Skip to content

Instantly share code, notes, and snippets.

@dkarter
Last active June 14, 2016 16:50
Show Gist options
  • Save dkarter/c25d75395bc7c49d424740e00427ba30 to your computer and use it in GitHub Desktop.
Save dkarter/c25d75395bc7c49d424740e00427ba30 to your computer and use it in GitHub Desktop.
module Pages
class Checkout
include Capybara::DSL
def visit
visit checkout_path
end
def change_payment_method(payment_method)
if payment_method == :credit_card
select "Credit Card", from: '.payment_method'
end
# ...
end
end
feature 'Purchasing products' do
scenario "Customer checks out with valid credit card" do
# ... setup
checkout_page = Pages::Checkout.new
checkout_page.visit
checkout_page.change_payment_method(:credit_card)
checkout_page.set_credit_card(number: "4111111111111111", exp: "10/20", cvv: 123)
checkout_page.choose_delivery_option(:free_two_day)
checkout_page.click_place_order
checkout_confirmation_page = Pages::CheckoutConfirmation.new
expect(checkout_confirmation_page).to be_on_page
expect(checkout_confirmation_page).to have_product("Boosted Longboard")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment