Shoulda Matchers

forked from Shoulda Matchers

Shoulda Matchers provides RSpec- and Minitest-compatible one-liners to test common Rails functionality that, if written by hand, would be much longer, more complex, and error-prone.
testing 896 0


May 14, 2021

Copy and paste this code into your terminal

DISCLAIMER: You should always review templates before running them. By running the template, you are agreeing to the terms of use.

The contents of this script as show. Any updates will be reflected in the below code and the snippet.

if !defined? RSpec
  say "RSpec was not installed. Adding it now..."
  gem "rspec-rails" , group: [:development, :test]
  run "bundle install"
  generate "rspec:install"

gem 'shoulda-matchers', group: [:test]

run 'bundle install'

create_file "spec/support/shoulda_matchers.rb", <<~EOF
  Shoulda::Matchers.configure do |config|
    config.integrate do |with|
      with.test_framework :rspec
      with.library :rails

gsub_file 'spec/rails_helper.rb', "# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }\n", "Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }\n"

A place where you can thank the author, post problems, give constructive feedback, etc. Be nice!