cuke_data

The cuke_data gem provides a single class, CukeData. CukeData.method_missing is defined such that you can call CukeData.whatever_you_want and it will return an instance of CukeData. The instance maintains a hash of values and raises an exception if you attempt to access a key that isn't set.

Examples

CukeData.foo === CukeData.foo #=> true
CukeData.bar === CukeData.bar #=> true
CukeData.foo === CukeData.bar #=> false

CukeData.baz[:bam] = :foo
CukeData.baz[:bam] #=> :foo
CukeData.baz[:never_set] # raises RuntimeError

Using CukeData, if you have the following steps in your feature definition:

Given there is a user named "Bob"
And there is an account "My Savings"
And the user "Bob" has access to "My Savings"

The step definitions can look like:

Given /^there is a user named "([^\"]+)"$/ do |name|
  CukeData.users[name] = User.create!(:name => name)
end

Given /^there is an account "([^\"]+)"$/ do |name|
  CukeData.accounts[name] = Account.create!(:name => name)
end

Given /^the user "([^\"]+)" has access to "([^\"]+)"$/ do |user_name, |
  CukeData.accounts[].grant_access(CukeData.users[user_name])
end

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 John Wilger. See LICENSE for details.