Sha256: 77c8fefe114c848d3c738e38db89a7a6b8b79c04ded73edb546a5f6f92dfaa8e

Contents?: true

Size: 948 Bytes

Versions: 29

Compression:

Stored size: 948 Bytes

Contents

require 'spec_helper'

describe "create 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.create_list(:post, 20) }

    its(:length) { should == 20 }

    it "creates all the posts" do
      subject.each do |record|
        record.should_not 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.create_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

29 entries across 29 versions & 2 rubygems

Version Path
challah-0.6.1 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/create_list_spec.rb
challah-0.6.0 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/create_list_spec.rb
challah-0.5.4 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/create_list_spec.rb
challah-0.5.3 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/create_list_spec.rb
challah-0.5.2 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/create_list_spec.rb
challah-0.5.0 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/create_list_spec.rb
factory_girl-2.5.2 spec/acceptance/create_list_spec.rb
challah-0.4.1 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/create_list_spec.rb
challah-0.4.0 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/create_list_spec.rb
challah-0.3.5 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/create_list_spec.rb
challah-0.3.4 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/create_list_spec.rb
challah-0.3.3 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/create_list_spec.rb
challah-0.3.2 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/create_list_spec.rb
challah-0.3.1 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/create_list_spec.rb
factory_girl-2.5.1 spec/acceptance/create_list_spec.rb
challah-0.3.0 vendor/bundle/gems/factory_girl-2.5.0/spec/acceptance/create_list_spec.rb
challah-0.2.1 vendor/bundle/gems/factory_girl-2.5.0/spec/acceptance/create_list_spec.rb
challah-0.2.0 vendor/bundle/gems/factory_girl-2.5.0/spec/acceptance/create_list_spec.rb
factory_girl-2.5.0 spec/acceptance/create_list_spec.rb
factory_girl-2.4.2 spec/acceptance/create_list_spec.rb