2010-11-12 15:58:25 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "a built instance" do
|
2011-01-19 19:47:49 -05:00
|
|
|
include FactoryGirl::Syntax::Methods
|
|
|
|
|
2010-11-12 15:58:25 -05:00
|
|
|
before do
|
|
|
|
define_model('User')
|
|
|
|
|
|
|
|
define_model('Post', :user_id => :integer) do
|
|
|
|
belongs_to :user
|
|
|
|
end
|
|
|
|
|
|
|
|
FactoryGirl.define do
|
2011-06-29 14:43:15 -04:00
|
|
|
factory :user
|
2010-11-12 15:58:25 -05:00
|
|
|
|
|
|
|
factory :post do
|
|
|
|
user
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-01-19 19:47:49 -05:00
|
|
|
subject { build(:post) }
|
2010-11-12 15:58:25 -05:00
|
|
|
|
|
|
|
it "isn't saved" do
|
|
|
|
should be_new_record
|
|
|
|
end
|
|
|
|
|
|
|
|
it "assigns and saves associations" do
|
|
|
|
subject.user.should be_kind_of(User)
|
|
|
|
subject.user.should_not be_new_record
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|