Module: RubyPitaya::AppSpecHelper

Included in:
AppSpecHelperClass
Defined in:
lib/rubypitaya/core/spec-helpers/app_spec_helper.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.finalize_after_suiteObject



38
39
40
41
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 38

def self.finalize_after_suite
  clear_all_services_data
  disconnect_services
end

.initialize_before_suiteObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 12

def self.initialize_before_suite
  default_setup = Setup.new.get_config

  @@log = Logger.new('/dev/null')
  @@setup = SetupSpecHelper.new(default_setup)
  @@config = ConfigSpecHelper.new
  @@session = Session.new
  @@postman = PostmanSpecHelper.new
  @@services = ServiceHolder.new

  @@default_setup = Setup.new

  is_cheats_enabled = @@setup.fetch('rubypitaya.server.cheats', true)
  @@handler_router ||= HandlerRouter.new(is_cheats_enabled)


  @@initializer_content = InitializerContent.new(@@log,
                                                 @@services,
                                                 @@setup,
                                                 @@config)
  @@initializer_broadcast = InitializerBroadcast.new
  @@initializer_broadcast.run(@@initializer_content)

  connect_services
end

.update_before_eachObject



43
44
45
46
47
48
49
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 43

def self.update_before_each
  @@response = {}
  @@setup.clear
  @@config.clear
  @@session.clear
  clear_all_services_data
end

Instance Method Details

#add_config(*keys, value) ⇒ Object



87
88
89
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 87

def add_config(*keys, value)
  @@config.add(*keys, value)
end

#add_setup(*keys, value) ⇒ Object



91
92
93
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 91

def add_setup(*keys, value)
  @@setup.add(*keys, value)
end

#authenticate(user_id) ⇒ Object



71
72
73
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 71

def authenticate(user_id)
  @@session.uid = user_id
end

#configObject



103
104
105
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 103

def config
  @@config
end

#initialize(context) ⇒ Object



51
52
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 51

def initialize(context)
end

#logObject



95
96
97
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 95

def log
  @@log
end

#postmanObject



111
112
113
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 111

def postman
  @@postman
end

#request(route, params = {}) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 54

def request(route, params = {})
  handler_name, action_name = route.split('.')[1..-1]

  @@response = @@handler_router.call(handler_name, action_name, @@session,
                                     @@postman, @@services, @@setup,
                                     @@config, @@log, params)
  rescue RouteError => error
    @@response = {
      code: error.code,
      message: error.message
    }
end

#responseObject



67
68
69
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 67

def response
  @@response
end

#servicesObject



115
116
117
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 115

def services
  @@services
end

#sessionObject



107
108
109
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 107

def session
  @@session
end

#set_config(config) ⇒ Object



75
76
77
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 75

def set_config(config)
  @@config.config_mock = config
end

#set_postman(postman) ⇒ Object



83
84
85
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 83

def set_postman(postman)
  @@postman.postman_mock = postman
end

#set_setup(setup) ⇒ Object



79
80
81
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 79

def set_setup(setup)
  @@setup.setup_mock = setup
end

#setupObject



99
100
101
# File 'lib/rubypitaya/core/spec-helpers/app_spec_helper.rb', line 99

def setup
  @@setup
end