How to Use Shoulda Matchers with RSpec for Ruby on Rails
shoulda-matchers gives you one-line RSpec and Minitest matchers for common Rails behavior — it { should validate_presence_of(:name) } replaces a hand-written validation spec. Add gem "shoulda-matchers", "~> 8.0" to your Gemfile’s test group, then add the configuration block to spec/rails_helper.rb naming your test framework and library. Version 8 works with Rails 8.1 and rspec-rails 8.