Sha256: 08fbebb36491c923db25561a6f776b05ce2f82f91e1951ef16cb1e7740af1ed0

Contents?: true

Size: 719 Bytes

Versions: 4

Compression:

Stored size: 719 Bytes

Contents

require 'spec_helper'

describe BookStoreController do
  let(:book) { FactoryGirl.create(:book) }
  let(:user) { FactoryGirl.create(:user) }

  describe 'GET show' do
    subject { get :show, :id => book.id }

    it { should be_ok }
  end

  describe 'POST purchase' do
    before do
      session[:user_id] = user.id
    end

    subject { post :purchase, :id => book.id }

    context 'when not purchased' do
      it { should be_created }

      it 'should added books' do
        post :purchase, :id => book.id
        user.reload.books.should include(book)
      end
    end

    context 'when purchased' do
      before do
        user.books << book
      end

      it { should be_forbidden }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dicer-0.3.0 examples/rails-3.2/spec/controllers/book_store_controller_spec.rb
dicer-0.2.0 examples/rails-3.2/spec/controllers/book_store_controller_spec.rb
dicer-0.1.0 examples/rails-3.2/spec/controllers/book_store_controller_spec.rb
dicer-0.0.1 examples/rails-3.2/spec/controllers/book_store_controller_spec.rb