I want to know how to implement data tables in cucumber ruby ? need an example to use both data tables and examples together from a feature file.
please provide an example feature with these and their implementation files.
I want to know how to implement data tables in cucumber ruby ? need an example to use both data tables and examples together from a feature file.
please provide an example feature with these and their implementation files.
With a scenario like this
Scenario Outline:
Given I have a username and password and a boolean
|username | password | boolean |
| myname | mysecret | <boolean> |
Then I print them out
Examples:
| boolean |
| true |
| false |
You would use step defs like this:
Given(/^I have a username and password and a boolean$/) do | table |
@data = table.hashes
end
Then(/^I print them out$/) do
@data.each { |_k, v| puts v }
# or
data_for_row_one_of_table = @data[0]
username = data_for_row_one_of_table['username']
# Do something with username here
...
end
Does that answer your question?