I agree with sevenseacat that you're likely using a modern version of RSpec that disables monkey patching.
This disabling is done by default when the spec_helper.rb
file is created when you do something like
$ rails generate rspec:install
In spec_helper.rb
, you'll see a section that looks like this:
# Limits the available syntax to the non-monkey patched syntax that is
# recommended. For more details, see:
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
config.disable_monkey_patching!
You can comment out that last line.
However, the recommended approach is not to use monkey patching, and use RSpec.describe
.