Cucumber step definition dsl extension to easily define more readable steps.
Add this line to your application's Gemfile:
gem 'cucumber_tricks', :require => false
And then execute:
$ bundle
Or install it yourself as:
$ gem install cucumber_tricks
Detailed usage examples can be found on relish
Add `require 'cucumber_tricks' from every steps definition file where you use it. This will make cucumber work in normal mode as well as in dry-run mode.
foo.feature
Given the tool 'screwdriver'
When this tool is used
steps.rb
A_TOOL = NameOrPronounTransform('tool', 'hammer')
Given /^(#{A_TOOL})$/ do |tool|
...
end
steps.rb
GivenEither /^the dog named "(.*)"$)$/,
/^the following dogs$/ do |dogs_table|
...
end
foo.feature
Given the dog "Rolphy"
...
Given the following dogs
| Rex |
| King |
| Volt |
foo.feature
Given the following dogs
| names | color |
| Rex | white |
| King | Sand |
steps.rb
Given /^the following dogs$$/ do |dogs|
hashes = dogs.hashes_with_defaults('names', 'tail' => 'wagging', 'smell' => 'not nice')
# hashes.each do |hash|
# expect(hash['smell']).to eq('not nice')
# end
...
end
foo.feature
Given the following dishes
| Spaghetti Bolognaise | => | Spaghetti | Bolognaise sauce | | |
| Burger | => | Bread | Meat | Salad | Ketchup |
steps.rb
Given /^the following dishes$$/ do |dishes|
name_2_dishes = dishes.hash_2_lists
# expect(name_2_dishes['Burger']).to eq(['Bread','Meat','Salad','Ketchup'])
...
end
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request