Class: Cucumber::Ast::Examples

Inherits:
Object
  • Object
show all
Includes:
HasLocation, Names
Defined in:
lib/cucumber/ast/examples.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Attributes included from Names

#description, #title

Instance Method Summary collapse

Methods included from HasLocation

#file, #file_colon_line, #line, #location

Methods included from Names

#name

Constructor Details

#initialize(location, comment, keyword, title, description, outline_table) ⇒ Examples

Returns a new instance of Examples.

Raises:

  • (ArgumentError)

10
11
12
13
14
# File 'lib/cucumber/ast/examples.rb', line 10

def initialize(location, comment, keyword, title, description, outline_table)
  @location, @comment, @keyword, @title, @description, @outline_table = location, comment, keyword, title, description, outline_table
  raise ArgumentError unless @location.is_a?(Location)
  raise ArgumentError unless @comment.is_a?(Comment)
end

Instance Attribute Details

#gherkin_statement(statement = nil) ⇒ Object (readonly)

Returns the value of attribute gherkin_statement


16
17
18
# File 'lib/cucumber/ast/examples.rb', line 16

def gherkin_statement
  @gherkin_statement
end

#outline_table=(value) ⇒ Object (writeonly)

Sets the attribute outline_table

Parameters:

  • value

    the value to set the attribute outline_table to.


8
9
10
# File 'lib/cucumber/ast/examples.rb', line 8

def outline_table=(value)
  @outline_table = value
end

Instance Method Details

#accept(visitor) ⇒ Object


21
22
23
24
25
26
# File 'lib/cucumber/ast/examples.rb', line 21

def accept(visitor)
  return if Cucumber.wants_to_quit
  visitor.visit_comment(@comment) unless @comment.empty?
  visitor.visit_examples_name(@keyword, name)
  visitor.visit_outline_table(@outline_table)
end

#each_example_row(&proc) ⇒ Object


32
33
34
# File 'lib/cucumber/ast/examples.rb', line 32

def each_example_row(&proc)
  @outline_table.cells_rows[1..-1].each(&proc)
end

#failed?Boolean

Returns:

  • (Boolean)

36
37
38
# File 'lib/cucumber/ast/examples.rb', line 36

def failed?
  @outline_table.cells_rows[1..-1].select{|row| row.failed?}.any?
end

#skip_invoke!Object


28
29
30
# File 'lib/cucumber/ast/examples.rb', line 28

def skip_invoke!
  @outline_table.skip_invoke!
end

#to_sexpObject


40
41
42
43
44
45
46
# File 'lib/cucumber/ast/examples.rb', line 40

def to_sexp
  sexp = [:examples, @keyword, name]
  comment = @comment.to_sexp
  sexp += [comment] if comment
  sexp += [@outline_table.to_sexp]
  sexp
end