Created
September 15, 2014 17:33
-
-
Save kwstannard/82e557f9d6b11e86e510 to your computer and use it in GitHub Desktop.
Drying Factories
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
require 'spec_helper' | |
RSpec.describe YourRecord do | |
subject(:record) { create :your_record, *traits } | |
let(:traits) { [] } | |
its(:name) { is_expected.to be_nil } | |
its(:size) { is_expected.to eq(0) } | |
context "when name is bob" do | |
let(:traits) { super() << :named_bob } #[:named_bob] | |
its(:name) { is_expected.to eq('bob') } | |
its(:size) { is_expected.to eq(0) } | |
context "when the size is large" do | |
let(:traits) { super() << :large } #[:named_bob, :large] | |
its(:name) { is_expected.to eq('bob') } | |
its(:size) { is_expected.to be > 2 } | |
end | |
context "when the size is small" do | |
let(:traits) { super() << :small } #[:named_bob, :small] | |
its(:name) { is_expected.to eq('bob') } | |
its(:size) { is_expected.to be < 2 } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment