Git Product home page Git Product logo

cucumber_tricks's Introduction

Build Status Test Coverage Code Climate

CucumberTricks

Cucumber step definition dsl extension to easily define more readable steps.

Installation

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

Usage

Detailed usage examples can be found on relish

Requiring the files

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.

Use pronouns to reference previously introduced items

foo.feature

Given the tool 'screwdriver'
When this tool is used

steps.rb

A_TOOL = NameOrPronounTransform('tool', 'hammer')

Given /^(#{A_TOOL})$/ do |tool|
  ...
end

Use the same step implementation to handle an inline arg as a 1-cell table

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 |

Add default values to the hashes of a table

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

Define named lists from a table

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

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

cucumber_tricks's People

Contributors

philou avatar

Watchers

 avatar  avatar  avatar

cucumber_tricks's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.