Class: OSpec::Example
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#example_group ⇒ Object
readonly
Returns the value of attribute example_group.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
Instance Method Summary collapse
-
#initialize(group, desc, block) ⇒ Example
constructor
A new instance of Example.
- #run(runner) ⇒ Object
- #run_after_hooks ⇒ Object
- #run_before_hooks ⇒ Object
Constructor Details
#initialize(group, desc, block) ⇒ Example
Returns a new instance of Example.
5 6 7 8 9 |
# File 'lib/ospec/example.rb', line 5 def initialize(group, desc, block) @example_group = group @description = desc @__block__ = block end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
3 4 5 |
# File 'lib/ospec/example.rb', line 3 def description @description end |
#example_group ⇒ Object (readonly)
Returns the value of attribute example_group.
3 4 5 |
# File 'lib/ospec/example.rb', line 3 def example_group @example_group end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
3 4 5 |
# File 'lib/ospec/example.rb', line 3 def exception @exception end |
Instance Method Details
#run(runner) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ospec/example.rb', line 23 def run runner begin runner.example_started self run_before_hooks instance_eval &@__block__ rescue => e @exception = e ensure begin run_after_hooks rescue => e @exception = e end end if @exception runner.example_failed self else runner.example_passed self end end |
#run_after_hooks ⇒ Object
17 18 19 20 21 |
# File 'lib/ospec/example.rb', line 17 def run_after_hooks @example_group.after_hooks.each do |after| instance_eval &after end end |
#run_before_hooks ⇒ Object
11 12 13 14 15 |
# File 'lib/ospec/example.rb', line 11 def run_before_hooks @example_group.before_hooks.each do |before| instance_eval &before end end |