Skip to content

Instantly share code, notes, and snippets.

@bgswan
Created February 24, 2011 17:35
Show Gist options
  • Save bgswan/842515 to your computer and use it in GitHub Desktop.
Save bgswan/842515 to your computer and use it in GitHub Desktop.
The step definitions for the cart feature
When /^(\d+) x \$(\d+)/ do |qty, price|
@basket ||= []
@basket << (qty.to_i * price.to_i)
end
Then /^Total bill = \$(.+)$/ do |expected_total|
@basket.inject(0) {|memo, item| memo += item}.should eql(expected_total.to_i)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment