Sha256: e27fa8e6a59896dd275efdbb7305366ce1f120c1dea1b435a56d0880275aa9db

Contents?: true

Size: 905 Bytes

Versions: 2

Compression:

Stored size: 905 Bytes

Contents

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

require 'factory_girl/syntax/blueprint'

describe "a blueprint" do
  before do
    Factory.clear_caches
    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.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/
      Factory(:user).email.should_not == @instance.email
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
masa-iwasaki-factory_girl-1.2.3.2 spec/factory_girl/syntax/blueprint_spec.rb
masa-iwasaki-factory_girl-1.2.3.1 spec/factory_girl/syntax/blueprint_spec.rb