Sha256: fa848fd0fa5fb10f0d585fc8d271a1a5d7db713748caa52cae2b4cd5787a5fe9

Contents?: true

Size: 823 Bytes

Versions: 4

Compression:

Stored size: 823 Bytes

Contents

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
factory_girl-1.3.3 spec/acceptance/syntax/blueprint_spec.rb
factory_girl-1.3.2 spec/acceptance/syntax/blueprint_spec.rb
factory_girl-1.3.1 spec/acceptance/syntax/blueprint_spec.rb
factory_girl-1.3.0 spec/acceptance/syntax/blueprint_spec.rb