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
- #abort! ⇒ Object private
-
#aborted? ⇒ Boolean
Check if scenario was aborted.
-
#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.
- #passed! ⇒ Object private
-
#passed? ⇒ Boolean
Check if scenario has passed.
-
#pending!(error) ⇒ Object
Call to mark scenario as pending.
-
#pending? ⇒ Boolean
Check if scenario is pending.
- #retryable? ⇒ Boolean
- #run(runner, reporter) ⇒ Object private
-
#run? ⇒ Boolean
Check if scenario was run and the state has changed.
-
#tag_names ⇒ Array<String>
Return a list of tag names as strings.
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.
40 41 42 43 44 45 46 47 48 |
# File 'lib/gurke/scenario.rb', line 40 def initialize(feature, file, line, , raw) @feature = feature @steps = RunList.new @file = file @line = line @tags = @raw = raw @state = nil end |
Instance Attribute Details
#exception ⇒ Exception (readonly)
Exception that led to either pending or failed state.
118 119 120 |
# File 'lib/gurke/scenario.rb', line 118 def exception @exception end |
#feature ⇒ Feature (readonly)
The feature that contains this scenario.
22 23 24 |
# File 'lib/gurke/scenario.rb', line 22 def feature @feature end |
#file ⇒ String (readonly)
Return path to file containing this scenario.
10 11 12 |
# File 'lib/gurke/scenario.rb', line 10 def file @file end |
#line ⇒ Fixnum (readonly)
Return line number where the scenario is defined.
16 17 18 |
# File 'lib/gurke/scenario.rb', line 16 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.
36 37 38 |
# File 'lib/gurke/scenario.rb', line 36 def raw @raw end |
#steps ⇒ Array<Step> (readonly)
List of this scenario’s steps.
This does not include background steps.
30 31 32 |
# File 'lib/gurke/scenario.rb', line 30 def steps @steps end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
33 34 35 |
# File 'lib/gurke/scenario.rb', line 33 def @tags end |
Instance Method Details
#abort! ⇒ 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.
152 153 154 155 |
# File 'lib/gurke/scenario.rb', line 152 def abort! @exception = nil @state = :aborted end |
#aborted? ⇒ Boolean
Check if scenario was aborted.
104 105 106 |
# File 'lib/gurke/scenario.rb', line 104 def aborted? @state == :aborted end |
#backgrounds ⇒ Array<Background>
Return all backgrounds for this scenario.
They are taken from the feature containing this scenario.
64 65 66 |
# File 'lib/gurke/scenario.rb', line 64 def backgrounds feature.backgrounds end |
#failed!(error = nil) ⇒ Object
Call to mark scenario as failed.
124 125 126 127 |
# File 'lib/gurke/scenario.rb', line 124 def failed!(error = nil) @exception = error @state = :failed end |
#failed? ⇒ Boolean
Check if scenario has failed.
88 89 90 |
# File 'lib/gurke/scenario.rb', line 88 def failed? @state == :failed end |
#name ⇒ String
Return name of the scenario.
54 55 56 |
# File 'lib/gurke/scenario.rb', line 54 def name raw.name end |
#passed! ⇒ 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.
145 146 147 148 |
# File 'lib/gurke/scenario.rb', line 145 def passed! @exception = nil @state = :passed end |
#passed? ⇒ Boolean
Check if scenario has passed.
96 97 98 |
# File 'lib/gurke/scenario.rb', line 96 def passed? @state == :passed end |
#pending!(error) ⇒ Object
Call to mark scenario as pending. Will do nothing if scenario is already failed.
134 135 136 137 |
# File 'lib/gurke/scenario.rb', line 134 def pending!(error) @exception = error @state = :pending end |
#pending? ⇒ Boolean
Check if scenario is pending.
80 81 82 |
# File 'lib/gurke/scenario.rb', line 80 def pending? @state == :pending end |
#retryable? ⇒ Boolean
139 140 141 |
# File 'lib/gurke/scenario.rb', line 139 def retryable? @tags.any? {|t| t.name == 'flaky' } 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.
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/gurke/scenario.rb', line 159 def run(runner, reporter) reporter.invoke :before_scenario, self runner.hook :scenario, self, world do run_scenario runner, reporter end if failed? && retryable? reporter.invoke :retry_scenario, self reset! runner.hook :scenario, self, world do run_scenario runner, reporter end end ensure reporter.invoke :after_scenario, self end |
#run? ⇒ Boolean
Check if scenario was run and the state has changed.
110 111 112 |
# File 'lib/gurke/scenario.rb', line 110 def run? !@state.nil? end |
#tag_names ⇒ Array<String>
Return a list of tag names as strings.
72 73 74 |
# File 'lib/gurke/scenario.rb', line 72 def tag_names @tag_names ||= .map(&:name) end |