Class: Gurke::Scenario

Inherits:
Object
  • Object
show all
Defined in:
lib/gurke/scenario.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, tags, raw)
  @feature = feature
  @steps   = RunList.new
  @file    = file
  @line    = line
  @tags    = tags
  @raw     = raw
end

Instance Attribute Details

#exceptionException (readonly)

Exception that led to either pending or failed state.



85
86
87
# File 'lib/gurke/scenario.rb', line 85

def exception
  @exception
end

#featureFeature (readonly)

The feature that contains this scenario.



20
21
22
# File 'lib/gurke/scenario.rb', line 20

def feature
  @feature
end

#fileString (readonly)

Return path to file containing this scenario.



8
9
10
# File 'lib/gurke/scenario.rb', line 8

def file
  @file
end

#lineFixnum (readonly)

Return line number where the scenario is defined.



14
15
16
# File 'lib/gurke/scenario.rb', line 14

def line
  @line
end

#rawObject (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

#stepsArray<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

#tagsObject (readonly)

Returns the value of attribute tags.



31
32
33
# File 'lib/gurke/scenario.rb', line 31

def tags
  @tags
end

Instance Method Details

#backgroundsArray<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

#nameString

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