Created
December 11, 2013 21:30
-
-
Save bryanaknight/7918800 to your computer and use it in GitHub Desktop.
Cart test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe "adding items and viewing cart" do | |
it "has unique cart for each restaurant" do | |
new_restaurant = FactoryGirl.create(:restaurant) | |
new_item = FactoryGirl.create(:item, restaurant_id: new_restaurant.id) | |
visit "/#{new_restaurant.slug}" | |
click_on('Add to Cart') | |
expect(page).to have_content("Bacon") | |
new_restaurant2 = FactoryGirl.create(:restaurant, title: "Parsley", description: "blah balh") | |
new_item2 = FactoryGirl.create(:item, restaurant_id: new_restaurant2.id, title: "brown fried food", description: "fried brown food") | |
visit "/#{new_restaurant2.slug}" | |
click_on('Add to Cart') | |
expect(page).to have_no_content("Bacon") | |
expect(page).to have_content("fried brown food") | |
end | |
it "cart holds unsubmitted order for current restaurant after visiting different restaurant" do | |
new_restaurant = FactoryGirl.create(:restaurant) | |
new_item = FactoryGirl.create(:item, restaurant_id: new_restaurant.id) | |
visit "/#{new_restaurant.slug}" | |
click_on('Add to Cart') | |
expect(page).to have_content("Bacon") | |
new_restaurant2 = FactoryGirl.create(:restaurant, title: "Parsley", description: "blah balh") | |
new_item2 = FactoryGirl.create(:item, restaurant_id: new_restaurant2.id, title: "brown fried food", description: "fried brown food") | |
visit "/#{new_restaurant2.slug}" | |
click_on('Add to Cart') | |
expect(page).to have_no_content("Bacon") | |
expect(page).to have_content("fried brown food") | |
visit '/' | |
visit "/#{new_restaurant.slug}" | |
click_on('View Items in Cart: 1') | |
expect(page).to have_content("Bacon") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment