1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/spec/factory_girl/attribute/static_spec.rb
Joshua Clayton 554e6ab378 rr => mocha
2011-08-13 00:12:47 -04:00

29 lines
769 B
Ruby

require 'spec_helper'
describe FactoryGirl::Attribute::Static do
before do
@name = :first_name
@value = 'John'
@attr = FactoryGirl::Attribute::Static.new(@name, @value)
end
it "should have a name" do
@attr.name.should == @name
end
it "should set its static value on a proxy" do
@proxy = stub("proxy", :set => nil)
@attr.add_to(@proxy)
@proxy.should have_received(:set).with(@name, @value)
end
it "should raise an error when defining an attribute writer" do
lambda {
FactoryGirl::Attribute::Static.new('test=', nil)
}.should raise_error(FactoryGirl::AttributeDefinitionError)
end
it "should convert names to symbols" do
FactoryGirl::Attribute::Static.new('name', nil).name.should == :name
end
end