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.
- #flaky? ⇒ Boolean
-
#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.
- #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.
39 40 41 42 43 44 45 46 47 |
# File 'lib/gurke/scenario.rb', line 39 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.
117 118 119 |
# File 'lib/gurke/scenario.rb', line 117 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.
35 36 37 |
# File 'lib/gurke/scenario.rb', line 35 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.
32 33 34 |
# File 'lib/gurke/scenario.rb', line 32 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.
151 152 153 154 |
# File 'lib/gurke/scenario.rb', line 151 def abort! @exception = nil @state = :aborted end |
#aborted? ⇒ Boolean
Check if scenario was aborted.
103 104 105 |
# File 'lib/gurke/scenario.rb', line 103 def aborted? @state == :aborted end |
#backgrounds ⇒ Array<Background>
Return all backgrounds for this scenario.
They are taken from the feature containing this scenario.
63 64 65 |
# File 'lib/gurke/scenario.rb', line 63 def backgrounds feature.backgrounds end |
#failed!(error = nil) ⇒ Object
Call to mark scenario as failed.
123 124 125 126 |
# File 'lib/gurke/scenario.rb', line 123 def failed!(error = nil) @exception = error @state = :failed end |
#failed? ⇒ Boolean
Check if scenario has failed.
87 88 89 |
# File 'lib/gurke/scenario.rb', line 87 def failed? @state == :failed end |
#flaky? ⇒ Boolean
138 139 140 |
# File 'lib/gurke/scenario.rb', line 138 def flaky? @tags.any? {|t| t.name == 'flaky' } end |
#name ⇒ String
Return name of the scenario.
53 54 55 |
# File 'lib/gurke/scenario.rb', line 53 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.
144 145 146 147 |
# File 'lib/gurke/scenario.rb', line 144 def passed! @exception = nil @state = :passed end |
#passed? ⇒ Boolean
Check if scenario has passed.
95 96 97 |
# File 'lib/gurke/scenario.rb', line 95 def passed? @state == :passed end |
#pending!(error) ⇒ Object
Call to mark scenario as pending. Will do nothing if scenario is already failed.
133 134 135 136 |
# File 'lib/gurke/scenario.rb', line 133 def pending!(error) @exception = error @state = :pending end |
#pending? ⇒ Boolean
Check if scenario is pending.
79 80 81 |
# File 'lib/gurke/scenario.rb', line 79 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.
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/gurke/scenario.rb', line 158 def run(runner, reporter) reporter.invoke :before_scenario, self _run(runner, reporter) return unless failed? (1..runner.retries(self)).each do reporter.invoke :retry_scenario, self reset! _run(runner, reporter) break unless failed? end ensure reporter.invoke :after_scenario, self end |
#run? ⇒ Boolean
Check if scenario was run and the state has changed.
109 110 111 |
# File 'lib/gurke/scenario.rb', line 109 def run? !@state.nil? end |
#tag_names ⇒ Array<String>
Return a list of tag names as strings.
71 72 73 |
# File 'lib/gurke/scenario.rb', line 71 def tag_names @tag_names ||= .map(&:name) end |