Permalink
Browse files

added transforms

  • Loading branch information...
1 parent d119e77 commit 2b0454fa4185c9f882a9ea2584b9da3f2b6b01ab @cheezy committed Feb 20, 2011
Showing with 36 additions and 26 deletions.
  1. +18 −17 features/purchase_books.feature
  2. +18 −9 features/step_definitions/purchase_books_steps.rb
@@ -4,38 +4,39 @@ Feature: Purchase Books
Background:
Given I am on the shopping page
-
+
+@focus
Scenario: Verify cart with one book
When I purchase "Pragmatic Project Automation"
- Then I should see "1" in the quantity for line "1"
- And I should see "Pragmatic Project Automation" in the description for line "1"
- And I should see "29.95" in the each for line "1"
- And I should see "29.95" in the total for line "1"
+ Then I should see "1" in the quantity for line 1
+ And I should see "Pragmatic Project Automation" in the description for line 1
+ And I should see "29.95" in the each for line 1
+ And I should see "29.95" in the total for line 1
And I should see "29.95" in the cart total
Scenario: verify cart with two books
When I purchase "Pragmatic Project Automation"
And I continue shopping
And I purchase "Pragmatic Project Automation"
- Then I should see "2" in the quantity for line "1"
- And I should see "Pragmatic Project Automation" in the description for line "1"
- And I should see "29.95" in the each for line "1"
- And I should see "59.90" in the total for line "1"
+ Then I should see "2" in the quantity for line 1
+ And I should see "Pragmatic Project Automation" in the description for line 1
+ And I should see "29.95" in the each for line 1
+ And I should see "59.90" in the total for line 1
And I should see "59.90" in the cart total
Scenario: verify cart with two different books
When I purchase "Pragmatic Project Automation"
And I continue shopping
And I purchase "Pragmatic Version Control"
- Then I should see "1" in the quantity for line "1"
- And I should see "Pragmatic Project Automation" in the description for line "1"
- And I should see "29.95" in the each for line "1"
- And I should see "29.95" in the total for line "1"
- And I should see "1" in the quantity for line "2"
- And I should see "Pragmatic Version Control" in the description for line "2"
- And I should see "28.50" in the each for line "2"
- And I should see "28.50" in the total for line "2"
+ Then I should see "1" in the quantity for line 1
+ And I should see "Pragmatic Project Automation" in the description for line 1
+ And I should see "29.95" in the each for line 1
+ And I should see "29.95" in the total for line 1
+ And I should see "1" in the quantity for line 2
+ And I should see "Pragmatic Version Control" in the description for line 2
+ And I should see "28.50" in the each for line 2
+ And I should see "28.50" in the total for line 2
And I should see "58.45" in the cart total
Scenario: Purchase two books
@@ -1,3 +1,12 @@
+
+Transform /^line (\d+)$/ do |line_string|
+ line_string.to_i
+end
+
+Transform /^(\d+\.\d{2})$/ do |dollar_amount|
+ "$#{dollar_amount}"
+end
+
Given /^I am on the shopping page$/ do
@catalog = CatalogPage.new(@browser)
@catalog.visit
@@ -11,24 +20,24 @@
@shopping_cart.continue_shopping
end
-Then /^I should see "([^\"]*)" in the quantity for line "([^\"]*)"$/ do |quantity, line|
- @shopping_cart.quantity_for_line(line.to_i).should include quantity
+Then /^I should see "([^\"]*)" in the quantity for (line \d+)$/ do |quantity, line|
+ @shopping_cart.quantity_for_line(line).should include quantity
end
-Then /^I should see "([^\"]*)" in the description for line "([^\"]*)"$/ do |desc, line|
- @shopping_cart.description_for_line(line.to_i).should == desc
+Then /^I should see "([^\"]*)" in the description for (line \d+)$/ do |desc, line|
+ @shopping_cart.description_for_line(line).should == desc
end
-Then /^I should see "([^\"]*)" in the each for line "([^\"]*)"$/ do |each, line|
- @shopping_cart.each_for_line(line.to_i).should == "$#{each}"
+Then /^I should see "([^\"]*)" in the each for (line \d+)$/ do |each, line|
+ @shopping_cart.each_for_line(line).should == each
end
-Then /^I should see "([^\"]*)" in the total for line "([^\"]*)"$/ do |total, line|
- @shopping_cart.total_for_line(line.to_i).should == "$#{total}"
+Then /^I should see "([^\"]*)" in the total for (line \d+)$/ do |total, line|
+ @shopping_cart.total_for_line(line).should == total
end
Then /^I should see "([^\"]*)" in the cart total$/ do |total|
- @shopping_cart.cart_total.should == "$#{total}"
+ @shopping_cart.cart_total.should == total
end

0 comments on commit 2b0454f

Please sign in to comment.