shoulda-matcher methods not found in Rails 4.1

Updated . Posted . Visible to the public.

So you're getting an error message like the following, although your Gemfile lists shoulda-matchers and it has always worked:

NoMethodError:
  undefined method `allow_value' for #<RSpec::ExampleGroups::Person::Age:0x007feb239fa6a8>

This is due to Rails 4.1 (specifically, Spring) revealing a weak point of shoulda-matchers -- jonleighton explains why Show archive.org snapshot .

Solution

The solution is to follow the gem's installation guide Show archive.org snapshot :

# Gemfile
gem 'shoulda-matchers', require: false

# spec/rails_helper.rb if present, spec/spec_helper.rb else
require 'rspec/rails'
require 'shoulda/matchers'
Profile picture of Dominik Schöler
Dominik Schöler
Last edit
Dominik Schöler
License
Source code in this card is licensed under the MIT License.
Posted by Dominik Schöler to makandra dev (2014-06-26 14:15)