Sha256: f75882b69dee699fa7de02ab4715ed6b24b9a3abba3ace645bcfc1f4db0cf545

Contents?: true

Size: 650 Bytes

Versions: 7

Compression:

Stored size: 650 Bytes

Contents

require 'spec_helper'
require 'rack/mock'

describe PowerShop::Middleware::ShoppingCart do
  let(:app) do
    Rack::Builder.new do
      use PowerShop::Middleware::ShoppingCart
      run ->(env) { [200, {'Content-Type' => "text/html"}, ['Hello world!']] }
    end.to_app
  end

  let(:request) { Rack::MockRequest.new(app) }
  let(:session) { ActionController::TestSession.new }

  it 'creates shopping cart' do
    request.get(
      'http://www.myshop.com',
      'REQUEST_URI' => '/',
      'HTTP_HOST' => 'www.myshop.com',
      'rack.session' => session
    )

    expect(::ShoppingCart.exists?(session[:shopping_cart_id])).to eq true
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
power_shop-0.2.4 spec/lib/middleware/shopping_cart_spec.rb
power_shop-0.2.3 spec/lib/middleware/shopping_cart_spec.rb
power_shop-0.2.2 spec/lib/middleware/shopping_cart_spec.rb
power_shop-0.2.1 spec/lib/middleware/shopping_cart_spec.rb
power_shop-0.2.0 spec/lib/middleware/shopping_cart_spec.rb
power_shop-0.1.1 spec/lib/middleware/shopping_cart_spec.rb
power_shop-0.1.0 spec/lib/middleware/shopping_cart_spec.rb