Rails 4 语法,用于应该有匹配器"have_many"与"order"



我对用户模型有轨道4验证:

has_many :items, -> { order(:position) }

我期望以下应该使用的匹配项可以工作:
it {should have_many(:items).order(:position)}

,但它提出了这个错误:
Expected User to have a has_many association called items (items should be ordered by position)

我的语法是对测试的错误吗?

v2.4.0中有一个错误,其中它不起作用。这已在v2.5.0中修复,因此请检查一下!

请参阅此处的更多信息:https://github.com/thoughtbot/shoulda-matchers/issues/388

相关内容

最新更新