Skip to content

Commit 758801c

Browse files
committed
Apply changes per @samphippen's review
1 parent bba982b commit 758801c

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

README.md

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ Use **[`rspec-rails` 1.x][]** for Rails 2.x.
5353
create spec
5454
create spec/spec_helper.rb
5555
create spec/rails_helper.rb
56-
57-
# Rails 4+ only: generate a binstub
58-
# (so you can run `bin/rspec` instead of `bundle exec rspec`)
59-
$ bundle binstubs rspec-core
6056
```
6157

6258
## Upgrading
@@ -119,6 +115,14 @@ $ bundle exec rspec spec/controllers/accounts_controller_spec.rb:8
119115
$ bundle exec rspec --help
120116
```
121117

118+
**Optional:** If `bundle exec rspec` is too verbose for you,
119+
you can generate a binstub at `bin/rspec`
120+
and use that instead (Rails 4+ only):
121+
122+
```sh
123+
$ bundle binstubs rspec-core
124+
```
125+
122126
## RSpec DSL Basics (or, how do I write a spec?)
123127

124128
In RSpec, application behavior is described
@@ -241,6 +245,25 @@ or for official Rails API documentation on the given `TestCase` class.
241245
> to encourage good testing practices, but there’s no “right” way to do it.
242246
> Ultimately, it’s up to you to decide how your test suite will be composed.
243247
248+
When creating a spec file,
249+
assign it a type by placing it [in the appropriate folder][]
250+
(_e.g.,_ `spec/models/` for model specs).
251+
If you want to be extra explicit,
252+
you can set the `:type` option at the top of the file, like so:
253+
254+
```ruby
255+
# spec/models/user_spec.rb
256+
257+
RSpec.describe User, type: :model do
258+
...
259+
```
260+
261+
If you use the built-in generators, these details will be handled automatically:
262+
263+
```sh
264+
$ rails generate rspec:<type> <name>
265+
```
266+
244267
[request]: https://relishapp.com/rspec/rspec-rails/docs/request-specs/request-spec
245268
[feature]: https://www.relishapp.com/rspec/rspec-rails/docs/feature-specs/feature-spec
246269
[system]: https://relishapp.com/rspec/rspec-rails/docs/system-specs/system-spec
@@ -254,23 +277,6 @@ or for official Rails API documentation on the given `TestCase` class.
254277
[`ActionDispatch::IntegrationTest`]: https://api.rubyonrails.org/classes/ActionDispatch/IntegrationTest.html
255278
[`ActionDispatch::SystemTestCase`]: https://api.rubyonrails.org/classes/ActionDispatch/SystemTestCase.html
256279
[`ActionController::TestCase`]: https://api.rubyonrails.org/classes/ActionController/TestCase.html
257-
258-
### I’m writing a spec file from scratch. How do I assign it a type?
259-
260-
Simply place the spec [in the appropriate folder][]
261-
(_e.g.,_ `spec/models/` for model specs)
262-
and RSpec will set its type automatically.
263-
264-
If you want to be extra explicit,
265-
you can set the `:type` option at the top of the file, like so:
266-
267-
```ruby
268-
# spec/models/user_spec.rb
269-
270-
RSpec.describe User, type: :model do
271-
...
272-
```
273-
274280
[in the appropriate folder]: https://relishapp.com/rspec/rspec-rails/docs/directory-structure
275281

276282
### System specs, feature specs, request specs–what’s the difference?

0 commit comments

Comments
 (0)