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_spec.rb
2011-09-03 00:25:26 -04:00

33 lines
985 B
Ruby

require 'spec_helper'
describe FactoryGirl::Attribute do
let(:name) { "user" }
let(:proxy) { stub("proxy") }
subject { FactoryGirl::Attribute.new(name) }
its(:name) { should == name.to_sym }
it { should_not be_association }
it { should_not be_callback }
it "doesn't set any attributes on a proxy when added" do
proxy.stubs(:set)
subject.add_to(proxy)
proxy.should have_received(:set).never
end
it "raises an error when defining an attribute writer" do
error_message = %{factory_girl uses 'f.test value' syntax rather than 'f.test = value'}
expect {
FactoryGirl::Attribute.new('test=')
}.to raise_error(FactoryGirl::AttributeDefinitionError, error_message)
end
it "returns nil when compared to a non-attribute" do
(subject <=> "foo").should be_nil
end
it "uses priority to perform comparisons" do
second_attribute = FactoryGirl::Attribute.new('name')
(subject <=> second_attribute).should be_zero
end
end