Sha256: 9d6b28b72ba16ebd0b7de9d5680f7dd068e9da0419733766393f5c3d3f8ea799

Contents?: true

Size: 788 Bytes

Versions: 1

Compression:

Stored size: 788 Bytes

Contents

require 'spec_helper'
require 'acceptance/acceptance_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

  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

1 entries across 1 versions & 1 rubygems

Version Path
factory_girl-2.0.0.beta1 spec/acceptance/syntax/blueprint_spec.rb