Permalink
Browse files

Fix books controller create action

- add missing `action` variable
- cleanup DB before starting tests
- use `BookRepository` to check if a record was created since calling
`action.book` won't work. `book` isn't an instance variable and isn't
exposed by the controller and doesn't have to be.
  • Loading branch information...
Bounga committed Jun 25, 2015
1 parent 53415d8 commit 0e7b5f91e4ffc9ee9ad66c3e7195469f58e07d80
Showing with 3 additions and 2 deletions.
  1. +3 −2 source/guides/getting-started.md
@@ -713,15 +713,16 @@ require 'spec_helper'
require_relative '../../../../apps/web/controllers/books/create'
describe Web::Controllers::Books::Create do
let(:action) { Web::Controllers::Books::Create.new }
let(:params) { Hash[book: { title: 'Confident Ruby', author: 'Avdi Grimm' }] }
after do
before do
BookRepository.clear
end
it 'creates a new book' do
action.call(params)
action.book.id.wont_be_nil
BookRepository.all.count.wont_equal 0
end
it 'redirects the user to the books listing' do

0 comments on commit 0e7b5f9

Please sign in to comment.