Closed dbforge closed 3 months ago
After one day of debugging, it all came down to a typo. Instead of validate
I wrote validatate
.
I noticed this after trying to debug why the module was loaded in RSpec, but I could not call the methods. When I noticed that other methods work, I saw it. Sorry.
Description
I cannot get shoulda-matchers running in my project. I am using Rails 7.0.4 and Ruby 3.2.3. The matchers are not found. How can this be? The rails app is loaded before-hand, models are found and shoulda-matchers is configured for rails and rspec. This should be able to load the matchers for my example groups.
Reproduction Steps
Build a Rails 7.0.4 project with Ruby 3.2.3. Add this to the Gemfile:
Run
bin/rails generate rspec:install
. The relevant files are created. Adapt.rspec
to include therails_helper.rb
:The
rails_helper.rb
should look like this:Mind the shoulda config at the bottom.
The
spec_helper.rb
should look like this (unchanged since generation):Add a migration and run it:
Add
organization.rb
toapp/models
and paste this:Now, build the
spec/models/organization_spec.rb
:Expected behavior
When running specs using
bundle exec rspec spec/models/organization.rb
, the spec should be green.Actual behavior
I get the error:
System configuration
shoulda_matchers version: 6.2.0 rails version: 7.0.4 ruby version: 3.2.3