| Class | Spec::DSL::Example |
| In: |
lib/spec/dsl/example.rb
|
| Parent: | Object |
| number | [RW] | The global sequence number of this example |
# File lib/spec/dsl/example.rb, line 9
9: def initialize(description, options={}, &example_block)
10: @from = caller(0)[3]
11: @options = options
12: @example_block = example_block
13: @description = description
14: @description_generated_proc = lambda { |desc| @generated_description = desc }
15: end
# File lib/spec/dsl/example.rb, line 40
40: def description
41: @description == :__generate_description ? generated_description : @description
42: end
# File lib/spec/dsl/example.rb, line 35
35: def matches?(matcher, specified_examples)
36: matcher.example_desc = description
37: matcher.matches?(specified_examples)
38: end
# File lib/spec/dsl/example.rb, line 17
17: def run(reporter, before_each_block, after_each_block, dry_run, execution_context, timeout=nil)
18: @dry_run = dry_run
19: reporter.example_started(self)
20: return reporter.example_finished(self) if dry_run
21:
22: errors = []
23: location = nil
24: Timeout.timeout(timeout) do
25: before_each_ok = before_example(execution_context, errors, &before_each_block)
26: example_ok = run_example(execution_context, errors) if before_each_ok
27: after_each_ok = after_example(execution_context, errors, &after_each_block)
28: location = failure_location(before_each_ok, example_ok, after_each_ok)
29: end
30:
31: ExampleShouldRaiseHandler.new(@from, @options).handle(errors)
32: reporter.example_finished(self, errors.first, location, @example_block.nil?) if reporter
33: end