Module: Spree::Storefront::TestingSupport::CartUtils

Defined in:
lib/spree/storefront/testing_support/cart_utils.rb

Instance Method Summary collapse

Instance Method Details

#add_to_cart(product, goto_checkout = false) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/spree/storefront/testing_support/cart_utils.rb', line 5

def add_to_cart(product, goto_checkout = false)
  visit spree.product_path(product)

  click_button Spree.t(:add_to_cart)
  wait_for_turbo
  expect(page).to have_link('Checkout')

  def view_cart
    visit spree.cart_path
  end

  def click_checkout
    click_link 'Checkout'
    expect(page).to have_content('Contact information').and have_content('Shipping Address')
  end

  if block_given?
    yield
  else
    goto_checkout ? click_checkout : view_cart
  end
end

#click_checkoutObject



16
17
18
19
# File 'lib/spree/storefront/testing_support/cart_utils.rb', line 16

def click_checkout
  click_link 'Checkout'
  expect(page).to have_content('Contact information').and have_content('Shipping Address')
end

#view_cartObject



12
13
14
# File 'lib/spree/storefront/testing_support/cart_utils.rb', line 12

def view_cart
  visit spree.cart_path
end