Sha256: 90973eb51ad2e24871e3ad37821b41fa3093b604df2107a5e69510b8fe20adf3
Contents?: true
Size: 1.88 KB
Versions: 2
Compression:
Stored size: 1.88 KB
Contents
require 'spec_helper' describe "Cart", type: :feature, js: true do let!(:mug) { create(:product, name: "RoR Mug", price: 10.95) } before do mug.master.stock_items.update_all(count_on_hand: 10) end scenario "shows cart icon on non-cart pages" do visit sprangular_engine.root_path expect(page).to have_selector("a.cart-link", visible: true) end scenario "should increment counter when product added to cart" do visit sprangular_engine.root_path(anchor: "!/products/#{mug.slug}") expect(page).to have_css("a.cart-link .cart-qty", visible: false) expect(page).to have_content("RoR Mug") expect(page).to have_content("$10.95") page.find(:css, '.add-to-cart').click expect(page).to have_css("a.cart-link .cart-qty", text: "1") end scenario 'allows you to remove an item from the cart' do visit sprangular_engine.root_path(anchor: "!/products/#{mug.slug}") page.find(:css, '.add-to-cart').click page.find(:css, '.cart-link').click page.find(:css, '#cart-aside .remove').click expect(page).to have_content("Your cart is empty") end scenario 'allows you to update quantity of items in cart' do visit sprangular_engine.root_path(anchor: "!/products/#{mug.slug}") page.find(:css, '.add-to-cart').click page.find(:css, '.cart-link').click within :css, "#cart-aside tr.item .quantity-input" do page.find(:css, 'a.plus').click end expect(page).to have_css("a.cart-link .cart-qty", text: "2") end scenario 'allows you to empty the cart' do visit sprangular_engine.root_path(anchor: "!/products/#{mug.slug}") page.find(:css, '.add-to-cart').click page.find(:css, '.cart-link').click within :css, "#cart-aside" do page.find(:css, 'a.empty').click end expect(page).to have_content("Your cart is empty") expect(page).to have_css("a.cart-link .cart-qty", visible: false) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sprangular-0.1.0 | spec/features/cart_spec.rb |
sprangular-0.0.1 | spec/features/cart_spec.rb |