Q:

undefined method `columns_hash'

I have used shoulda_matchers in my specs. For this test
it { should validate_uniqueness_of(:name).scoped_to(:role_id) }

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

When I change the test to:
it { should validate_uniqueness_of(:name).scoped_to(:role_id).with_message('is already taken') }

I am getting this error:
 NoMethodError:
       undefined method `columns_hash' for Activity:Class

My model has only one field - name

A:

Mongoid Models do not have a columns_hash class method and shoulda-matchers use this method.
The corresponding method in mongoid is columns
I was able to solve this issue by replacing the gems shoulda and shoulda-matchers with mongoid-rspec.

