Created
October 14, 2017 16:52
-
-
Save Epigene/e14e7a48aaa442763bf2098888ec56c1 to your computer and use it in GitHub Desktop.
#build_stubbed vs FactoryGirl strategies
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 "#instance_double VS FactoryGirl.build_stubbed, FactoryGirl.build, and FactoryGirl.create" do | |
subject { book.by_bce_autor? } | |
bout2_number_of = 200 | |
context "when setting up with #instance_double" do | |
let(:book) { build_stubbed(:book) } | |
let(:author) { instance_double("Author", bce?: true) } | |
before { allow(book).to receive(:author).and_return(author) } | |
bout2_number_of.times do | |
it { is_expected.to eq(true) } | |
end | |
end | |
context "when setting up with FactoryGirl.build_stubbed" do | |
let(:book) { build_stubbed(:book, :by_bce_author) } | |
bout2_number_of.times do | |
it { is_expected.to eq(true) } | |
end | |
end | |
context "when setting up with FactoryGirl.build" do | |
let(:book) { build(:book, :by_bce_author) } | |
bout2_number_of.times do | |
it { is_expected.to eq(true) } | |
end | |
end | |
context "when setting up with FactoryGirl.create" do | |
let(:book) { create(:book, :by_bce_author) } | |
bout2_number_of.times do | |
it { is_expected.to eq(true) } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment