Shoulda Matchers

forked from Shoulda Matchers

https://github.com/thoughtbot/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 1,045 0


sliu
sliu

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"
end

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
    end
  end
EOF

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!