mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
Fix instructions for Minitest
[ci skip]
This commit is contained in:
parent
5d173a95c8
commit
15f53cd50b
1 changed files with 27 additions and 34 deletions
61
README.md
61
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
|
||||
|
|
Loading…
Reference in a new issue