Permalink
Browse files

checkpoint5

  • Loading branch information...
cheezy committed Nov 22, 2010
1 parent afdd3be commit 876129fb25a6b02960c97c384ebc674e10e142f5
@@ -2,6 +2,13 @@
class CheckoutPage
include WatirHelper
+ DEFAULT_DATA = {
+ 'name' => 'Cheezy',
+ 'address' => '123 Main Street',
+ 'email' => 'cheezy@example.com',
+ 'pay_type' => 'Check'
+ }
+
text_field(:name, :id => 'order_name')
text_field(:address, :id => 'order_address')
text_field(:email, :id => 'order_email')
@@ -11,4 +18,13 @@ class CheckoutPage
def initialize(browser)
@browser = browser
end
+
+ def complete_order(data={})
+ data = DEFAULT_DATA.merge(data)
+ self.name = data['name']
+ self.address = data['address']
+ self.email = data['email']
+ self.pay_type = data['pay_type']
+ place_order
+ end
end
@@ -50,3 +50,22 @@ Feature: Purchase Books
And I place my order
Then I should see "Thank you for your order"
+ Scenario: Our first high level scenario
+ When I purchase "Pragmatic Unit Testing (C#)"
+ And I checkout with
+ | name | address | email | pay_type |
+ | Cheezy | 123 Main Street | cheezy@example.com | Credit card |
+ Then I should see "Thank you for your order"
+
+ Scenario: Using some default data
+ When I purchase a book
+ And I checkout with
+ | pay_type |
+ | Credit card |
+ Then I should see "Thank you for your order"
+
+ Scenario: Using all default data
+ When I purchase a book
+ And I complete the order
+ Then I should see "Thank you for your order"
+
@@ -59,3 +59,17 @@
Then /^I should see "([^\"]*)"$/ do |expected_text|
@catalog.content.should include expected_text
end
+
+And /^I checkout with$/ do |table|
+ @checkout_page = @shopping_cart.goto_checkout_page
+ @checkout_page.complete_order(table.hashes.first)
+end
+
+When /^I purchase a book$/ do
+ @shopping_cart = @catalog.add_book_to_shopping_cart('Pragmatic Version Control')
+end
+
+And /^I complete the order$/ do
+ @checkout_page = @shopping_cart.goto_checkout_page
+ @checkout_page.complete_order
+end

0 comments on commit 876129f

Please sign in to comment.