Sha256: 6d4250e45c25f12c6efdbb684bed911fc247e85dd39653ae07b6aaea46e2bfce

Contents?: true

Size: 1.04 KB

Versions: 39

Compression:

Stored size: 1.04 KB

Contents

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

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

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

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

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

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

    it "saves the record" do
      @instance.should_not be_new_record
    end
  end
end

Version data entries

39 entries across 34 versions & 3 rubygems

Version Path
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/factory_girl-2.6.4/spec/acceptance/syntax/make_spec.rb
challah-0.6.2 vendor/bundle/gems/factory_girl-2.6.1/spec/acceptance/syntax/make_spec.rb
challah-0.6.1 vendor/bundle/gems/factory_girl-2.6.1/spec/acceptance/syntax/make_spec.rb
challah-0.6.1 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/syntax/make_spec.rb
challah-0.6.0 vendor/bundle/gems/factory_girl-2.6.1/spec/acceptance/syntax/make_spec.rb
challah-0.6.0 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/syntax/make_spec.rb
challah-0.5.4 vendor/bundle/gems/factory_girl-2.6.1/spec/acceptance/syntax/make_spec.rb
challah-0.5.4 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/syntax/make_spec.rb
challah-0.5.3 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/syntax/make_spec.rb
challah-0.5.3 vendor/bundle/gems/factory_girl-2.6.1/spec/acceptance/syntax/make_spec.rb
challah-0.5.2 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/syntax/make_spec.rb
challah-0.5.2 vendor/bundle/gems/factory_girl-2.6.1/spec/acceptance/syntax/make_spec.rb
factory_girl-2.6.4 spec/acceptance/syntax/make_spec.rb
factory_girl-2.6.3 spec/acceptance/syntax/make_spec.rb
factory_girl-2.6.2 spec/acceptance/syntax/make_spec.rb
challah-0.5.1 vendor/bundle/gems/factory_girl-2.6.1/spec/acceptance/syntax/make_spec.rb
factory_girl-2.6.1 spec/acceptance/syntax/make_spec.rb
challah-0.5.0 vendor/bundle/gems/factory_girl-2.5.1/spec/acceptance/syntax/make_spec.rb
factory_girl-2.6.0 spec/acceptance/syntax/make_spec.rb
factory_girl-2.5.2 spec/acceptance/syntax/make_spec.rb