Last active
December 16, 2015 08:09
-
-
Save sevenseacat/5404252 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
describe GamesController do | |
describe 'POST "create"' do | |
subject(:response) { post :create, params } | |
context 'valid parameters provided' do | |
let(:params) { { game: FactoryGirl.attributes_for(:game) } } | |
specify { expect { subject }.to change(Game, :count).by 1 } | |
# This fails - assigns(:game) is nil so the route comes out like /games//score | |
it { should redirect_to score_game_path(assigns(:game)) } | |
# This passes - subject evaluated first? | |
it { subject.should redirect_to score_game_path(assigns(:game)) } | |
# This passes - named subject gets evaluated first too | |
it 'redirects to the newly created game' do | |
response.should redirect_to score_game_path(assigns(:game)) | |
end | |
it { should set_flash :notice } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment