Skip to content

Commit

Permalink
No more "should"'s in the example descriptions.
Browse files Browse the repository at this point in the history
Closes #216
  • Loading branch information
justinko authored and joshuaclayton committed Oct 14, 2011
1 parent 9fcd0b6 commit 334b8a9
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 71 deletions.
4 changes: 2 additions & 2 deletions spec/acceptance/syntax/blueprint_spec.rb
Expand Up @@ -19,11 +19,11 @@
@instance = FactoryGirl.create(:user, :last_name => 'Rye')
end

it "should use attributes from the blueprint" do
it "uses attributes from the blueprint" do
@instance.first_name.should == 'Bill'
end

it "should evaluate attribute blocks for each instance" do
it "evaluates attribute blocks for each instance" do
@instance.email.should =~ /somebody\d+@example.com/
FactoryGirl.create(:user).email.should_not == @instance.email
end
Expand Down
18 changes: 9 additions & 9 deletions spec/acceptance/syntax/generate_spec.rb
Expand Up @@ -17,16 +17,16 @@
end
end

it "should not raise an error when generating an invalid instance" do
lambda { User.generate(:first_name => nil) }.should_not raise_error
it "does not raise an error when generating an invalid instance" do
expect { User.generate(:first_name => nil) }.to_not raise_error
end

it "should raise an error when forcefully generating an invalid instance" do
lambda { User.generate!(:first_name => nil) }.should raise_error(ActiveRecord::RecordInvalid)
it "raises an error when forcefully generating an invalid instance" do
expect { User.generate!(:first_name => nil) }.to raise_error(ActiveRecord::RecordInvalid)
end

%w(generate generate! spawn).each do |method|
it "should yield a generated instance when using #{method} with a block" do
it "yields a generated instance when using #{method} with a block" do
saved_instance = nil
User.send(method) {|instance| saved_instance = instance }
saved_instance.should be_kind_of(User)
Expand All @@ -37,20 +37,20 @@
@instance = User.send(method, :last_name => 'Rye')
end

it "should use attributes from the factory" do
it "uses attributes from the factory" do
@instance.first_name.should == 'Bill'
end

it "should use attributes passed to generate" do
it "uses attributes passed to generate" do
@instance.last_name.should == 'Rye'
end

if method == 'spawn'
it "should not save the record" do
it "does not save the record" do
@instance.should be_new_record
end
else
it "should save the record" do
it "does save the record" do
@instance.should_not be_new_record
end
end
Expand Down
12 changes: 6 additions & 6 deletions spec/acceptance/syntax/make_spec.rb
Expand Up @@ -19,15 +19,15 @@
@instance = User.make(:last_name => 'Rye')
end

it "should use attributes from the factory" do
it "uses attributes from the factory" do
@instance.first_name.should == 'Bill'
end

it "should use attributes passed to make" do
it "uses attributes passed to make" do
@instance.last_name.should == 'Rye'
end

it "should build the record" do
it "builds the record" do
@instance.should be_new_record
end
end
Expand All @@ -37,15 +37,15 @@
@instance = User.make!(:last_name => 'Rye')
end

it "should use attributes from the factory" do
it "uses attributes from the factory" do
@instance.first_name.should == 'Bill'
end

it "should use attributes passed to make" do
it "uses attributes passed to make" do
@instance.last_name.should == 'Rye'
end

it "should save the record" do
it "saves the record" do
@instance.should_not be_new_record
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/acceptance/syntax/sham_spec.rb
Expand Up @@ -28,15 +28,15 @@
@instance = FactoryGirl.create(:user, :last_name => 'Rye')
end

it "should support a sham called 'name'" do
it "supports a sham called 'name'" do
@instance.first_name.should == 'Name'
end

it "should support shams with starting values" do
it "supports shams with starting values" do
@instance.username.should == 'User-FOO'
end

it "should use the sham for the email" do
it "uses the sham for the email" do
@instance.email.should =~ /somebody\d@example.com/
end
end
Expand Down
58 changes: 29 additions & 29 deletions spec/acceptance/syntax/vintage_spec.rb
Expand Up @@ -29,29 +29,29 @@
end
end

