Read more

shoulda-matcher methods not found in Rails 4.1

Dominik Schöler
June 26, 2014Software engineer at makandra GmbH

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>
Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

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'
Posted by Dominik Schöler to makandra dev (2014-06-26 16:15)