2010-06-10 13:37:51 -04:00
|
|
|
require 'spec_helper'
|
2009-04-11 11:27:23 -04:00
|
|
|
|
2010-06-24 09:45:57 -04:00
|
|
|
describe FactoryGirl::Attribute::Static do
|
2009-04-11 11:27:23 -04:00
|
|
|
before do
|
|
|
|
@name = :first_name
|
|
|
|
@value = 'John'
|
2010-06-24 09:45:57 -04:00
|
|
|
@attr = FactoryGirl::Attribute::Static.new(@name, @value)
|
2009-04-11 11:27:23 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should have a name" do
|
|
|
|
@attr.name.should == @name
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should set its static value on a proxy" do
|
2011-08-12 22:06:10 -04:00
|
|
|
@proxy = stub("proxy", :set => nil)
|
2009-04-11 11:27:23 -04:00
|
|
|
@attr.add_to(@proxy)
|
2011-08-12 22:06:10 -04:00
|
|
|
@proxy.should have_received(:set).with(@name, @value)
|
2009-04-11 11:27:23 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should raise an error when defining an attribute writer" do
|
|
|
|
lambda {
|
2010-06-24 09:45:57 -04:00
|
|
|
FactoryGirl::Attribute::Static.new('test=', nil)
|
|
|
|
}.should raise_error(FactoryGirl::AttributeDefinitionError)
|
2009-04-11 11:27:23 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should convert names to symbols" do
|
2010-06-24 09:45:57 -04:00
|
|
|
FactoryGirl::Attribute::Static.new('name', nil).name.should == :name
|
2009-04-11 11:27:23 -04:00
|
|
|
end
|
|
|
|
end
|