shoulda-matchers: undefined method `validate_presence_of'
I’m getting an error when trying to use shoulda-matchers in a Rails 4 project:
test/models/registration_test.rb:5:in `<class:RegistrationTest>': undefined method `validate_presence_of' for RegistrationTest:Class (NoMethodError) from test/models/registration_test.rb:3:in `<main>'
Gemfile:
group :test do
gem 'capybara'
gem 'shoulda-matchers'
gem 'database_cleaner'
gem 'factory_girl_rails'
end
test_helper.rb:
ENV["RAILS_ENV"] ||= "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
ActiveRecord::Migration.check_pending!
end
registration_test.rb:
require 'test_helper'
class RegistrationTest < ActiveSupport::TestCase
should validate_presence_of :first_name
end
What am I missing here?
About this issue
- Original URL
- State: closed
- Created 11 years ago
- Comments: 18 (1 by maintainers)
The quick & dirty hack version of the above:
@onetakeone Not only is this issue closed (and was closed 4 years ago), but the last comment was over 3 years ago. Don’t comment on dead threads.
Check https://github.com/thoughtbot/shoulda-matchers for configuration block to place in rails_helper.rb