Skip to content

Instantly share code, notes, and snippets.

@braidn
Created July 24, 2013 23:28
Show Gist options
  • Save braidn/6075586 to your computer and use it in GitHub Desktop.
Save braidn/6075586 to your computer and use it in GitHub Desktop.
weird state AR Template error in spree 1.3.3 extension
def add_to_cart(name, variant=nil)
visit spree.root_path
click_link name
choose variant if variant
click_button 'add-to-cart-button'
end
def user_login(user)
fill_in 'spree_user_email', :with => user.email
fill_in 'spree_user_password', :with => 'secret'
click_button 'Login'
end
def init_checkout
visit spree.cart_path
click_on "Checkout"
user_login(user)
end
def fill_out_address
address = FactoryGirl.attributes_for(:address)
within('#billing') do
fill_in 'First Name', :with => address['firstname']
fill_in 'Last Name', :with => address['lastname']
fill_in 'Address', :with => address['address1']
fill_in 'order_bill_address_attributes_state_name', :with => address['state_name']
fill_in 'Zip', :with => address['zip']
select FactoryGirl.attributes_for(:contry)[:name], :for => 'Country'
fill_in 'Phone', :with => address['phone']
end
within('#shipping') do
check('Use Billing Address')
end
end
require 'spec_helper'
feature 'Checkbox on checkout to save cc', %q{
As a user
I want to see a checkbox to save my cc info
When I imput my cc number for checkout
} do
let (:user) { create(:user) }
background do
@product = create(:product, name: 'awesome-sauce')
add_to_cart(@product.name)
end
scenario 'I want to add a credit card to my account' do
init_checkout
fill_out_address
click_button 'Save and Continue'
page.should have_content 'Save Credit Card'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment