Sha256: 89b0fd6e9d40d3c02eccf7b829693fd4d285cb82efdd9a9bd99e940346f02a33

Contents?: true

Size: 926 Bytes

Versions: 13

Compression:

Stored size: 926 Bytes

Contents

require 'spec_helper'
require 'acceptance/acceptance_helper'

require 'factory_girl/syntax/blueprint'

describe "a blueprint" do
  before do
    define_model('User', :first_name => :string, :last_name => :string, :email => :string)

    Factory.sequence(:email) { |n| "somebody#{n}@example.com" }
    User.blueprint do
      first_name { 'Bill'                       }
      last_name  { 'Nye'                        }
      email      { FactoryGirl.generate(:email) }
    end
  end

  describe "after making an instance" do
    before do
      @instance = FactoryGirl.create(:user, :last_name => 'Rye')
    end

    it "should use attributes from the blueprint" do
      @instance.first_name.should == 'Bill'
    end

    it "should evaluate attribute blocks for each instance" do
      @instance.email.should =~ /somebody\d+@example.com/
      FactoryGirl.create(:user).email.should_not == @instance.email
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

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