Reputation: 35
How to test the foreign key association in rspec,
Here is the code
has_one :store, :foreign_key => "seller_id", :class_name => "Store"
How to write rspec for this code
Please tell me some suggestion
Upvotes: 1
Views: 321
Reputation: 6720
The answer is shoulda-matchers gems. Check this out: https://github.com/thoughtbot/shoulda-matchers
describe Post do
it { should belong_to(:user) }
it { should have_many(:tags).through(:taggings) }
end
describe User do
it { should have_many(:posts) }
end
Upvotes: 1