Class: Lucid::AST::OutlineTable::ExampleRow

Inherits:
Cells
  • Object
show all
Defined in:
lib/lucid/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.



61
62
63
64
# File 'lib/lucid/ast/outline_table.rb', line 61

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

Instance Attribute Details

#scenario_outlineObject (readonly)

Returns the value of attribute scenario_outline.



59
60
61
# File 'lib/lucid/ast/outline_table.rb', line 59

def scenario_outline
  @scenario_outline
end

Instance Method Details

#accept(visitor) ⇒ Object



85
86
87
88
89
90
91
92
93
# File 'lib/lucid/ast/outline_table.rb', line 85

def accept(visitor)
  if visitor.configuration.expand?
    accept_expand(visitor)
  else
    visitor.visit_table_row(self) do
      accept_plain(visitor)
    end
  end
end

#accept_expand(visitor) ⇒ Object



117
118
119
120
121
122
123
124
125
126
# File 'lib/lucid/ast/outline_table.rb', line 117

def accept_expand(visitor)
  return if header?
  visitor.runtime.with_hooks(self) do
    @table.visit_scenario_name(visitor, self)
    @step_invocations.each do |step_invocation|
      step_invocation.accept(visitor)
      @exception ||= step_invocation.reported_exception
    end
  end
end

#accept_hook?(hook) ⇒ Boolean

Returns:

  • (Boolean)


128
129
130
# File 'lib/lucid/ast/outline_table.rb', line 128

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

#accept_plain(visitor) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/lucid/ast/outline_table.rb', line 95

def accept_plain(visitor)
  if header?
    @cells.each do |cell|
      cell.status = :skipped_param
      cell.accept(visitor)
    end
  else
    visitor.runtime.with_hooks(self) do
      @step_invocations.each do |step_invocation|
        step_invocation.invoke(visitor.runtime, visitor.configuration)
        @exception ||= step_invocation.reported_exception
      end

      @cells.each do |cell|
        cell.accept(visitor)
      end

      visitor.visit_exception(@scenario_exception, :failed) if @scenario_exception
    end
  end
end

#backtrace_lineObject



157
158
159
# File 'lib/lucid/ast/outline_table.rb', line 157

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

#create_step_invocations!(scenario_outline) ⇒ Object



74
75
76
77
# File 'lib/lucid/ast/outline_table.rb', line 74

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

#exceptionObject



132
133
134
# File 'lib/lucid/ast/outline_table.rb', line 132

def exception
  @exception || @scenario_exception
end

#fail!(exception) ⇒ Object



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

def fail!(exception)
  @scenario_exception = exception
end

#failed?Boolean

Returns true if one or more steps failed

Returns:

  • (Boolean)

Raises:



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

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

#languageObject



165
166
167
# File 'lib/lucid/ast/outline_table.rb', line 165

def language
  @table.language
end

#nameObject



161
162
163
# File 'lib/lucid/ast/outline_table.rb', line 161

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

#passed?Boolean

Returns true if all steps passed

Returns:

  • (Boolean)


147
148
149
# File 'lib/lucid/ast/outline_table.rb', line 147

def passed?
  !failed?
end

#skip_invoke!Object



79
80
81
82
83
# File 'lib/lucid/ast/outline_table.rb', line 79

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

#source_tag_namesObject



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

def source_tag_names
  source_tags.map { |tag| tag.name }
end

#source_tagsObject



70
71
72
# File 'lib/lucid/ast/outline_table.rb', line 70

def source_tags
  @table.source_tags
end

#statusObject

Returns the status



152
153
154
155
# File 'lib/lucid/ast/outline_table.rb', line 152

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