require 'spec_helper' require 'acceptance/acceptance_helper' describe "an instance generated by a factory that inherits from another factory" do before do define_model("User", :name => :string, :admin => :boolean, :email => :string) FactoryGirl.define do factory :user do name { "John" } email { "john@example.com" } end factory :admin, :parent => :user do admin { true } email { "admin@example.com" } end end end subject { FactoryGirl.create(:admin) } it "uses the parent build class" do subject.should be_kind_of(User) end it "inherits attributes" do subject.name.should == 'John' end it "has its own attributes" do subject.should be_admin end it "overrides attributes" do subject.email.should == 'admin@example.com' end end