Class: Vigia::Sail::Example
Instance Attribute Summary
Attributes inherited from RSpecObject
#name, #options, #rspec
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from RSpecObject
clean!, #contextual_object, inherited, #initialize, setup_and_run
Methods included from Hooks
#execute_hook, #hooks_for_object, #with_hooks
Class Method Details
.example_contexts_include?(context, example_name, enabled_contexts) ⇒ Boolean
16
17
18
19
|
# File 'lib/vigia/sail/example.rb', line 16
def example_contexts_include?(context, example_name, enabled_contexts)
return context.options[:examples].include?(example_name) if context.options[:examples].is_a?(Enumerable)
[ *(enabled_contexts || :default) ].include?(context.name)
end
|
.register(name, options) ⇒ Object
5
6
7
8
|
# File 'lib/vigia/sail/example.rb', line 5
def register(name, options)
@collection = {} if collection.nil?
@collection.merge!(name => options)
end
|
.run_in_context(context, rspec_context) ⇒ Object
10
11
12
13
14
|
# File 'lib/vigia/sail/example.rb', line 10
def run_in_context(context, rspec_context)
@collection.each do |name, options|
setup_and_run(name, rspec_context) if example_contexts_include?(context, name, options[:contexts])
end
end
|
Instance Method Details
#disabled?(in_context) ⇒ Boolean
48
49
50
51
|
# File 'lib/vigia/sail/example.rb', line 48
def disabled?(in_context)
return false unless options[:disable_if]
contextual_object(option_name: :disable_if, context: in_context)
end
|
#expectation ⇒ Object
33
34
35
|
# File 'lib/vigia/sail/example.rb', line 33
def expectation
must_be_a_block(options[:expectation], "Example `#{ name }` expectation must be a block")
end
|
#run ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/vigia/sail/example.rb', line 22
def run
instance = self
rspec.it instance do
skip if instance.skip?(self) || (respond_to?(:skip?) and send(:skip?))
unless instance.disabled?(self) || (respond_to?(:disabled?) and send(:disabled?))
instance_exec(&instance.expectation)
end
end
end
|
#skip?(in_context) ⇒ Boolean
43
44
45
46
|
# File 'lib/vigia/sail/example.rb', line 43
def skip?(in_context)
return false unless options[:skip_if]
contextual_object(option_name: :skip_if, context: in_context)
end
|
#to_s ⇒ Object
37
38
39
40
41
|
# File 'lib/vigia/sail/example.rb', line 37
def to_s
return contextual_object(option_name: :description) if options[:description]
name.to_s
end
|