rspec-rails 4.0.0 → 5.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/Changelog.md +139 -50
- data/README.md +42 -31
- data/lib/generators/rspec/controller/controller_generator.rb +2 -2
- data/lib/generators/rspec/controller/templates/request_spec.rb +6 -1
- data/lib/generators/rspec/install/templates/spec/rails_helper.rb +1 -1
- data/lib/generators/rspec/job/job_generator.rb +2 -1
- data/lib/generators/rspec/job/templates/job_spec.rb.erb +1 -1
- data/lib/generators/rspec/mailer/templates/mailer_spec.rb +2 -2
- data/lib/generators/rspec/mailer/templates/preview.rb +1 -1
- data/lib/generators/rspec/scaffold/scaffold_generator.rb +4 -0
- data/lib/generators/rspec/scaffold/templates/api_controller_spec.rb +13 -13
- data/lib/generators/rspec/scaffold/templates/api_request_spec.rb +20 -20
- data/lib/generators/rspec/scaffold/templates/controller_spec.rb +10 -58
- data/lib/generators/rspec/scaffold/templates/edit_spec.rb +0 -4
- data/lib/generators/rspec/scaffold/templates/new_spec.rb +0 -4
- data/lib/generators/rspec/scaffold/templates/request_spec.rb +23 -18
- data/lib/generators/rspec/system/system_generator.rb +14 -16
- data/lib/rspec/rails/configuration.rb +41 -6
- data/lib/rspec/rails/example/controller_example_group.rb +1 -0
- data/lib/rspec/rails/example/mailbox_example_group.rb +1 -1
- data/lib/rspec/rails/example/mailer_example_group.rb +2 -2
- data/lib/rspec/rails/example/request_example_group.rb +1 -4
- data/lib/rspec/rails/example/system_example_group.rb +5 -4
- data/lib/rspec/rails/extensions/active_record/proxy.rb +4 -1
- data/lib/rspec/rails/file_fixture_support.rb +9 -11
- data/lib/rspec/rails/fixture_file_upload_support.rb +32 -16
- data/lib/rspec/rails/fixture_support.rb +9 -12
- data/lib/rspec/rails/matchers/action_mailbox.rb +14 -5
- data/lib/rspec/rails/matchers/active_job.rb +29 -3
- data/lib/rspec/rails/matchers/have_enqueued_mail.rb +33 -5
- data/lib/rspec/rails/matchers/have_http_status.rb +4 -4
- data/lib/rspec/rails/matchers/relation_match_array.rb +1 -1
- data/lib/rspec/rails/version.rb +1 -1
- data/lib/rspec-rails.rb +5 -7
- data.tar.gz.sig +0 -0
- metadata +37 -25
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be221e5df3386cb55e14f8047e02628bc11098596dcce06749701ac0b7497782
|
4
|
+
data.tar.gz: 56b12531541ff18599c13618ba2937859bb4cd860cc814b3350046ec4949e870
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1786502c478ab9de29fbd59ce16371178776a7283698ba048b203f62aa614fc6c28e4c72b5064595f4eacd2cf309443de8d0d6803ac604e9d11a641c6f86c4b
|
7
|
+
data.tar.gz: 5860654b1926c2f2cdd998d2b84ac075167f7107bd687b74dae5bb9e17d7e76ef6b0c96dd022ec7a9be5dc0fe008e845808187080e97b400bec18b35d1872e76
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/Changelog.md
CHANGED
@@ -1,82 +1,148 @@
|
|
1
|
-
###
|
2
|
-
[Full Changelog](https://github.com/rspec/rspec-rails/compare/
|
1
|
+
### Development
|
2
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.1.1...5-1-maintenance)
|
3
|
+
|
4
|
+
Bug Fixes:
|
5
|
+
|
6
|
+
* Fix controller scaffold templates parameter name. (Taketo Takashima, #2591)
|
7
|
+
* Include generator specs in the inferred list of specs. (Jason Karns, #2597)
|
8
|
+
|
9
|
+
### 5.1.1 / 2022-03-07
|
10
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.1.0...v5.1.1)
|
11
|
+
|
12
|
+
Bug Fixes:
|
13
|
+
|
14
|
+
* Properly handle global id serialised arguments in `have_enqueued_mail`.
|
15
|
+
(Jon Rowe, #2578)
|
16
|
+
|
17
|
+
### 5.1.0 / 2022-01-26
|
18
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.0.3...v5.1.0)
|
3
19
|
|
4
20
|
Enhancements:
|
5
21
|
|
6
|
-
*
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
22
|
+
* Make the API request scaffold template more consistent and compatible with
|
23
|
+
Rails 6.1. (Naoto Hamada, #2484)
|
24
|
+
* Change the scaffold `rails_helper.rb` template to use `require_relative`.
|
25
|
+
(Jon Dufresne, #2528)
|
26
|
+
|
27
|
+
### 5.0.3 / 2022-01-26
|
28
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.0.2...v5.0.3)
|
12
29
|
|
13
30
|
Bug Fixes:
|
14
31
|
|
15
|
-
*
|
16
|
-
|
17
|
-
*
|
18
|
-
(
|
19
|
-
|
20
|
-
|
21
|
-
|
32
|
+
* Properly name params in controller and request spec templates when
|
33
|
+
using the `--model-name` parameter. (@kenzo-tanaka, #2534)
|
34
|
+
* Fix support for `have_enqueued_mail` on Ruby 3.1 with Rails 6.1.
|
35
|
+
(Fabio Napoleoni, Mikael Henriksson, Phil Pirozhkov, Jon Rowe, #2566)
|
36
|
+
|
37
|
+
### 5.0.2 / 2021-08-14
|
38
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.0.1...v5.0.2)
|
39
|
+
|
40
|
+
Bug Fixes:
|
41
|
+
|
42
|
+
* Prevent generated job specs from duplicating `_job` in filenames.
|
43
|
+
(Nick Flückiger, #2496)
|
44
|
+
* Fix `ActiveRecord::TestFixture#uses_transaction` by using example description
|
45
|
+
to replace example name rather than example in our monkey patched
|
46
|
+
`run_in_transaction?` method. (Stan Lo, #2495)
|
47
|
+
* Prevent keyword arguments being lost when methods are invoked dynamically
|
48
|
+
in controller specs. (Josh Cheek, #2509, #2514)
|
22
49
|
|
23
|
-
###
|
24
|
-
[Full Changelog](https://github.com/rspec/rspec-rails/compare/
|
50
|
+
### 5.0.1 / 2021-03-18
|
51
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v5.0.0...v5.0.1)
|
52
|
+
|
53
|
+
Bug Fixes:
|
54
|
+
|
55
|
+
* Limit multibyte example descriptions when used in system tests for #method_name
|
56
|
+
which ends up as screenshot names etc. (@y-yagi, #2405, #2487)
|
57
|
+
|
58
|
+
### 5.0.0 / 2021-03-09
|
59
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.1.1...v5.0.0)
|
25
60
|
|
26
61
|
Enhancements:
|
27
62
|
|
28
|
-
*
|
29
|
-
*
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
63
|
+
* Support new #file_fixture_path and new fixture test support code. (Jon Rowe, #2398)
|
64
|
+
* Support for Rails 6.1. (Benoit Tigeot, Jon Rowe, Phil Pirozhkov, and more #2398)
|
65
|
+
|
66
|
+
Breaking Changes:
|
67
|
+
|
68
|
+
* Drop support for Rails below 5.2.
|
69
|
+
|
70
|
+
### 4.1.1 / 2021-03-09
|
34
71
|
|
35
72
|
Bug Fixes:
|
36
73
|
|
37
|
-
*
|
38
|
-
(
|
39
|
-
* Prevent a `WrongScopeError` being thrown during loading fixtures on Rails
|
40
|
-
6.1 development version. (Edouard Chin, #2215)
|
41
|
-
* Fix Mocha mocking support with `should`. (Phil Pirozhkov, #2256)
|
74
|
+
* Remove generated specs when destroying a generated controller.
|
75
|
+
(@Naokimi, #2475)
|
42
76
|
|
43
|
-
### 4.
|
44
|
-
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.0.beta2...v4.0.0.beta3)
|
77
|
+
### 4.1.0 / 2021-03-06
|
45
78
|
|
46
79
|
Enhancements:
|
47
80
|
|
48
|
-
*
|
49
|
-
|
50
|
-
*
|
51
|
-
|
52
|
-
*
|
53
|
-
(
|
54
|
-
*
|
55
|
-
|
56
|
-
*
|
57
|
-
|
81
|
+
* Issue a warning when using job matchers with `#at` mis-match on `usec` precision.
|
82
|
+
(Jon Rowe, #2350)
|
83
|
+
* Generated request specs now have a bare `_spec` suffix instead of `request_spec`.
|
84
|
+
(Eloy Espinaco, Luka Lüdicke, #2355, #2356, #2378)
|
85
|
+
* Generated scaffold now includes engine route helpers when inside a mountable engine.
|
86
|
+
(Andrew W. Lee, #2372)
|
87
|
+
* Improve request spec "controller" scafold when no action is specified.
|
88
|
+
(Thomas Hareau, #2399)
|
89
|
+
* Introduce testing snippets concept (Phil Pirozhkov, Benoit Tigeot, #2423)
|
90
|
+
* Prevent collisions with `let(:name)` for Rails 6.1 and `let(:method_name)` on older
|
91
|
+
Rails. (Benoit Tigeot, #2461)
|
92
|
+
|
93
|
+
### 4.0.2 / 2020-12-26
|
94
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.1...v4.0.2)
|
58
95
|
|
59
96
|
Bug Fixes:
|
60
97
|
|
61
|
-
*
|
62
|
-
|
63
|
-
* `
|
64
|
-
(
|
65
|
-
*
|
98
|
+
* Indent all extra failure lines output from system specs. (Alex Robbin, #2321)
|
99
|
+
* Generated request spec for update now uses the correct let. (Paul Hanyzewski, #2344)
|
100
|
+
* Return `true`/`false` from predicate methods in config rather than raw values.
|
101
|
+
(Phil Pirozhkov, Jon Rowe, #2353, #2354)
|
102
|
+
* Remove old #fixture_path feature detection code which broke under newer Rails.
|
103
|
+
(Koen Punt, Jon Rowe, #2370)
|
104
|
+
* Fix an error when `use_active_record` is `false` (Phil Pirozhkov, #2423)
|
66
105
|
|
67
|
-
### 4.0.
|
68
|
-
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.0
|
106
|
+
### 4.0.1 / 2020-05-16
|
107
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.0...v4.0.1)
|
69
108
|
|
70
109
|
Bug Fixes:
|
71
110
|
|
72
|
-
*
|
111
|
+
* Remove warning when calling `driven_by` in system specs. (Aubin Lorieux, #2302)
|
112
|
+
* Fix comparison of times for `#at` in job matchers. (Jon Rowe, Markus Doits, #2304)
|
113
|
+
* Allow `have_enqueued_mail` to match when a sub class of `ActionMailer::DeliveryJob`
|
114
|
+
is set using `<Class>.delivery_job=`. (Atsushi Yoshida #2305)
|
115
|
+
* Restore Ruby 2.2.x compatibility. (Jon Rowe, #2332)
|
116
|
+
* Add `required_ruby_version` to gem spec. (Marc-André Lafortune, #2319, #2338)
|
73
117
|
|
74
|
-
### 4.0.0
|
75
|
-
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.9.
|
118
|
+
### 4.0.0 / 2020-03-24
|
119
|
+
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.9.1...v4.0.0)
|
76
120
|
|
77
121
|
Enhancements:
|
78
122
|
|
79
123
|
* Adds support for Rails 6. (Penelope Phippen, Benoit Tigeot, Jon Rowe, #2071)
|
124
|
+
* Adds support for JRuby on Rails 5.2 and 6
|
125
|
+
* Add support for parameterised mailers (Ignatius Reza, #2125)
|
126
|
+
* Add ActionMailbox spec helpers and test type (James Dabbs, #2119)
|
127
|
+
* Add ActionCable spec helpers and test type (Vladimir Dementyev, #2113)
|
128
|
+
* Add support for partial args when using `have_enqueued_mail`
|
129
|
+
(Ignatius Reza, #2118, #2125)
|
130
|
+
* Add support for time arguments for `have_enqueued_job` (@alpaca-tc, #2157)
|
131
|
+
* Improve path parsing in view specs render options. (John Hawthorn, #2115)
|
132
|
+
* Add routing spec template as an option for generating controller specs.
|
133
|
+
(David Revelo, #2134)
|
134
|
+
* Add argument matcher support to `have_enqueued_*` matchers. (Phil Pirozhkov, #2206)
|
135
|
+
* Switch generated templates to use ruby 1.9 hash keys. (Tanbir Hasan, #2224)
|
136
|
+
* Add `have_been_performed`/`have_performed_job`/`perform_job` ActiveJob
|
137
|
+
matchers (Isaac Seymour, #1785)
|
138
|
+
* Default to generating request specs rather than controller specs when
|
139
|
+
generating a controller (Luka Lüdicke, #2222)
|
140
|
+
* Allow `ActiveJob` matchers `#on_queue` modifier to take symbolic queue names. (Nils Sommer, #2283)
|
141
|
+
* The scaffold generator now generates request specs in preference to controller specs.
|
142
|
+
(Luka Lüdicke, #2288)
|
143
|
+
* Add configuration option to disable ActiveRecord. (Jon Rowe, Phil Pirozhkov, Hermann Mayer, #2266)
|
144
|
+
* Set `ActionDispatch::SystemTesting::Server.silence_puma = true` when running system specs.
|
145
|
+
(ta1kt0me, Benoit Tigeot, #2289)
|
80
146
|
|
81
147
|
Bug Fixes:
|
82
148
|
|
@@ -86,12 +152,35 @@ Bug Fixes:
|
|
86
152
|
deprecated. (Pavel Rosický, #2092)
|
87
153
|
* `ActionView::Template#formats` has been deprecated and replaced by
|
88
154
|
`ActionView::Template#format`(Seb Jacobs, #2100)
|
155
|
+
* Replace `before_teardown` as well as `after_teardown` to ensure screenshots
|
156
|
+
are generated correctly. (Jon Rowe, #2164)
|
157
|
+
* `ActionView::FixtureResolver#hash` has been renamed to `ActionView::FixtureResolver#data`.
|
158
|
+
(Penelope Phippen, #2076)
|
159
|
+
* Prevent `driven_by(:selenium)` being called due to hook precedence.
|
160
|
+
(Takumi Shotoku, #2188)
|
161
|
+
* Prevent a `WrongScopeError` being thrown during loading fixtures on Rails
|
162
|
+
6.1 development version. (Edouard Chin, #2215)
|
163
|
+
* Fix Mocha mocking support with `should`. (Phil Pirozhkov, #2256)
|
164
|
+
* Restore previous conditional check for setting `default_url_options` in feature
|
165
|
+
specs, prevents a `NoMethodError` in some scenarios. (Eugene Kenny, #2277)
|
166
|
+
* Allow changing `ActiveJob::Base.queue_adapter` inside a system spec.
|
167
|
+
(Jonathan Rochkind, #2242)
|
168
|
+
* `rails generate generator` command now creates related spec file (Joel Azemar, #2217)
|
169
|
+
* Relax upper `capybara` version constraint to allow for Capybara 3.x (Phil Pirozhkov, #2281)
|
170
|
+
* Clear ActionMailer test mailbox after each example (Benoit Tigeot, #2293)
|
89
171
|
|
90
172
|
Breaking Changes:
|
91
173
|
|
92
174
|
* Drops support for Rails below 5.0
|
93
175
|
* Drops support for Ruby below 2.3
|
94
176
|
|
177
|
+
### 3.9.1 / 2020-03-10
|
178
|
+
[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.9.0...v3.9.1)
|
179
|
+
|
180
|
+
Bug Fixes:
|
181
|
+
|
182
|
+
* Add missing require for have_enqueued_mail matcher. (Ignatius Reza, #2117)
|
183
|
+
|
95
184
|
### 3.9.0 / 2019-10-08
|
96
185
|
[Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.8.3...v3.9.0)
|
97
186
|
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# rspec-rails [![
|
1
|
+
# rspec-rails [![Code Climate][]][code-climate] [![Gem Version][]][gem-version]
|
2
2
|
|
3
3
|
`rspec-rails` brings the [RSpec][] testing framework to [Ruby on Rails][]
|
4
4
|
as a drop-in alternative to its default testing framework, Minitest.
|
@@ -8,9 +8,13 @@ They’re also specifications (or _specs,_ for short):
|
|
8
8
|
detailed explanations of how the application is supposed to behave,
|
9
9
|
expressed in plain English.
|
10
10
|
|
11
|
-
|
11
|
+
According to [RSpec Rails new versioning strategy][] use:
|
12
|
+
* **[`rspec-rails` 5.x][]** for Rails 6.x.
|
13
|
+
* **[`rspec-rails` 4.x][]** for Rails from 5.x or 6.x.
|
14
|
+
* **[`rspec-rails` 3.x][]** for Rails earlier than 5.0.
|
15
|
+
* **[`rspec-rails` 1.x][]** for Rails 2.x.
|
12
16
|
|
13
|
-
[Build Status]: https://secure.travis-ci.org/rspec/rspec-rails.svg?branch=
|
17
|
+
[Build Status]: https://secure.travis-ci.org/rspec/rspec-rails.svg?branch=main
|
14
18
|
[travis-ci]: https://travis-ci.org/rspec/rspec-rails
|
15
19
|
[Code Climate]: https://codeclimate.com/github/rspec/rspec-rails.svg
|
16
20
|
[code-climate]: https://codeclimate.com/github/rspec/rspec-rails
|
@@ -19,23 +23,30 @@ Use **[`rspec-rails` 1.x][]** for Rails 2.x.
|
|
19
23
|
[RSpec]: https://rspec.info/
|
20
24
|
[Ruby on Rails]: https://rubyonrails.org/
|
21
25
|
[`rspec-rails` 1.x]: https://github.com/dchelimsky/rspec-rails
|
26
|
+
[`rspec-rails` 3.x]: https://github.com/rspec/rspec-rails/tree/3-9-maintenance
|
27
|
+
[`rspec-rails` 4.x]: https://github.com/rspec/rspec-rails/tree/4-1-maintenance
|
28
|
+
[`rspec-rails` 5.x]: https://github.com/rspec/rspec-rails/tree/5-0-maintenance
|
29
|
+
[RSpec Rails new versioning strategy]: https://github.com/rspec/rspec-rails/blob/main/rfcs/versioning-strategy.md
|
22
30
|
|
23
31
|
## Installation
|
24
32
|
|
33
|
+
**IMPORTANT** This README / branch refers to the current development build.
|
34
|
+
See the [`5-0-maintenance` branch on Github](https://github.com/rspec/rspec-rails/tree/5-0-maintenance) if you want or require the latest stable release.
|
35
|
+
|
25
36
|
1. Add `rspec-rails` to **both** the `:development` and `:test` groups
|
26
37
|
of your app’s `Gemfile`:
|
27
38
|
|
28
39
|
```ruby
|
29
|
-
# Run against
|
40
|
+
# Run against this stable release
|
30
41
|
group :development, :test do
|
31
|
-
gem 'rspec-rails', '~>
|
42
|
+
gem 'rspec-rails', '~> 5.0.0'
|
32
43
|
end
|
33
44
|
|
34
|
-
# Or, run against the
|
35
|
-
# (requires
|
45
|
+
# Or, run against the main branch
|
46
|
+
# (requires main-branch versions of all related RSpec libraries)
|
36
47
|
group :development, :test do
|
37
48
|
%w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib|
|
38
|
-
gem lib, git: "https://github.com/rspec/#{lib}.git", branch: '
|
49
|
+
gem lib, git: "https://github.com/rspec/#{lib}.git", branch: 'main'
|
39
50
|
end
|
40
51
|
end
|
41
52
|
```
|
@@ -182,17 +193,17 @@ In addition to [the matchers that come standard in RSpec][],
|
|
182
193
|
here are some extras that make it easier
|
183
194
|
to test the various parts of a Rails system:
|
184
195
|
|
185
|
-
| RSpec matcher | Delegates to
|
186
|
-
| ------------------------ |
|
187
|
-
| [`be_a_new`][] |
|
188
|
-
| [`render_template`][] | `assert_template`
|
189
|
-
| [`redirect_to`][] | `assert_redirect`
|
190
|
-
| [`route_to`] | `
|
191
|
-
| [`be_routable`] |
|
192
|
-
| [`have_http_status`][] |
|
193
|
-
| [`match_array`][] |
|
194
|
-
| [`have_been_enqueued`][] |
|
195
|
-
| [`have_enqueued_job`][] |
|
196
|
+
| RSpec matcher | Delegates to | Available in | Notes |
|
197
|
+
| ------------------------ | ------------------- | ------------------------------- | -------------------------------------------------------- |
|
198
|
+
| [`be_a_new`][] | | all | primarily intended for controller specs |
|
199
|
+
| [`render_template`][] | `assert_template` | request / controller / view | use with `expect(response).to` |
|
200
|
+
| [`redirect_to`][] | `assert_redirect` | request / controller | use with `expect(response).to` |
|
201
|
+
| [`route_to`] | `assert_recognizes` | routing / controller | use with `expect(...).to route_to` |
|
202
|
+
| [`be_routable`] | | routing / controller | use with `expect(...).not_to be_routable` |
|
203
|
+
| [`have_http_status`][] | | request / controller / feature | |
|
204
|
+
| [`match_array`][] | | all | for comparing arrays of ActiveRecord objects |
|
205
|
+
| [`have_been_enqueued`][] | | all | requires config: `ActiveJob::Base.queue_adapter = :test` |
|
206
|
+
| [`have_enqueued_job`][] | | all | requires config: `ActiveJob::Base.queue_adapter = :test` |
|
196
207
|
|
197
208
|
Follow the links above for examples of how each matcher is used.
|
198
209
|
|
@@ -222,18 +233,18 @@ Each one inherits from one of Rails’ built-in `TestCase` classes,
|
|
222
233
|
meaning the helper methods provided by default in Rails tests
|
223
234
|
are available in RSpec, as well.
|
224
235
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
236
|
+
| Spec type | Corresponding Rails test class |
|
237
|
+
| -------------- | -------------------------------- |
|
238
|
+
| [model][] | |
|
239
|
+
| [controller][] | [`ActionController::TestCase`][] |
|
240
|
+
| [mailer][] | `ActionMailer::TestCase` |
|
241
|
+
| [job][] | |
|
242
|
+
| [view][] | `ActionView::TestCase` |
|
243
|
+
| [routing][] | |
|
244
|
+
| [helper][] | `ActionView::TestCase` |
|
245
|
+
| [request][] | [`ActionDispatch::IntegrationTest`][] |
|
246
|
+
| [feature][] | |
|
247
|
+
| [system][] | [`ActionDispatch::SystemTestCase`][] |
|
237
248
|
|
238
249
|
Follow the links above to see examples of each spec type,
|
239
250
|
or for official Rails API documentation on the given `TestCase` class.
|
@@ -16,7 +16,7 @@ module Rspec
|
|
16
16
|
return unless options[:request_specs]
|
17
17
|
|
18
18
|
template 'request_spec.rb',
|
19
|
-
File.join('spec/requests', class_path, "#{file_name}
|
19
|
+
File.join('spec/requests', class_path, "#{file_name}_spec.rb")
|
20
20
|
end
|
21
21
|
|
22
22
|
def generate_controller_spec
|
@@ -27,7 +27,7 @@ module Rspec
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def generate_view_specs
|
30
|
-
return if actions.empty?
|
30
|
+
return if actions.empty? && behavior == :invoke
|
31
31
|
return unless options[:view_specs] && options[:template_engine]
|
32
32
|
|
33
33
|
empty_directory File.join("spec", "views", file_path)
|
@@ -1,7 +1,12 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
RSpec.describe "<%= class_name.pluralize %>", <%= type_metatag(:request) %> do
|
4
|
-
<% namespaced_path = regular_class_path.join('/')
|
4
|
+
<% namespaced_path = regular_class_path.join('/') -%>
|
5
|
+
<% if actions.empty? -%>
|
6
|
+
describe "GET /index" do
|
7
|
+
pending "add some examples (or delete) #{__FILE__}"
|
8
|
+
end
|
9
|
+
<% end -%>
|
5
10
|
<% for action in actions -%>
|
6
11
|
describe "GET /<%= action %>" do
|
7
12
|
it "returns http success" do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
2
|
require 'spec_helper'
|
3
3
|
ENV['RAILS_ENV'] ||= 'test'
|
4
|
-
|
4
|
+
require_relative '../config/environment'
|
5
5
|
# Prevent database truncation if the environment is production
|
6
6
|
abort("The Rails environment is running in production mode!") if Rails.env.production?
|
7
7
|
require 'rspec/rails'
|
@@ -5,7 +5,8 @@ module Rspec
|
|
5
5
|
# @private
|
6
6
|
class JobGenerator < Base
|
7
7
|
def create_job_spec
|
8
|
-
|
8
|
+
file_suffix = file_name.end_with?('job') ? 'spec.rb' : 'job_spec.rb'
|
9
|
+
template 'job_spec.rb.erb', File.join('spec/jobs', class_path, [file_name, file_suffix].join('_'))
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rails_helper'
|
2
2
|
|
3
3
|
<% module_namespacing do -%>
|
4
|
-
RSpec.describe <%= class_name
|
4
|
+
RSpec.describe <%= class_name %><%= "Job" unless class_name.end_with?("Job")%>, <%= type_metatag(:job) %> do
|
5
5
|
pending "add some examples to (or delete) #{__FILE__}"
|
6
6
|
end
|
7
7
|
<% end -%>
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require "rails_helper"
|
2
2
|
|
3
3
|
<% module_namespacing do -%>
|
4
|
-
RSpec.describe <%=
|
4
|
+
RSpec.describe <%= class_name.sub(/(Mailer)?$/, 'Mailer') %>, <%= type_metatag(:mailer) %> do
|
5
5
|
<% for action in actions -%>
|
6
6
|
describe "<%= action %>" do
|
7
|
-
let(:mail) { <%=
|
7
|
+
let(:mail) { <%= class_name.sub(/(Mailer)?$/, 'Mailer') %>.<%= action %> }
|
8
8
|
|
9
9
|
it "renders the headers" do
|
10
10
|
expect(mail.subject).to eq(<%= action.to_s.humanize.inspect %>)
|
@@ -5,7 +5,7 @@ class <%= class_name %>Preview < ActionMailer::Preview
|
|
5
5
|
|
6
6
|
# Preview this email at http://localhost:3000/rails/mailers/<%= file_path %>/<%= action %>
|
7
7
|
def <%= action %>
|
8
|
-
<%=
|
8
|
+
<%= class_name.sub(/(Mailer)?$/, 'Mailer') %>.<%= action %>
|
9
9
|
end
|
10
10
|
<% end -%>
|
11
11
|
|
@@ -64,21 +64,21 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
|
|
64
64
|
context "with valid params" do
|
65
65
|
it "creates a new <%= class_name %>" do
|
66
66
|
expect {
|
67
|
-
post :create, params: {<%=
|
67
|
+
post :create, params: {<%= singular_table_name %>: valid_attributes}, session: valid_session
|
68
68
|
}.to change(<%= class_name %>, :count).by(1)
|
69
69
|
end
|
70
70
|
|
71
|
-
it "renders a JSON response with the new <%=
|
72
|
-
post :create, params: {<%=
|
71
|
+
it "renders a JSON response with the new <%= singular_table_name %>" do
|
72
|
+
post :create, params: {<%= singular_table_name %>: valid_attributes}, session: valid_session
|
73
73
|
expect(response).to have_http_status(:created)
|
74
74
|
expect(response.content_type).to eq('application/json')
|
75
|
-
expect(response.location).to eq(<%=
|
75
|
+
expect(response.location).to eq(<%= singular_table_name %>_url(<%= class_name %>.last))
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
79
|
context "with invalid params" do
|
80
|
-
it "renders a JSON response with errors for the new <%=
|
81
|
-
post :create, params: {<%=
|
80
|
+
it "renders a JSON response with errors for the new <%= singular_table_name %>" do
|
81
|
+
post :create, params: {<%= singular_table_name %>: invalid_attributes}, session: valid_session
|
82
82
|
expect(response).to have_http_status(:unprocessable_entity)
|
83
83
|
expect(response.content_type).to eq('application/json')
|
84
84
|
end
|
@@ -91,25 +91,25 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
|
|
91
91
|
skip("Add a hash of attributes valid for your model")
|
92
92
|
}
|
93
93
|
|
94
|
-
it "updates the requested <%=
|
94
|
+
it "updates the requested <%= singular_table_name %>" do
|
95
95
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
96
|
-
put :update, params: {id: <%= file_name %>.to_param, <%=
|
96
|
+
put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>: new_attributes}, session: valid_session
|
97
97
|
<%= file_name %>.reload
|
98
98
|
skip("Add assertions for updated state")
|
99
99
|
end
|
100
100
|
|
101
|
-
it "renders a JSON response with the <%=
|
101
|
+
it "renders a JSON response with the <%= singular_table_name %>" do
|
102
102
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
103
|
-
put :update, params: {id: <%= file_name %>.to_param, <%=
|
103
|
+
put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>: new_attributes}, session: valid_session
|
104
104
|
expect(response).to have_http_status(:ok)
|
105
105
|
expect(response.content_type).to eq('application/json')
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
109
|
context "with invalid params" do
|
110
|
-
it "renders a JSON response with errors for the <%=
|
110
|
+
it "renders a JSON response with errors for the <%= singular_table_name %>" do
|
111
111
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
112
|
-
put :update, params: {id: <%= file_name %>.to_param, <%=
|
112
|
+
put :update, params: {id: <%= file_name %>.to_param, <%= singular_table_name %>: invalid_attributes}, session: valid_session
|
113
113
|
expect(response).to have_http_status(:unprocessable_entity)
|
114
114
|
expect(response.content_type).to eq('application/json')
|
115
115
|
end
|
@@ -117,7 +117,7 @@ RSpec.describe <%= controller_class_name %>Controller, <%= type_metatag(:control
|
|
117
117
|
end
|
118
118
|
|
119
119
|
describe "DELETE #destroy" do
|
120
|
-
it "destroys the requested <%=
|
120
|
+
it "destroys the requested <%= singular_table_name %>" do
|
121
121
|
<%= file_name %> = <%= class_name %>.create! valid_attributes
|
122
122
|
expect {
|
123
123
|
delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session
|