mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
Stub out ActiveRecord::Base#persisted?
This commit is contained in:
parent
5312fad41d
commit
168bbf8e34
2 changed files with 5 additions and 2 deletions
|
@ -10,7 +10,6 @@ module FactoryGirl
|
|||
:delete,
|
||||
:destroy!,
|
||||
:destroy,
|
||||
:destroyed?,
|
||||
:increment!,
|
||||
:increment,
|
||||
:reload,
|
||||
|
@ -58,6 +57,10 @@ module FactoryGirl
|
|||
id.nil?
|
||||
end
|
||||
|
||||
def destroyed?
|
||||
nil
|
||||
end
|
||||
|
||||
DISABLED_PERSISTENCE_METHODS.each do |write_method|
|
||||
define_singleton_method(write_method) do |*args|
|
||||
raise "stubbed models are not allowed to access the database - #{self.class}##{write_method}(#{args.join(",")})"
|
||||
|
|
|
@ -36,6 +36,7 @@ describe FactoryGirl::Strategy::Stub do
|
|||
|
||||
it { expect(subject.result(evaluation)).not_to be_new_record }
|
||||
it { expect(subject.result(evaluation)).to be_persisted }
|
||||
it { expect(subject.result(evaluation)).not_to be_destroyed }
|
||||
|
||||
it "assigns created_at" do
|
||||
created_at = subject.result(evaluation).created_at
|
||||
|
@ -52,7 +53,6 @@ describe FactoryGirl::Strategy::Stub do
|
|||
include_examples "disabled persistence method", :delete
|
||||
include_examples "disabled persistence method", :destroy
|
||||
include_examples "disabled persistence method", :destroy!
|
||||
include_examples "disabled persistence method", :destroyed?
|
||||
include_examples "disabled persistence method", :increment
|
||||
include_examples "disabled persistence method", :increment!
|
||||
include_examples "disabled persistence method", :reload
|
||||
|
|
Loading…
Reference in a new issue