Shoulda matchers have_many with custom relation name
问题 How do I test this ActiveRecord relation using shoulda matchers? Models class User < ActiveRecord::Base has_many :articles end class Article < ActiveRecord::Base belongs_to :author, class_name: 'User' end Test describe User do it { should have_many(:articles) } end I'm getting the following error: 1) User should have many articles Failure/Error: it { should have_many(:articles) } Expected User to have a has_many association called articles (Article does not have a user_id foreign key.) # .