Class: Gurke::Scenario
- Inherits:
-
Object
- Object
- Gurke::Scenario
- Defined in:
- lib/gurke/scenario.rb
Instance Attribute Summary collapse
-
#exception ⇒ Exception
readonly
Exception that led to either pending or failed state.
-
#feature ⇒ Feature
readonly
The feature that contains this scenario.
-
#file ⇒ String
readonly
Return path to file containing this scenario.
-
#line ⇒ Fixnum
readonly
Return line number where the scenario is defined.
- #raw ⇒ Object readonly private
-
#steps ⇒ Array<Step>
readonly
List of this scenario’s steps.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
-
#backgrounds ⇒ Array<Background>
Return all backgrounds for this scenario.
-
#failed!(error = nil) ⇒ Object
Call to mark scenario as failed.
-
#failed? ⇒ Boolean
Check if scenario has failed.
-
#initialize(feature, file, line, tags, raw) ⇒ Scenario
constructor
private
A new instance of Scenario.
-
#name ⇒ String
Return name of the scenario.
-
#pending!(error) ⇒ Object
Call to mark scenario as pending.
-
#pending? ⇒ Boolean
Check if scenario is pending.
- #run(runner, reporter) ⇒ Object private
Constructor Details
#initialize(feature, file, line, tags, raw) ⇒ Scenario
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Scenario.
38 39 40 41 42 43 44 45 |
# File 'lib/gurke/scenario.rb', line 38 def initialize(feature, file, line, , raw) @feature = feature @steps = RunList.new @file = file @line = line @tags = @raw = raw end |
Instance Attribute Details
#exception ⇒ Exception (readonly)
Exception that led to either pending or failed state.
85 86 87 |
# File 'lib/gurke/scenario.rb', line 85 def exception @exception end |
#feature ⇒ Feature (readonly)
The feature that contains this scenario.
20 21 22 |
# File 'lib/gurke/scenario.rb', line 20 def feature @feature end |
#file ⇒ String (readonly)
Return path to file containing this scenario.
8 9 10 |
# File 'lib/gurke/scenario.rb', line 8 def file @file end |
#line ⇒ Fixnum (readonly)
Return line number where the scenario is defined.
14 15 16 |
# File 'lib/gurke/scenario.rb', line 14 def line @line end |
#raw ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 |
# File 'lib/gurke/scenario.rb', line 34 def raw @raw end |
#steps ⇒ Array<Step> (readonly)
List of this scenario’s steps.
This does not include background steps.
28 29 30 |
# File 'lib/gurke/scenario.rb', line 28 def steps @steps end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
31 32 33 |
# File 'lib/gurke/scenario.rb', line 31 def @tags end |
Instance Method Details
#backgrounds ⇒ Array<Background>
Return all backgrounds for this scenario.
They are taken from the feature containing this scenario.
61 62 63 |
# File 'lib/gurke/scenario.rb', line 61 def backgrounds feature.backgrounds end |
#failed!(error = nil) ⇒ Object
Call to mark scenario as failed.
91 92 93 94 |
# File 'lib/gurke/scenario.rb', line 91 def failed!(error = nil) @exception = error @state = :failed end |
#failed? ⇒ Boolean
Check if scenario has failed.
77 78 79 |
# File 'lib/gurke/scenario.rb', line 77 def failed? @state == :failed end |
#name ⇒ String
Return name of the scenario.
51 52 53 |
# File 'lib/gurke/scenario.rb', line 51 def name raw.name end |
#pending!(error) ⇒ Object
Call to mark scenario as pending. Will do nothing if scenario is already failed.
101 102 103 104 105 106 |
# File 'lib/gurke/scenario.rb', line 101 def pending!(error) return if failed? @exception = error @state = :pending end |
#pending? ⇒ Boolean
Check if scenario is pending.
69 70 71 |
# File 'lib/gurke/scenario.rb', line 69 def pending? @state == :pending end |
#run(runner, reporter) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
110 111 112 113 114 115 116 117 118 |
# File 'lib/gurke/scenario.rb', line 110 def run(runner, reporter) reporter.invoke :before_scenario, self runner.hook :scenario, world do run_scenario runner, reporter end ensure reporter.invoke :after_scenario, self end |