Created
June 23, 2016 12:36
-
-
Save urbanautomaton/c51e2537718b44e35f2274c09a03b9b4 to your computer and use it in GitHub Desktop.
actually, factory_girl is extremely good
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
RSpec.describe 'FactoryGirl.build_stubbed' do | |
let(:stubbed_model) { FactoryGirl.build_stubbed(:step_progress) } | |
it 'doesnt allow #save' do | |
expect { | |
stubbed_model.save | |
}.to raise_error RuntimeError, /stubbed models are not allowed to access the database/ | |
end | |
it 'doesnt allow #update_attributes' do | |
expect { | |
stubbed_model.update_attributes(created_at: Time.now) | |
}.to raise_error RuntimeError, /stubbed models are not allowed to access the database/ | |
end | |
it 'allows #save!' do | |
stubbed_model.save! | |
end | |
it 'allows #touch' do | |
stubbed_model.touch(:last_completed_at) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment