Class: Vigia::Sail::Context
Instance Attribute Summary
Attributes inherited from RSpecObject
#name, #options, #rspec
Instance Method Summary
collapse
Methods inherited from RSpecObject
clean!, #contextual_object, inherited, #initialize, register, setup_and_run
Methods included from Hooks
#execute_hook, #hooks_for_object, #with_hooks
Instance Method Details
#run ⇒ Object
5
6
7
|
# File 'lib/vigia/sail/context.rb', line 5
def run
run_rspec_context unless disabled?
end
|
#run_children(in_context) ⇒ Object
56
57
58
59
60
|
# File 'lib/vigia/sail/context.rb', line 56
def run_children(in_context)
children.each do |context_name|
Vigia::Sail::Context.setup_and_run(context_name, in_context)
end
end
|
#run_examples(in_context) ⇒ Object
#run_rspec_context ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/vigia/sail/context.rb', line 39
def run_rspec_context
instance = self
rspec.context instance.to_s do
define_singleton_method("context_#{ instance.name }", ->{ instance })
instance.with_hooks(self) do
let(:http_client_options) { instance.set_http_client_options(self) }
let(:expectations) { instance.set_expectations(self) }
instance.run_examples(self)
instance.run_children(self)
instance.run_shared_examples(self)
end
end
end
|
#run_shared_examples(in_context) ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/vigia/sail/context.rb', line 27
def run_shared_examples(in_context)
if custom_examples.any?
custom_examples.each do |example_name|
in_context.include_examples example_name
end
end
end
|
#set_expectations(in_let_context) ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'lib/vigia/sail/context.rb', line 13
def set_expectations(in_let_context)
Vigia::HttpClient::ExpectedRequest.new.tap do |instance|
expectations.each do |name|
option_object = options[:expectations][name]
instance[name] = contextual_object(object: option_object, context: in_let_context)
end
instance
end
end
|
#set_http_client_options(in_let_context) ⇒ Object
9
10
11
|
# File 'lib/vigia/sail/context.rb', line 9
def set_http_client_options(in_let_context)
Vigia::HttpClient::Options.build(self, in_let_context)
end
|
#to_s ⇒ Object
35
36
37
|
# File 'lib/vigia/sail/context.rb', line 35
def to_s
(contextual_object(option_name: :description) || "context #{ name }").to_s
end
|