From 15f53cd50b7680b093cca0491be67e8ce71c8650 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Fri, 15 Jan 2016 11:05:23 -0700 Subject: [PATCH] Fix instructions for Minitest [ci skip] --- README.md | 61 ++++++++++++++++++++++++------------------------------- 1 file changed, 27 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 5f504acb..620862f5 100644 --- a/README.md +++ b/README.md @@ -109,7 +109,32 @@ group :test do end ``` -[Then, configure the gem to integrate with RSpec](#configuration). +Now you need to tell the gem a couple of things: + +* Which test framework you're using +* Which portion of the matchers you want to use + +You can supply this information by using a configuration block. Place the +following in `rails_helper.rb`: + +``` ruby +Shoulda::Matchers.configure do |config| + config.integrate do |with| + # Choose a test framework: + with.test_framework :rspec + with.test_framework :minitest + with.test_framework :minitest_4 + with.test_framework :test_unit + + # Choose one or more libraries: + with.library :active_record + with.library :active_model + with.library :action_controller + # Or, choose the following (which implies all of the above): + with.library :rails + end +end +``` Now you can use matchers in your tests. For instance a model test might look like this: @@ -149,7 +174,7 @@ end Then you can say: ``` ruby -describe MyModel, type: :model do +describe MySpecialModel, type: :model do # ... end ``` @@ -184,8 +209,6 @@ group :test do end ``` -[Then, configure the gem to integrate with Minitest](#configuration). - Now you can use matchers in your tests. For instance a model test might look like this: @@ -195,36 +218,6 @@ class PersonTest < ActiveSupport::TestCase end ``` -### Configuration - -Before you can use Shoulda Matchers, you'll need to tell it a couple of things: - -* Which test framework you're using -* Which portion of the matchers you want to use - -You can supply this information by using a configuration block. Place the -following in `rails_helper.rb` (if you're using RSpec) or `test_helper.rb` (if -you're using Minitest): - -``` ruby -Shoulda::Matchers.configure do |config| - config.integrate do |with| - # Choose a test framework: - with.test_framework :rspec - with.test_framework :minitest - with.test_framework :minitest_4 - with.test_framework :test_unit - - # Choose one or more libraries: - with.library :active_record - with.library :active_model - with.library :action_controller - # Or, choose the following (which implies all of the above): - with.library :rails - end -end -``` - ## Running tests ### Unit tests