Sha256: c8ffc500dcfab1ef2cd673af5b90b1e24bf0651c81ecb573919d468f280033c9

Contents?: true

Size: 998 Bytes

Versions: 11

Compression:

Stored size: 998 Bytes

Contents

require 'spec_helper'
require 'acceptance/acceptance_helper'

describe "build multiple instances" do
  before do
    define_model('Post', :title => :string)

    FactoryGirl.define do
      factory(:post) do |post|
        post.title "Through the Looking Glass"
      end
    end
  end

  context "without default attributes" do
    subject { FactoryGirl.build_list(:post, 20) }

    its(:length) { should == 20 }

    it "builds (but doesn't save) all the posts" do
      subject.each do |record|
        record.should be_new_record
      end
    end

    it "uses the default factory values" do
      subject.each do |record|
        record.title.should == "Through the Looking Glass"
      end
    end
  end

  context "with default attributes" do
    subject { FactoryGirl.build_list(:post, 20, :title => "The Hunting of the Snark") }

    it "overrides the default values" do
      subject.each do |record|
        record.title.should == "The Hunting of the Snark"
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
factory_girl-2.0.4 spec/acceptance/build_list_spec.rb
factory_girl-2.0.3 spec/acceptance/build_list_spec.rb
factory_girl-2.0.2 spec/acceptance/build_list_spec.rb
factory_girl-2.0.1 spec/acceptance/build_list_spec.rb
factory_girl-2.0.0.rc4 spec/acceptance/build_list_spec.rb
factory_girl-2.0.0.rc3 spec/acceptance/build_list_spec.rb
factory_girl-2.0.0.rc2 spec/acceptance/build_list_spec.rb
factory_girl-2.0.0.rc1 spec/acceptance/build_list_spec.rb
factory_girl-2.0.0.beta5 spec/acceptance/build_list_spec.rb
factory_girl-2.0.0.beta4 spec/acceptance/build_list_spec.rb
factory_girl-2.0.0.beta3 spec/acceptance/build_list_spec.rb