Skip to content

Instantly share code, notes, and snippets.

@Epigene
Created October 14, 2017 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Epigene/81249c5b6cac5d9d3e1aa72691ab704c to your computer and use it in GitHub Desktop.
Save Epigene/81249c5b6cac5d9d3e1aa72691ab704c to your computer and use it in GitHub Desktop.
#new VS all other setup strategies
describe "#new VS all others when testing Book#vampire_title?" do
subject { book.vampire_title? }
bout1_number_of = 200
context "when setting up with #new" do
bout1_number_of.times do
let(:book) { Book.new(title: "Vampire Literature, a Historical Perspective") }
it { is_expected.to eq(true) }
end
end
context "when setting up with #instance_double" do
let(:book) { instance_double("Book", vampire_title?: true) }
bout1_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, title: "Vampire Literature, a Historical Perspective") }
bout1_number_of.times do
it { is_expected.to eq(true) }
end
end
context "when setting up with FactoryGirl.build" do
let(:book) { build(:book, title: "Vampire Literature, a Historical Perspective") }
bout1_number_of.times do
it { is_expected.to eq(true) }
end
end
context "when setting up with FactoryGirl.create" do
let(:book) { create(:book, title: "Vampire Literature, a Historical Perspective") }
bout1_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