Sha256: ff1508b4303650c93fae4b4f4c61ebe6b05ee260f12f7fa6c5bd6b89082013c2

Contents?: true

Size: 892 Bytes

Versions: 59

Compression:

Stored size: 892 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)

    FactoryGirl.define do
      sequence(:email) { |n| "somebody#{n}@example.com" }
    end

    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 "uses attributes from the blueprint" do
      @instance.first_name.should == 'Bill'
    end

    it "evaluates 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

59 entries across 59 versions & 4 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.7.4 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.7.3 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.7.2 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.7.1 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.7.0 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.6.9 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.6.8 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.6.7 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.6.6 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.6.5 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.6.4 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.6.3 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.6.2 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.6.1 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.6.0 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.5.17 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.5.16 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.5.15 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb
classiccms-0.5.14 vendor/bundle/gems/factory_girl-3.0.0/spec/acceptance/syntax/blueprint_spec.rb