From 334b8a944977d68dafaaf5871d9b3f2bec6553de Mon Sep 17 00:00:00 2001 From: Justin Ko Date: Wed, 12 Oct 2011 12:32:23 -0600 Subject: [PATCH] No more "should"'s in the example descriptions. Closes #216 --- spec/acceptance/syntax/blueprint_spec.rb | 4 +- spec/acceptance/syntax/generate_spec.rb | 18 +++---- spec/acceptance/syntax/make_spec.rb | 12 ++--- spec/acceptance/syntax/sham_spec.rb | 6 +-- spec/acceptance/syntax/vintage_spec.rb | 58 +++++++++++----------- spec/factory_girl/definition_proxy_spec.rb | 16 +++--- spec/factory_girl/factory_spec.rb | 26 +++++----- spec/factory_girl/find_definitions_spec.rb | 2 +- 8 files changed, 71 insertions(+), 71 deletions(-) diff --git a/spec/acceptance/syntax/blueprint_spec.rb b/spec/acceptance/syntax/blueprint_spec.rb index b5a4b744d..67a4263b9 100644 --- a/spec/acceptance/syntax/blueprint_spec.rb +++ b/spec/acceptance/syntax/blueprint_spec.rb @@ -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 diff --git a/spec/acceptance/syntax/generate_spec.rb b/spec/acceptance/syntax/generate_spec.rb index ec0c86563..565ccc973 100644 --- a/spec/acceptance/syntax/generate_spec.rb +++ b/spec/acceptance/syntax/generate_spec.rb @@ -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) @@ -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 diff --git a/spec/acceptance/syntax/make_spec.rb b/spec/acceptance/syntax/make_spec.rb index be868add5..38ac52947 100644 --- a/spec/acceptance/syntax/make_spec.rb +++ b/spec/acceptance/syntax/make_spec.rb @@ -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 @@ -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 diff --git a/spec/acceptance/syntax/sham_spec.rb b/spec/acceptance/syntax/sham_spec.rb index 4e8e055b1..95e6ce0fa 100644 --- a/spec/acceptance/syntax/sham_spec.rb +++ b/spec/acceptance/syntax/sham_spec.rb @@ -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 diff --git a/spec/acceptance/syntax/vintage_spec.rb b/spec/acceptance/syntax/vintage_spec.rb index f2da5972b..f2da9531e 100644 --- a/spec/acceptance/syntax/vintage_spec.rb +++ b/spec/acceptance/syntax/vintage_spec.rb @@ -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 @@ -65,13 +65,13 @@ 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 @@ -79,7 +79,7 @@ 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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/spec/factory_girl/definition_proxy_spec.rb b/spec/factory_girl/definition_proxy_spec.rb index 6e7bcb99f..cb8215f7f 100644 --- a/spec/factory_girl/definition_proxy_spec.rb +++ b/spec/factory_girl/definition_proxy_spec.rb @@ -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) @@ -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) @@ -25,16 +25,16 @@ 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]] @@ -42,13 +42,13 @@ 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") diff --git a/spec/factory_girl/factory_spec.rb b/spec/factory_girl/factory_spec.rb index 75bcaa8af..10e4a6631 100644 --- a/spec/factory_girl/factory_spec.rb +++ b/spec/factory_girl/factory_spec.rb @@ -8,7 +8,7 @@ FactoryGirl.register_factory(@factory) end - it "should have a factory name" do + it "has a factory name" do @factory.name.should == @name end @@ -16,11 +16,11 @@ @factory.factory_name.should == @name end - it "should have a build class" do + it "has a build class" do @factory.build_class.should == @class end - it "should have a default strategy" do + it "has a default strategy" do @factory.default_strategy.should == :create end @@ -36,7 +36,7 @@ proxy.should have_received(:result).with(block) end - it "should return associations" do + it "returns associations" do factory = FactoryGirl::Factory.new(:post) FactoryGirl.register_factory(FactoryGirl::Factory.new(:admin)) factory.declare_attribute(FactoryGirl::Declaration::Association.new(:author, {})) @@ -48,7 +48,7 @@ factory.associations.size.should == 3 end - it "should raise for a self referencing association" do + it "raises for a self referencing association" do factory = FactoryGirl::Factory.new(:post) lambda { factory.declare_attribute(FactoryGirl::Declaration::Association.new(:parent, { :factory => :post })) @@ -63,20 +63,20 @@ @hash = { @name => @value } end - it "should return the overridden value in the generated attributes" do + it "returns the overridden value in the generated attributes" do declaration = FactoryGirl::Declaration::Static.new(@name, 'The price is wrong, Bob!') @factory.declare_attribute(declaration) result = @factory.run(FactoryGirl::Proxy::AttributesFor, @hash) result[@name].should == @value end - it "should not call a lazy attribute block for an overridden attribute" do + it "does not call a lazy attribute block for an overridden attribute" do declaration = FactoryGirl::Declaration::Dynamic.new(@name, lambda { flunk }) @factory.declare_attribute(declaration) result = @factory.run(FactoryGirl::Proxy::AttributesFor, @hash) end - it "should override a symbol parameter with a string parameter" do + it "overrides a symbol parameter with a string parameter" do declaration = FactoryGirl::Declaration::Static.new(@name, 'The price is wrong, Bob!') @factory.declare_attribute(declaration) @hash = { @name.to_s => @value } @@ -93,26 +93,26 @@ :test_alias => 'new') end - it "should use the passed in value for the alias" do + it "uses the passed in value for the alias" do @result[:test_alias].should == 'new' end - it "should discard the predefined value for the attribute" do + it "discards the predefined value for the attribute" do @result[:test].should be_nil end end - it "should guess the build class from the factory name" do + it "guesses the build class from the factory name" do @factory.build_class.should == User end - it "should create a new factory using the class of the parent" do + it "creates a new factory using the class of the parent" do child = FactoryGirl::Factory.new(:child, :parent => @factory.name) child.ensure_compiled child.build_class.should == @factory.build_class end - it "should create a new factory while overriding the parent class" do + it "creates a new factory while overriding the parent class" do child = FactoryGirl::Factory.new(:child, :class => String, :parent => @factory.name) child.ensure_compiled child.build_class.should == String diff --git a/spec/factory_girl/find_definitions_spec.rb b/spec/factory_girl/find_definitions_spec.rb index ec2756941..2d1611b12 100644 --- a/spec/factory_girl/find_definitions_spec.rb +++ b/spec/factory_girl/find_definitions_spec.rb @@ -78,7 +78,7 @@ def self.in_directory_with_files(*files) describe "with several factories files under #{dir}/factories in non-alphabetical order" do in_directory_with_files File.join(dir, 'factories', 'b.rb'), File.join(dir, 'factories', 'a.rb') - it "should load the files in the right order" do + it "loads the files in the right order" do FactoryGirl.stubs(:load) sorted_load_order = sequence("load order") FactoryGirl.expects(:load).with(includes("a.rb")).in_sequence(sorted_load_order)