Sha256: 64edbc7db80d2d73d2f87a0c152e58ffa5853cecaf174f51e40e4a46932da434

Contents?: true

Size: 953 Bytes

Versions: 3

Compression:

Stored size: 953 Bytes

Contents

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 "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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
factory_girl-2.1.2 spec/factory_girl/attribute_spec.rb
factory_girl-2.1.0 spec/factory_girl/attribute_spec.rb
factory_girl-2.0.5 spec/factory_girl/attribute_spec.rb