Sha256: 2307c131fac0bf851df9df1c3af55120aa4e8589e02cc83dec61ab9781b97aa7

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

require 'spec_helper'

RSpec.describe Spree::AuctionsController, type: :controller do
  context '#index' do
    it 'lists auctions' do
      auctions = [
        create(:auction),
        create(:auction),
        create(:auction)
      ]
      get :index
      expect(assigns[:auctions]).to match_array auctions
    end

    it 'renders the index template' do
      get :index
      expect(response.status).to eq 200
      expect(response).to render_template :index
    end
  end

  context '#show' do
    let!(:auction) { create(:auction) }

    context 'for an auction that does not exist' do
      it 'responds with a 404' do
        expect {
          get :show, params: { id: 'not_real' }
        }.to raise_error ActiveRecord::RecordNotFound
      end
    end

    it 'assigns an auction instance variable' do
      get :show, params: { id: auction.id }
      expect(response.status).to eq 200
      expect(assigns[:auction]).to eq auction
    end

    it 'renders the show template' do
      get :show, params: { id: auction.id }
      expect(response.status).to eq 200
      expect(response).to render_template :show
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_auction-0.0.6 spec/controllers/auctions_controller_spec.rb
solidus_auction-0.0.5 spec/controllers/auctions_controller_spec.rb