Sha256: 06b19c9297afec7f0bea65d2fde0fcf67f2249f4c97c0dfd669a023dc9b16aa5

Contents?: true

Size: 1.11 KB

Versions: 11

Compression:

Stored size: 1.11 KB

Contents

require 'spec_helper'
require 'acceptance/acceptance_helper'

require 'factory_girl/syntax/make'

describe "a factory using make syntax" do
  before do
    define_model('User', :first_name => :string, :last_name => :string)

    FactoryGirl.define do
      factory :user do
        first_name 'Bill'
        last_name  'Nye'
      end
    end
  end

  describe "after make" do
    before do
      @instance = User.make(:last_name => 'Rye')
    end

    it "should use attributes from the factory" do
      @instance.first_name.should == 'Bill'
    end

    it "should use attributes passed to make" do
      @instance.last_name.should == 'Rye'
    end

    it "should build the record" do
      @instance.should be_new_record
    end
  end

  describe "after make!" do
    before do
      @instance = User.make!(:last_name => 'Rye')
    end

    it "should use attributes from the factory" do
      @instance.first_name.should == 'Bill'
    end

    it "should use attributes passed to make" do
      @instance.last_name.should == 'Rye'
    end

    it "should save the record" do
      @instance.should_not be_new_record
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
factory_girl-2.0.4 spec/acceptance/syntax/make_spec.rb
factory_girl-2.0.3 spec/acceptance/syntax/make_spec.rb
factory_girl-2.0.2 spec/acceptance/syntax/make_spec.rb
factory_girl-2.0.1 spec/acceptance/syntax/make_spec.rb
factory_girl-2.0.0.rc4 spec/acceptance/syntax/make_spec.rb
factory_girl-2.0.0.rc3 spec/acceptance/syntax/make_spec.rb
factory_girl-2.0.0.rc2 spec/acceptance/syntax/make_spec.rb
factory_girl-2.0.0.rc1 spec/acceptance/syntax/make_spec.rb
factory_girl-2.0.0.beta5 spec/acceptance/syntax/make_spec.rb
factory_girl-2.0.0.beta4 spec/acceptance/syntax/make_spec.rb
factory_girl-2.0.0.beta3 spec/acceptance/syntax/make_spec.rb