From 4bf87167866f22a7516fa59bc4ed9ceda369f49f Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Wed, 7 Jan 2015 16:29:15 +1100 Subject: [PATCH] Extract complete_checkout to method --- .../shopping/variant_overrides_spec.rb | 70 +++++++++++-------- 1 file changed, 40 insertions(+), 30 deletions(-) diff --git a/spec/features/consumer/shopping/variant_overrides_spec.rb b/spec/features/consumer/shopping/variant_overrides_spec.rb index abe11de532..4b73d0b4df 100644 --- a/spec/features/consumer/shopping/variant_overrides_spec.rb +++ b/spec/features/consumer/shopping/variant_overrides_spec.rb @@ -98,37 +98,8 @@ feature "shopping with variant overrides defined", js: true do wait_until_enabled 'li.cart a.button' click_link 'Quick checkout' - checkout_as_guest + complete_checkout - within "#details" do - fill_in "First Name", with: "Some" - fill_in "Last Name", with: "One" - fill_in "Email", with: "test@example.com" - fill_in "Phone", with: "0456789012" - end - - toggle_billing - within "#billing" do - fill_in "Address", with: "123 Street" - select "Australia", from: "Country" - select "Victoria", from: "State" - fill_in "City", with: "Melbourne" - fill_in "Postcode", with: "3066" - end - - toggle_shipping - within "#shipping" do - choose sm.name - end - - toggle_payment - within "#payment" do - choose pm.name - end - - ActionMailer::Base.deliveries.length.should == 0 - place_order - page.should have_content "Your order has been processed successfully" ActionMailer::Base.deliveries.length.should == 2 email = ActionMailer::Base.deliveries.last @@ -142,4 +113,43 @@ feature "shopping with variant overrides defined", js: true do it "subtracts stock from the override" end + + + private + + def complete_checkout + checkout_as_guest + + within "#details" do + fill_in "First Name", with: "Some" + fill_in "Last Name", with: "One" + fill_in "Email", with: "test@example.com" + fill_in "Phone", with: "0456789012" + end + + toggle_billing + within "#billing" do + fill_in "Address", with: "123 Street" + select "Australia", from: "Country" + select "Victoria", from: "State" + fill_in "City", with: "Melbourne" + fill_in "Postcode", with: "3066" + end + + toggle_shipping + within "#shipping" do + choose sm.name + end + + toggle_payment + within "#payment" do + choose pm.name + end + + place_order + #sleep 5 + using_wait_time 10 do + page.should have_content "Your order has been processed successfully" + end + end end