Method: Cucumber::Glue::ProtoWorld#table

Defined in:
lib/cucumber/glue/proto_world.rb

#table(text_or_table, file = nil, line = 0) ⇒ Object

Parse Gherkin into a Ast::Table object.

Useful in conjunction with the #step method. Returns a Cucumber::MultilineArgument::DataTable for text_or_table, which can either be a String:

table(%{
  | account | description | amount |
  | INT-100 | Taxi        | 114    |
  | CUC-101 | Peeler      | 22     |
})

or a 2D Array:

table([
  %w{ account description amount },
  %w{ INT-100 Taxi        114    },
  %w{ CUC-101 Peeler      22     }
])

Examples:

Create a table

users = table(%{
  | name  | email           |
  | Matt  | [email protected]   |
  | Aslak | [email protected] |
})

Parameters:

  • text_or_table (String)

    The Gherkin string that represents the table



70
71
72
73
# File 'lib/cucumber/glue/proto_world.rb', line 70

def table(text_or_table, file = nil, line = 0)
  location = !file ? Core::Ast::Location.of_caller : Core::Ast::Location.new(file, line)
  MultilineArgument::DataTable.from(text_or_table, location)
end