With Rails 5 and RSpec 3.5, I'm getting the following error.
1) User
Failure/Error: it { should validate_uniqueness_of(:auth_token)}
NoMethodError:
undefined method `validate_uniqueness_of' for #<RSpec::ExampleGroups::User:0x007fab919f8cf
8>
# ./spec/models/user_spec.rb:14:in `block (2 levels) in <top (required)>'
I've googled around for the right syntax but couldn't find the solution. Does anyone have an idea of what to use here? Thanks
You have to add the gem to the Gemfile:
Gemfile
group :test do
gem 'shoulda-matchers'
end
And include it:
spec/rails_helper.rb
RSpec.configure do |config|
config.include(Shoulda::Matchers::ActiveModel, type: :model)
config.include(Shoulda::Matchers::ActiveRecord, type: :model)
end
I made it work by adding this:
Gemfile
group :test do
gem 'shoulda-matchers'
end
rails_helper.rb
require 'shoulda/matchers'
Shoulda::Matchers.configure do |config|
config.integrate do |with|
with.test_framework :rspec
with.library :rails
end
end
.rspec
--color
--require spec_helper
--require rails_helper
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With