Sha256: febd07b557788de1f258c2f1a0d87b5dfe8608f0471ee6502062bbf10b96d686

Contents?: true

Size: 887 Bytes

Versions: 3

Compression:

Stored size: 887 Bytes

Contents

require 'spec_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

3 entries across 3 versions & 1 rubygems

Version Path
factory_girl-2.1.2 spec/acceptance/syntax/blueprint_spec.rb
factory_girl-2.1.0 spec/acceptance/syntax/blueprint_spec.rb
factory_girl-2.0.5 spec/acceptance/syntax/blueprint_spec.rb