Sha256: 3940e0cd42ea293c9ed392e3f245b19e93b5f217710e4e757566bdb067ce8ef3

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

describe FactoryGirl::Proxy::Build do
  let(:instance)    { stub("built-instance") }
  let(:proxy_class) { stub("class", :new => instance) }

  subject { FactoryGirl::Proxy::Build.new(proxy_class) }

  it_should_behave_like "proxy with association support", FactoryGirl::Proxy::Create
  it_should_behave_like "proxy with standard getters and setters", :attribute_name, "attribute value!"
  it_should_behave_like "proxy with callbacks", :after_build
  it_should_behave_like "proxy with :method => :build",
    FactoryGirl::Proxy::Build

  describe "specifying method" do
    it "defaults to create" do
      subject.send(:get_method, nil).should == FactoryGirl::Proxy::Create
    end

    it "can specify create explicitly" do
      subject.send(:get_method, :create).should ==
        FactoryGirl::Proxy::Create
    end

    it "can specify build explicitly" do
      subject.send(:get_method, :build).should ==
        FactoryGirl::Proxy::Build
    end

    it "complains if method is unrecognized" do
      lambda { subject.send(:get_method, :froboznicate) }.
        should raise_error("unrecognized method froboznicate")
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
factory_girl-2.2.0 spec/factory_girl/proxy/build_spec.rb
factory_girl-2.1.2 spec/factory_girl/proxy/build_spec.rb
factory_girl-2.1.0 spec/factory_girl/proxy/build_spec.rb