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