it "should raise an ArgumentError when trying to use a non-existent strategy" do
lambda {
it "raises an ArgumentError when trying to use a non-existent strategy" do
expect {
Factory.define(:object, :default_strategy => :nonexistent) {}
}.should raise_error(ArgumentError)
}.to raise_error(ArgumentError)
end

it "should raise Factory::SequenceAbuseError" do
it "raises Factory::SequenceAbuseError" do
Factory.define :sequence_abuser, :class => User do |factory|
factory.first_name { Factory.sequence(:name) }
end

lambda {
expect {
Factory(:sequence_abuser)
}.should raise_error(FactoryGirl::SequenceAbuseError)
}.to raise_error(FactoryGirl::SequenceAbuseError)
end
end

describe Factory, "referencing a nonexistent factory as a parent" do
it "should raise an ArgumentError when trying to use a non-existent factory as parent" do
lambda {
it "raises an ArgumentError when trying to use a non-existent factory as parent" do
expect {
Factory.define(:child, :parent => :nonexsitent) {}
Factory.build(:child)
}.should raise_error(ArgumentError)
}.to raise_error(ArgumentError)
end
end

Expand All @@ -65,21 +65,21 @@
FactoryGirl::DefinitionProxy.stubs(:new => @proxy)
end

it "should create a new factory using the specified name and options" do
it "creates a new factory using the specified name and options" do
FactoryGirl::Factory.stubs(:new => @factory)
Factory.define(@name, @options) {|f| }
FactoryGirl::Factory.should have_received(:new).with(@name, @options)
end

it "should pass the factory do the block" do
it "passes the factory do the block" do
yielded = nil
Factory.define(@name) do |y|
yielded = y
end
yielded.should == @proxy
end

it "should add the factory to the list of factories" do
it "adds the factory to the list of factories" do
Factory.define(@name) {|f| }
@factory.should == FactoryGirl.factory_by_name(@name)
end
Expand All @@ -93,48 +93,48 @@
FactoryGirl.register_factory(@factory)
end

it "should use Proxy::AttributesFor for Factory.attributes_for" do
it "uses Proxy::AttributesFor for Factory.attributes_for" do
@factory.stubs(:run => "result")
Factory.attributes_for(@name, :attr => 'value').should == 'result'
@factory.should have_received(:run).with(FactoryGirl::Proxy::AttributesFor, :attr => 'value')
end

it "should use Proxy::Build for Factory.build" do
it "uses Proxy::Build for Factory.build" do
@factory.stubs(:run => "result")
Factory.build(@name, :attr => 'value').should == 'result'
@factory.should have_received(:run).with(FactoryGirl::Proxy::Build, :attr => 'value')
end

it "should use Proxy::Create for Factory.create" do
it "uses Proxy::Create for Factory.create" do
@factory.stubs(:run => "result")
Factory.create(@name, :attr => 'value').should == 'result'
@factory.should have_received(:run).with(FactoryGirl::Proxy::Create, :attr => 'value')
end

it "should use Proxy::Stub for Factory.stub" do
it "uses Proxy::Stub for Factory.stub" do
@factory.stubs(:run => "result")
Factory.stub(@name, :attr => 'value').should == 'result'
@factory.should have_received(:run).with(FactoryGirl::Proxy::Stub, :attr => 'value')
end

it "should use default strategy option as Factory.default_strategy" do
it "uses default strategy option as Factory.default_strategy" do
@factory.stubs(:default_strategy => :create, :run => "result")
Factory.default_strategy(@name, :attr => 'value').should == 'result'
@factory.should have_received(:run).with(FactoryGirl::Proxy::Create, :attr => 'value')
end

it "should use the default strategy for the global Factory method" do
it "uses the default strategy for the global Factory method" do
@factory.stubs(:default_strategy => :create, :run => "result")
Factory(@name, :attr => 'value').should == 'result'
@factory.should have_received(:run).with(FactoryGirl::Proxy::Create, :attr => 'value')
end

[:build, :create, :attributes_for, :stub].each do |method|
it "should raise an ArgumentError on #{method} with a nonexistent factory" do
lambda { Factory.send(method, :bogus) }.should raise_error(ArgumentError)
it "raises an ArgumentError on #{method} with a nonexistent factory" do
expect { Factory.send(method, :bogus) }.to raise_error(ArgumentError)
end

