Sha256: 9b750b06b259735d4dc5a942f6f836e4d9c4c88ecb888c50a1eaa3d7705d85b6

Contents?: true

Size: 935 Bytes

Versions: 3

Compression:

Stored size: 935 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

require 'factory_girl/syntax/blueprint'

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

  after do
    Factory.factories.clear
    Factory.sequences.clear
  end

  describe "after making an instance" do
    before do
      @instance = Factory(: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/
      Factory(:user).email.should_not == @instance.email
      # Factory(:user).email.should == @instance.email      
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
freegenie-factory_girl-1.2.4 spec/factory_girl/syntax/blueprint_spec.rb
freegenie-factory_girl-1.2.3 spec/factory_girl/syntax/blueprint_spec.rb
freegenie-factory_girl-1.2.2 spec/factory_girl/syntax/blueprint_spec.rb