Sha256: 4d632f0bc644fa39914aa4819ac09383118cb972d681b5e1d21ea9aeda5ba4e4

Contents?: true

Size: 1.35 KB

Versions: 26

Compression:

Stored size: 1.35 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper'))

describe Factory::Proxy::AttributesFor do
  before do
    @proxy = Factory::Proxy::AttributesFor.new(@class)
  end

  describe "when asked to associate with another factory" do
    before do
      stub(Factory).create
      @proxy.associate(:owner, :user, {})
    end

    it "should not set a value for the association" do
      (@proxy.result.key?(:owner)).should_not be
    end
  end

  it "should return nil when building an association" do
    @proxy.association(:user).should be_nil
  end

  it "should not call Factory.create when building an association" do
    stub(Factory).create
    @proxy.association(:user).should be_nil
    Factory.should have_received.create.never
  end

  it "should always return nil when building an association" do
    @proxy.set(:association, 'x')
    @proxy.association(:user).should be_nil
  end

  it "should return a hash when asked for the result" do
    @proxy.result.should be_kind_of(Hash)
  end

  describe "after setting an attribute" do
    before do
      @proxy.set(:attribute, 'value')
    end

    it "should set that value in the resulting hash" do
      @proxy.result[:attribute].should == 'value'
    end

    it "should return that value when asked for that attribute" do
      @proxy.get(:attribute).should == 'value'
    end
  end
end

Version data entries

26 entries across 26 versions & 14 rubygems

Version Path
BrettRasmussen-factory_girl-1.2.2 spec/factory_girl/proxy/attributes_for_spec.rb
BrettRasmussen-factory_girl-1.2.3 spec/factory_girl/proxy/attributes_for_spec.rb
agibralter-factory_girl-1.2.1 spec/factory_girl/proxy/attributes_for_spec.rb
lacomartincik-factory_girl-1.2.1.1 spec/factory_girl/proxy/attributes_for_spec.rb
qrush-factory_girl-1.2.1.1 spec/factory_girl/proxy/attributes_for_spec.rb
thoughtbot-factory_girl-1.2.2 spec/factory_girl/proxy/attributes_for_spec.rb
ttilley-factory_girl-1.2.2.1 spec/factory_girl/proxy/attributes_for_spec.rb
ttilley-factory_girl-1.2.2.2 spec/factory_girl/proxy/attributes_for_spec.rb
ttilley-factory_girl-1.2.2 spec/factory_girl/proxy/attributes_for_spec.rb
vitalish-factory_girl-1.2.10 spec/factory_girl/proxy/attributes_for_spec.rb
vitalish-factory_girl-1.2.9 spec/factory_girl/proxy/attributes_for_spec.rb
vitalish-factory_girl-1.2.8 spec/factory_girl/proxy/attributes_for_spec.rb
vitalish-factory_girl-1.2.7 spec/factory_girl/proxy/attributes_for_spec.rb
vitalish-factory_girl-1.2.6 spec/factory_girl/proxy/attributes_for_spec.rb
lockbox_middleware-1.2.1 vendor/gems/factory_girl-1.2.3/spec/factory_girl/proxy/attributes_for_spec.rb
malvestuto_factory_girl-1.2.5 spec/factory_girl/proxy/attributes_for_spec.rb
factory_girl-1.2.4 spec/factory_girl/proxy/attributes_for_spec.rb
jeffrafter-factory_girl-1.2.3 spec/factory_girl/proxy/attributes_for_spec.rb
masa-iwasaki-factory_girl-1.2.3.2 spec/factory_girl/proxy/attributes_for_spec.rb
masa-iwasaki-factory_girl-1.2.3.1 spec/factory_girl/proxy/attributes_for_spec.rb