parent
5d173a95c8
commit
15f53cd50b
61
README.md
61
README.md
|
@ -109,7 +109,32 @@ group :test do
|
||||||
end
|
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
|
Now you can use matchers in your tests. For instance a model test might look
|
||||||
like this:
|
like this:
|
||||||
|
@ -149,7 +174,7 @@ end
|
||||||
Then you can say:
|
Then you can say:
|
||||||
|
|
||||||
``` ruby
|
``` ruby
|
||||||
describe MyModel, type: :model do
|
describe MySpecialModel, type: :model do
|
||||||
# ...
|
# ...
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
@ -184,8 +209,6 @@ group :test do
|
||||||
end
|
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
|
Now you can use matchers in your tests. For instance a model test might look
|
||||||
like this:
|
like this:
|
||||||
|
|
||||||
|
@ -195,36 +218,6 @@ class PersonTest < ActiveSupport::TestCase
|
||||||
end
|
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
|
## Running tests
|
||||||
|
|
||||||
### Unit tests
|
### Unit tests
|
||||||
|
|
Loading…
Reference in New Issue