Class: Spec::Runner::Specification
- Defined in:
- lib/spec/runner/specification.rb
Class Attribute Summary collapse
-
.current ⇒ Object
Returns the value of attribute current.
-
.generated_description ⇒ Object
Returns the value of attribute generated_description.
Instance Attribute Summary collapse
-
#spec_block ⇒ Object
readonly
Returns the value of attribute spec_block.
Instance Method Summary collapse
-
#initialize(name, opts = {}, &spec_block) ⇒ Specification
constructor
A new instance of Specification.
- #matches?(matcher, description) ⇒ Boolean
- #run(reporter, setup_block, teardown_block, dry_run, execution_context) ⇒ Object
Constructor Details
#initialize(name, opts = {}, &spec_block) ⇒ Specification
Returns a new instance of Specification.
15 16 17 18 19 20 21 |
# File 'lib/spec/runner/specification.rb', line 15 def initialize(name, opts={}, &spec_block) @from = caller(0)[3] @description = name @options = opts @spec_block = spec_block @description_generated_callback = lambda { |desc| @generated_description = desc } end |
Class Attribute Details
.current ⇒ Object
Returns the value of attribute current.
6 7 8 |
# File 'lib/spec/runner/specification.rb', line 6 def current @current end |
.generated_description ⇒ Object
Returns the value of attribute generated_description.
6 7 8 |
# File 'lib/spec/runner/specification.rb', line 6 def generated_description @generated_description end |
Instance Attribute Details
#spec_block ⇒ Object (readonly)
Returns the value of attribute spec_block.
12 13 14 |
# File 'lib/spec/runner/specification.rb', line 12 def spec_block @spec_block end |
Instance Method Details
#matches?(matcher, description) ⇒ Boolean
41 42 43 44 |
# File 'lib/spec/runner/specification.rb', line 41 def matches?(matcher, description) matcher.spec_desc = name matcher.matches?(description) end |
#run(reporter, setup_block, teardown_block, dry_run, execution_context) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/spec/runner/specification.rb', line 23 def run(reporter, setup_block, teardown_block, dry_run, execution_context) reporter.spec_started(name) if reporter return reporter.spec_finished(name) if dry_run errors = [] begin set_current setup_ok = setup_spec(execution_context, errors, &setup_block) spec_ok = execute_spec(execution_context, errors) if setup_ok teardown_ok = teardown_spec(execution_context, errors, &teardown_block) ensure clear_current end SpecShouldRaiseHandler.new(@from, @options).handle(errors) reporter.spec_finished(name, errors.first, failure_location(setup_ok, spec_ok, teardown_ok)) if reporter end |