0

shoulda_matchers在我的specs. 对于这个测试

it { should validate_uniqueness_of(:name).scoped_to(:role_id) }

我收到此错误:

Expected errors to include "has already been taken" when name is set to "arbitrary_string", got errors: ["name is already taken (\"arbitrary_string\")"]

当我将测试更改为:

it { should validate_uniqueness_of(:name).scoped_to(:role_id).with_message('is already taken') }

我收到此错误:

 NoMethodError:
       undefined method `columns_hash' for Activity:Class

我的模型只有一个字段 -name

4

1 回答 1

2

Mongoid模型没有columns_hash类方法并shoulda-matchers使用此方法。

中对应的方法mongoidcolumns

我能够通过替换gemsshoulda和.shoulda-matchersmongoid-rspec

于 2013-08-27T08:09:56.330 回答