Class: Cucumber::Ast::OutlineTable::ExampleRow

Inherits:
Cells
  • Object
show all
Defined in:
lib/cucumber/ast/outline_table.rb

Overview

:nodoc:

Defined Under Namespace

Classes: InvalidForHeaderRowError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table, cells) ⇒ ExampleRow

Returns a new instance of ExampleRow.



60
61
62
63
# File 'lib/cucumber/ast/outline_table.rb', line 60

def initialize(table, cells)
  super
  @scenario_exception = nil
end

Instance Attribute Details

#scenario_outlineObject (readonly)



58
59
60
# File 'lib/cucumber/ast/outline_table.rb', line 58

def scenario_outline
  @scenario_outline
end

Instance Method Details

#accept(visitor) ⇒ Object



76
77
78
79
# File 'lib/cucumber/ast/outline_table.rb', line 76

def accept(visitor)
  return if Cucumber.wants_to_quit
  visitor.options[:expand] ? accept_expand(visitor) : accept_plain(visitor)
end

#accept_expand(visitor) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/cucumber/ast/outline_table.rb', line 103

def accept_expand(visitor)
  if header?
  else
    visitor.step_mother.before_and_after(self) do
      @table.visit_scenario_name(visitor, self)
      @step_invocations.each do |step_invocation|
        step_invocation.invoke(visitor.step_mother, visitor.options)
        @exception ||= step_invocation.reported_exception
        step_invocation.visit_step_result(visitor)
      end
    end
  end
end

#accept_hook?(hook) ⇒ Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/cucumber/ast/outline_table.rb', line 117

def accept_hook?(hook)
  @table.accept_hook?(hook)
end

#accept_plain(visitor) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/cucumber/ast/outline_table.rb', line 81

def accept_plain(visitor)
  if header?
    @cells.each do |cell|
      cell.status = :skipped_param
      visitor.visit_table_cell(cell)
    end
  else
    visitor.step_mother.before_and_after(self) do
      @step_invocations.each do |step_invocation|
        step_invocation.invoke(visitor.step_mother, visitor.options)
        @exception ||= step_invocation.reported_exception
      end

      @cells.each do |cell|
        visitor.visit_table_cell(cell)
      end
      
      visitor.visit_exception(@scenario_exception, :failed) if @scenario_exception
    end
  end
end

#backtrace_lineObject



146
147
148
# File 'lib/cucumber/ast/outline_table.rb', line 146

def backtrace_line
  @scenario_outline.backtrace_line(name, line)
end

#create_step_invocations!(scenario_outline) ⇒ Object



65
66
67
68
# File 'lib/cucumber/ast/outline_table.rb', line 65

def create_step_invocations!(scenario_outline)
  @scenario_outline = scenario_outline
  @step_invocations = scenario_outline.step_invocations(self)
end

#exceptionObject



121
122
123
# File 'lib/cucumber/ast/outline_table.rb', line 121

def exception
  @exception || @scenario_exception
end

#fail!(exception) ⇒ Object



125
126
127
# File 'lib/cucumber/ast/outline_table.rb', line 125

def fail!(exception)
  @scenario_exception = exception
end

#failed?Boolean

Returns true if one or more steps failed

Returns:

  • (Boolean)

Raises:



130
131
132
133
# File 'lib/cucumber/ast/outline_table.rb', line 130

def failed?
  raise InvalidForHeaderRowError if header?
  @step_invocations.failed? || !!@scenario_exception
end

#languageObject



154
155
156
# File 'lib/cucumber/ast/outline_table.rb', line 154

def language
  @table.language
end

#nameObject



150
151
152
# File 'lib/cucumber/ast/outline_table.rb', line 150

def name
  "| #{@cells.collect{|c| c.value }.join(' | ')} |"
end

#passed?Boolean

Returns true if all steps passed

Returns:

  • (Boolean)


136
137
138
# File 'lib/cucumber/ast/outline_table.rb', line 136

def passed?
  !failed?
end

#skip_invoke!Object



70
71
72
73
74
# File 'lib/cucumber/ast/outline_table.rb', line 70

def skip_invoke!
  @step_invocations.each do |step_invocation|
    step_invocation.skip_invoke!
  end
end

#statusObject

Returns the status



141
142
143
144
# File 'lib/cucumber/ast/outline_table.rb', line 141

def status
  return :failed if @scenario_exception
  @step_invocations.status
end