mirror of
https://github.com/thoughtbot/factory_bot.git
synced 2022-11-09 11:43:51 -05:00
35 lines
591 B
Ruby
35 lines
591 B
Ruby
require 'spec_helper'
|
|
require 'acceptance/acceptance_helper'
|
|
|
|
describe "a built instance" do
|
|
include FactoryGirl::Syntax::Methods
|
|
|
|
before do
|
|
define_model('User')
|
|
|
|
define_model('Post', :user_id => :integer) do
|
|
belongs_to :user
|
|
end
|
|
|
|
FactoryGirl.define do
|
|
factory :user do
|
|
end
|
|
|
|
factory :post do
|
|
user
|
|
end
|
|
end
|
|
end
|
|
|
|
subject { build(:post) }
|
|
|
|
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
|
|
|