Sha256: 29c08c5ed1c39b2db809f46305f6f835a9c68246f557c3f3d40a858a3c0474e2

Contents?: true

Size: 867 Bytes

Versions: 9

Compression:

Stored size: 867 Bytes

Contents

require 'spec_helper'

describe FactoryGirl::Attribute do
  before do
    @name  = :user
    @attr  = FactoryGirl::Attribute.new(@name)
  end

  it "should have a name" do
    @attr.name.should == @name
  end

  it "isn't an association" do
    @attr.should_not be_association
  end

  it "should do nothing when being added to a proxy" do
    @proxy = "proxy"
    stub(@proxy).set
    @attr.add_to(@proxy)
    @proxy.should have_received.set.never
  end

  it "should raise an error when defining an attribute writer" do
    error_message = %{factory_girl uses 'f.test value' syntax rather than 'f.test = value'}
    lambda {
      FactoryGirl::Attribute.new('test=')
    }.should raise_error(FactoryGirl::AttributeDefinitionError, error_message)
  end

  it "should convert names to symbols" do
    FactoryGirl::Attribute.new('name').name.should == :name
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
factory_girl-2.0.2 spec/factory_girl/attribute_spec.rb
factory_girl-2.0.1 spec/factory_girl/attribute_spec.rb
factory_girl-2.0.0.rc4 spec/factory_girl/attribute_spec.rb
factory_girl-2.0.0.rc3 spec/factory_girl/attribute_spec.rb
factory_girl-2.0.0.rc2 spec/factory_girl/attribute_spec.rb
factory_girl-2.0.0.rc1 spec/factory_girl/attribute_spec.rb
factory_girl-2.0.0.beta5 spec/factory_girl/attribute_spec.rb
factory_girl-2.0.0.beta4 spec/factory_girl/attribute_spec.rb
factory_girl-2.0.0.beta3 spec/factory_girl/attribute_spec.rb