Class: RSpec::Core::Example
Instance Attribute Summary collapse
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #behaviour ⇒ Object
- #example_group ⇒ Object
- #fail_fast(reporter, exception) ⇒ Object
-
#initialize(example_group_class, desc, options, example_block = nil) ⇒ Example
constructor
A new instance of Example.
- #pending? ⇒ Boolean
- #run(example_group_instance, reporter) ⇒ Object
- #set_exception(exception) ⇒ Object
Constructor Details
#initialize(example_group_class, desc, options, example_block = nil) ⇒ Example
Returns a new instance of Example.
15 16 17 18 19 20 |
# File 'lib/rspec/core/example.rb', line 15 def initialize(example_group_class, desc, , example_block=nil) @example_group_class, @options, @example_block = example_group_class, , example_block @metadata = @example_group_class..for_example(desc, ) @exception = nil @pending_declared_in_example = false end |
Instance Attribute Details
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/rspec/core/example.rb', line 5 def @metadata end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/rspec/core/example.rb', line 5 def @options end |
Class Method Details
.delegate_to_metadata(*keys) ⇒ Object
7 8 9 10 11 |
# File 'lib/rspec/core/example.rb', line 7 def self.(*keys) keys.each do |key| define_method(key) {@metadata[key]} end end |
Instance Method Details
#behaviour ⇒ Object
26 27 28 29 |
# File 'lib/rspec/core/example.rb', line 26 def behaviour RSpec.deprecate("behaviour", "example_group") example_group end |
#example_group ⇒ Object
22 23 24 |
# File 'lib/rspec/core/example.rb', line 22 def example_group @example_group_class end |
#fail_fast(reporter, exception) ⇒ Object
70 71 72 73 74 |
# File 'lib/rspec/core/example.rb', line 70 def fail_fast(reporter, exception) start(reporter) set_exception(exception) finish(reporter) end |
#pending? ⇒ Boolean
31 32 33 |
# File 'lib/rspec/core/example.rb', line 31 def pending? !!pending end |
#run(example_group_instance, reporter) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rspec/core/example.rb', line 35 def run(example_group_instance, reporter) @example_group_instance = example_group_instance @example_group_instance.example = self start(reporter) begin unless pending with_pending_capture do with_around_hooks do begin run_before_each @example_group_instance.instance_eval(&@example_block) rescue Exception => e set_exception(e) ensure run_after_each end end end end rescue Exception => e set_exception(e) ensure @example_group_instance.example = nil assign_auto_description end finish(reporter) end |
#set_exception(exception) ⇒ Object
66 67 68 |
# File 'lib/rspec/core/example.rb', line 66 def set_exception(exception) @exception ||= exception end |