shoulda-matchers gem , :
describe User do
it { should have_many(:surveys) }
end
- gem-o-phobia , ActiveRecord::Reflection, :
describe User do
it "should have_many :surveys" do
expect(User.reflect_on_association(:surveys).macro).to eq :has_many
end
end
describe Survey do
it "should belong_to user" do
expect(Survey.reflect_on_association(:user).macro).to eq :belongs_to
expect(Survey.column_names).to include :user_id
end
end
, , , , , A B.