Created
April 10, 2012 13:43
-
-
Save jgaskins/2351463 to your computer and use it in GitHub Desktop.
Keep your specs from needlessly hitting the database
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
describe ThingsController do | |
describe '#create' do | |
let(:thing_data) { { name: 'Name' } } | |
it 'creates a new Thing and hits the DB 3x' do | |
expect { post :create, thing: thing_data }.to change { Thing.count }.by 1 | |
# other response-related expectations here | |
end | |
it 'creates a new Thing and hits the DB once' do | |
post :create, thing: thing_data | |
assigns(:thing).should be_persisted | |
# other response-related expectations here | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment