Sha256: 8d745062145d279fcd444c1d6b9046edee02c6b51454e41e006f76b613ac2169

Contents?: true

Size: 949 Bytes

Versions: 2

Compression:

Stored size: 949 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

  it "should be ignorable" do
    @attr.ignore
    @attr.should be_ignored
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
factory_girl_kibiz0r-2.0.0.beta3 spec/factory_girl/attribute_spec.rb
factory_girl_kibiz0r-2.0.0.beta2 spec/factory_girl/attribute_spec.rb