Class: GreenPepper::DoWithExampleFactory

Inherits:
ExampleFactory show all
Defined in:
lib/greenpepper/factory/dowithexamplefactory.rb

Instance Method Summary collapse

Instance Method Details

#create_example(table) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/greenpepper/factory/dowithexamplefactory.rb', line 12

def create_example(table)
  return nil unless support? table

  # fixture name in cell 0,1
  example = create_example_factory table[0][1]

  # data in next rows
  table[1..-1].each {|row| 
    execute_dowith_line row, example
  }
  return example
end

#last_table?(table) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/greenpepper/factory/dowithexamplefactory.rb', line 29

def last_table?(table)
  /^\s*end\s*$/i === table[-1][0]
end

#support?(table) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/greenpepper/factory/dowithexamplefactory.rb', line 25

def support?(table)
  /^\s*do\s*with\s*$/i === table[0][0]
end