it "should recognize either 'name' or :name for Factory.#{method}" do
it "recognizes either 'name' or :name for Factory.#{method}" do
@factory.stubs(:run)
lambda { Factory.send(method, @name.to_s) }.should_not raise_error
lambda { Factory.send(method, @name.to_sym) }.should_not raise_error
Expand All @@ -147,17 +147,17 @@
@name = :count
end

it "should create a new sequence" do
it "creates a new sequence" do
Factory.sequence(@name)
Factory.next(@name).should == 1
end

it "should use the supplied block as the sequence generator" do
it "uses the supplied block as the sequence generator" do
Factory.sequence(@name) {|n| "user-#{n}" }
Factory.next(@name).should == "user-1"
end

it "should use the supplied start_value as the sequence start_value" do
it "uses the supplied start_value as the sequence start_value" do
Factory.sequence(@name, "A")
Factory.next(@name).should == "A"
end
Expand All @@ -175,12 +175,12 @@
Factory.sequence(@name) {}
end

it "should call next on the sequence when sent next" do
it "calls next on the sequence when sent next" do
Factory.next(@name)
@sequence.should have_received(:next)
end

it "should return the value from the sequence" do
it "returns the value from the sequence" do
Factory.next(@name).should == @value
end
end
Expand All @@ -196,7 +196,7 @@
@username = Factory.attributes_for(:user)[:username]
end

it "should match the correct format" do
it "matches the correct format" do
@username.should =~ /^username\d+$/
end

Expand All @@ -205,11 +205,11 @@
@another_username = Factory.attributes_for(:user)[:username]
end

it "should match the correct format" do
it "matches the correct format" do
@username.should =~ /^username\d+$/
end

it "should not be the same as the first generated value" do
it "is not the same as the first generated value" do
@another_username.should_not == @username
end
end
Expand Down
16 changes: 8 additions & 8 deletions spec/factory_girl/definition_proxy_spec.rb
Expand Up @@ -4,7 +4,7 @@
let(:factory) { FactoryGirl::Factory.new(:object) }
subject { FactoryGirl::DefinitionProxy.new(factory) }

it "should add a static attribute when an attribute is defined with a value" do
it "adds a static attribute when an attribute is defined with a value" do
attribute = stub('attribute', :name => :name)
FactoryGirl::Attribute::Static.stubs(:new => attribute)
factory.stubs(:define_attribute)
Expand All @@ -14,7 +14,7 @@
FactoryGirl::Attribute::Static.should have_received(:new).with(:name, "value", false)
end

it "should add a dynamic attribute when an attribute is defined with a block" do
it "adds a dynamic attribute when an attribute is defined with a block" do
attribute = stub('attribute', :name => :name)
block = lambda {}
FactoryGirl::Attribute::Dynamic.stubs(:new => attribute)
Expand All @@ -25,30 +25,30 @@
factory.should have_received(:define_attribute).with(attribute)
end

it "should raise for an attribute with a value and a block" do
lambda {
it "raises for an attribute with a value and a block" do
expect {
subject.add_attribute(:name, 'value') {}
}.should raise_error(FactoryGirl::AttributeDefinitionError)
}.to raise_error(FactoryGirl::AttributeDefinitionError)
end

describe "child factories" do
its(:child_factories) { should == [] }

it "should be able to add child factories" do
it "is be able to add child factories" do
block = lambda {}
subject.factory(:admin, { :aliases => [:great] }, &block)
subject.child_factories.should == [[:admin, { :aliases => [:great] }, block]]
end
end

describe "adding an attribute using a in-line sequence" do
it "should create the sequence" do
it "creates the sequence" do
FactoryGirl::Sequence.stubs(:new)
subject.sequence(:name) {}
FactoryGirl::Sequence.should have_received(:new).with(:name, 1)
end

it "should create the sequence with a custom default value" do
it "creates the sequence with a custom default value" do
FactoryGirl::Sequence.stubs(:new)
subject.sequence(:name, "A") {}
FactoryGirl::Sequence.should have_received(:new).with(:name, "A")
Expand Down

0 comments on commit 334b8a9

Please sign in to comment.