Sha256: 9b0318bc20bb3f026bfb45f4dd40ea99de69e061ca11d6313951d3ae01571680

Contents?: true

Size: 974 Bytes

Versions: 3

Compression:

Stored size: 974 Bytes

Contents

require 'spec_helper'

describe FactoryGirl::Attribute do
  let(:name)  { "user" }
  let(:proxy) { stub("proxy") }
  subject     { FactoryGirl::Attribute.new(name, false) }

  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=', false)
    }.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', false)
    (subject <=> second_attribute).should be_zero
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
factory_girl-2.3.1 spec/factory_girl/attribute_spec.rb
factory_girl-2.3.0 spec/factory_girl/attribute_spec.rb
factory_girl-2.2.0 spec/factory_girl/attribute_spec.rb