spree_paypal_express/spec/requests/paypal_express_spec.rb

41 lines
1.3 KiB
Ruby
Raw Normal View History

2012-05-24 20:33:17 +00:00
require 'spec_helper'
2012-07-20 11:06:56 +00:00
describe "Paypal Express checkout" do
before do
2012-05-24 20:33:17 +00:00
FactoryGirl.create(:shipping_method, :zone => Spree::Zone.find_by_name('North America'))
FactoryGirl.create(:payment_method, :environment => 'test')
@product = FactoryGirl.create(:product, :name => "RoR Mug")
sign_in_as! FactoryGirl.create(:user)
2012-07-20 11:06:56 +00:00
FactoryGirl.create(:ppx)
2012-05-24 20:33:17 +00:00
end
let!(:address) { FactoryGirl.create(:address, :state => Spree::State.first) }
2012-07-20 11:06:56 +00:00
it "should display paypal link", :js => true do
2012-05-24 20:33:17 +00:00
visit spree.product_path(@product)
click_button "Add To Cart"
click_link "Checkout"
str_addr = "bill_address"
select "United States", :from => "order_#{str_addr}_attributes_country_id"
['firstname', 'lastname', 'address1', 'city', 'zipcode', 'phone'].each do |field|
fill_in "order_#{str_addr}_attributes_#{field}", :with => "#{address.send(field)}"
end
select "#{address.state.name}", :from => "order_#{str_addr}_attributes_state_id"
check "order_use_billing"
click_button "Save and Continue"
2012-07-20 10:23:01 +00:00
#delivery
click_button "Save and Continue"
2012-05-24 21:02:15 +00:00
choose "Paypal"
2012-07-20 10:23:01 +00:00
page.should have_selector('a#ppx')
2012-05-24 20:33:17 +00:00
click_button "Save and Continue"
2012-07-20 10:23:01 +00:00
current_path.should match /\A\/orders\/[A-Z][0-9]{9}\/checkout\/paypal_payment\z/
2012-05-24 20:33:17 +00:00
end
2012-07-20 10:23:01 +00:00
end