Sha256: 5e8d5fef70308e53f9929c0f5943057341561235bec5232a3a883d2ede99f1d0

Contents?: true

Size: 1.6 KB

Versions: 32

Compression:

Stored size: 1.6 KB

Contents

require "spec_helper"

describe FactoryGirl::Definition do
  it { should delegate(:declare_attribute).to(:declarations) }
end

describe FactoryGirl::Definition, "with a name" do
  let(:name) { :"great name" }
  subject    { FactoryGirl::Definition.new(name) }

  it "creates a new attribute list with the name passed" do
    FactoryGirl::DeclarationList.stubs(:new)
    subject
    FactoryGirl::DeclarationList.should have_received(:new).with(name)
  end
end

describe FactoryGirl::Definition, "#overridable" do
  let(:list) { stub("declaration list", overridable: true) }
  before { FactoryGirl::DeclarationList.stubs(new: list) }

  it "sets the declaration list as overridable" do
    subject.overridable.should == subject
    list.should have_received(:overridable).once
  end
end

describe FactoryGirl::Definition, "defining traits" do
  let(:trait_1) { stub("trait") }
  let(:trait_2) { stub("trait") }

  it "maintains a list of traits" do
    subject.define_trait(trait_1)
    subject.define_trait(trait_2)
    subject.defined_traits.should == [trait_1, trait_2]
  end
end

describe FactoryGirl::Definition, "adding callbacks" do
  let(:callback_1) { "callback1" }
  let(:callback_2) { "callback2" }

  it "maintains a list of callbacks" do
    subject.add_callback(callback_1)
    subject.add_callback(callback_2)
    subject.callbacks.should == [callback_1, callback_2]
  end
end

describe FactoryGirl::Definition, "#to_create" do
  its(:to_create) { should be_nil }

  it "returns the assigned value when given a block" do
    block = proc { nil }
    subject.to_create(&block)
    subject.to_create.should == block
  end
end

Version data entries

32 entries across 24 versions & 4 rubygems

Version Path
challah-1.0.0.beta vendor/bundle/gems/factory_girl-4.1.0/spec/factory_girl/definition_spec.rb
challah-0.9.1.beta.3 vendor/bundle/gems/factory_girl-4.1.0/spec/factory_girl/definition_spec.rb
challah-0.9.1.beta vendor/bundle/gems/factory_girl-4.1.0/spec/factory_girl/definition_spec.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/factory_girl-4.1.0/spec/factory_girl/definition_spec.rb
challah-0.9.0 vendor/bundle/gems/factory_girl-4.1.0/spec/factory_girl/definition_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/factory_girl-4.0.0/spec/factory_girl/definition_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/factory_girl-3.6.1/spec/factory_girl/definition_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/factory_girl-4.0.0/spec/factory_girl/definition_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/factory_girl-3.6.1/spec/factory_girl/definition_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/factory_girl-4.1.0/spec/factory_girl/definition_spec.rb
challah-rolls-0.2.0 vendor/bundle/gems/challah-0.8.3/vendor/bundle/gems/factory_girl-4.1.0/spec/factory_girl/definition_spec.rb
challah-0.8.3 vendor/bundle/gems/factory_girl-4.1.0/spec/factory_girl/definition_spec.rb
challah-0.8.3 vendor/bundle/gems/factory_girl-4.0.0/spec/factory_girl/definition_spec.rb
factory_girl-3.6.2 spec/factory_girl/definition_spec.rb
challah-0.8.1 vendor/bundle/gems/factory_girl-4.0.0/spec/factory_girl/definition_spec.rb
factory_girl-4.1.0 spec/factory_girl/definition_spec.rb
challah-rolls-0.1.0 vendor/bundle/gems/factory_girl-4.0.0/spec/factory_girl/definition_spec.rb
challah-rolls-0.1.0 vendor/bundle/gems/factory_girl-3.6.1/spec/factory_girl/definition_spec.rb
challah-rolls-0.1.0 vendor/bundle/gems/challah-0.8.0.pre/vendor/bundle/gems/factory_girl-3.6.1/spec/factory_girl/definition_spec.rb
challah-0.8.0.pre vendor/bundle/gems/factory_girl-3.6.1/spec/factory_girl/definition_spec.rb