rspec-rails 4.0.0.beta4 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/Capybara.md +5 -54
  5. data/Changelog.md +72 -37
  6. data/README.md +23 -18
  7. data/lib/generators/rspec/controller/controller_generator.rb +1 -1
  8. data/lib/generators/rspec/controller/templates/request_spec.rb +6 -1
  9. data/lib/generators/rspec/{generators → generator}/generator_generator.rb +2 -2
  10. data/lib/generators/rspec/{generators → generator}/templates/generator_spec.rb +0 -0
  11. data/lib/generators/rspec/install/templates/spec/rails_helper.rb +15 -1
  12. data/lib/generators/rspec/scaffold/scaffold_generator.rb +18 -10
  13. data/lib/generators/rspec/scaffold/templates/api_request_spec.rb +131 -0
  14. data/lib/generators/rspec/scaffold/templates/request_spec.rb +137 -0
  15. data/lib/rspec-rails.rb +2 -2
  16. data/lib/rspec/rails/adapters.rb +3 -3
  17. data/lib/rspec/rails/configuration.rb +40 -4
  18. data/lib/rspec/rails/example/channel_example_group.rb +2 -2
  19. data/lib/rspec/rails/example/feature_example_group.rb +5 -23
  20. data/lib/rspec/rails/example/mailbox_example_group.rb +1 -1
  21. data/lib/rspec/rails/example/mailer_example_group.rb +2 -2
  22. data/lib/rspec/rails/example/system_example_group.rb +8 -4
  23. data/lib/rspec/rails/example/view_example_group.rb +1 -1
  24. data/lib/rspec/rails/extensions/active_record/proxy.rb +4 -1
  25. data/lib/rspec/rails/fixture_file_upload_support.rb +7 -12
  26. data/lib/rspec/rails/fixture_support.rb +38 -27
  27. data/lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb +3 -3
  28. data/lib/rspec/rails/matchers/active_job.rb +31 -5
  29. data/lib/rspec/rails/matchers/have_enqueued_mail.rb +4 -4
  30. data/lib/rspec/rails/matchers/relation_match_array.rb +1 -1
  31. data/lib/rspec/rails/matchers/routing_matchers.rb +2 -2
  32. data/lib/rspec/rails/tasks/rspec.rake +4 -4
  33. data/lib/rspec/rails/vendor/capybara.rb +0 -5
  34. data/lib/rspec/rails/version.rb +1 -1
  35. metadata +30 -28
  36. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51903b359e44b4d8c3323a4af3caa9de3495e02009b61da605af24d7ae588b0b
4
- data.tar.gz: 11e9ff4ad45a88a32e9f0a4294cd6c8f7c75febd5ba07c1382fed86ebdcd64aa
3
+ metadata.gz: 4cfb82b177fd4c881bb331fe78d7c0c7e974d8e886050b67db824aa4e4a93ab2
4
+ data.tar.gz: 1c55d80deaeab9a57af17b7b4c219490be2141c55d04fef428daa4a09fc3fd4f
5
5
  SHA512:
6
- metadata.gz: 8e9b40e1404bb29508e00c460db05b7d499ca86daa332cbe3e517dfd922ec860302023e6f71e15e7445f07c7eb39979306cd98ef296b7794ae2c87e3d5865b59
7
- data.tar.gz: bb8b7f0411f6d1eff0550b952117bbd58aa59ca082c54d2a145e808fc14a400de0885bb8a8b5503b04baef787527b50a08054e471444123e433d3138c8b45fe1
6
+ metadata.gz: 346b1d7428910e9b79881fa6a5ad616521fe6615c058ba559aa11136929e9f3ec7601d76e8a200123c74708f147d49c665b0fc649cf76a10f8b4ae55e734c6c0
7
+ data.tar.gz: 10478159e4622f40869d46fb36ab8a4472d469b2547bb54238164244511326393a3b66f7568787d0419aeac70fcb24942352f1f3fcdaede273070aa609b12cfc
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/Capybara.md CHANGED
@@ -1,58 +1,19 @@
1
1
  rspec-rails supports integration with Capybara out of the box by adding
2
2
  its Capybara::DSL (visit/page) and Capybara::RSpecMatchers to the
3
- examples in the applicable directories, which differ slightly between
4
- Capybara 1.x and Capybara >= 2.x.
3
+ examples in the applicable directories.
5
4
 
6
5
  ## Capybara::DSL
7
6
 
8
7
  Adds the `visit` and `page` methods, which work together to simulate a
9
8
  GET request and provide access to the result (via `page`).
10
9
 
11
- ## Capybara::RSpecMatchers
12
-
13
- Exposes matchers used to specify expected HTML content (e.g. `should_not have_selector` will work correctly).
14
-
15
- ## Capybara 1.x
16
-
17
- Capybara::DSL is added to examples in:
18
-
19
- * spec/requests # included by Capybara
20
- * spec/controllers
21
-
22
- Capybara::RSpecMatchers is added to examples in:
23
-
24
- * spec/requests # included by Capybara
25
- * spec/controllers
26
- * spec/views
27
- * spec/helpers
28
- * spec/mailers
29
-
30
- ## Capybara 2.0
31
-
32
- To use Capybara 2.0, you need rspec-rails-2.11.1 or greater.
33
-
34
10
  Capybara::DSL is added to examples in:
35
11
 
36
12
  * spec/features
37
13
 
38
- Capybara::RSpecMatchers is added to examples in:
39
-
40
- * spec/features
41
- * spec/controllers
42
- * spec/views
43
- * spec/helpers
44
- * spec/mailers
45
-
46
- ## Upgrading to Capybara-2.0
47
-
48
- Many users have been confused by the co-existence of the the
49
- Capybara::DSL (visit/page) alongside the rack-test DSL
50
- (get|post|put|delete|head/response.body) in examples in spec/requests
51
- and spec/controllers. As of rspec-rails-2.11.1 and capybara-2.0.0.beta2, these
52
- are separated as follows:
14
+ ## Capybara::RSpecMatchers
53
15
 
54
- * Capybara::DSL is included `spec/features`
55
- * rack-test DSL is included in `spec/requests` and `spec/controllers`
16
+ Exposes matchers used to specify expected HTML content (e.g. `should_not have_selector` will work correctly).
56
17
 
57
18
  Capybara::RSpecMatchers is added to examples in:
58
19
 
@@ -62,16 +23,6 @@ Capybara::RSpecMatchers is added to examples in:
62
23
  * spec/helpers
63
24
  * spec/mailers
64
25
 
65
- If you're upgrading to Capybara-2.0 and you used visit/page in
66
- spec/requests you'll want to move those examples to spec/features and
67
- they should just work.
68
-
69
- If you want to leave those examples in spec/requests, you can include
70
- Capybara::DSL in those examples yourself as follows, but this is
71
- absolutely not recommended as you will be overriding the intended
72
- behavior and accepting the risks associated with doing so:
26
+ ## Upgrading to Capybara-3.x
73
27
 
74
- # not recommended!
75
- RSpec.configure do |c|
76
- c.include Capybara::DSL, file_path: "spec/requests"
77
- end
28
+ Consult the official [Upgrading from Capybara 2.x to 3.x](https://github.com/teamcapybara/capybara/blob/master/UPGRADING.md#upgrading-from-capybara-2x-to-3x) guide.
data/Changelog.md CHANGED
@@ -1,28 +1,50 @@
1
- ### 4.0.0.beta4
2
- [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.0.beta3...v4.0.0.beta4)
1
+ ### 4.1.0 / 2021-03-06
2
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.2...v4.1.0)
3
3
 
4
4
  Enhancements:
5
5
 
6
- * Add argument matcher support to `have_enqueued_*` matchers. (Phil Pirozhkov, #2206)
7
- * Switch generated templates to use ruby 1.9 hash keys. (Tanbir Hasan, #2224)
8
- * Add `have_been_performed`/`have_performed_job`/`perform_job` ActiveJob
9
- matchers (Isaac Seymour, #1785)
10
- * Default to generating request specs rather than controller specs when
11
- generating a controller (Luka Lüdicke, #2222)
6
+ * Issue a warning when using job matchers with `#at` mis-match on `usec` precision.
7
+ (Jon Rowe, #2350)
8
+ * Generated request specs now have a bare `_spec` suffix instead of `request_spec`.
9
+ (Eloy Espinaco, Luka Lüdicke, #2355, #2356, #2378)
10
+ * Generated scaffold now includes engine route helpers when inside a mountable engine.
11
+ (Andrew W. Lee, #2372)
12
+ * Improve request spec "controller" scafold when no action is specified.
13
+ (Thomas Hareau, #2399)
14
+ * Introduce testing snippets concept (Phil Pirozhkov, Benoit Tigeot, #2423)
15
+ * Prevent collisions with `let(:name)` for Rails 6.1 and `let(:method_name)` on older
16
+ Rails. (Benoit Tigeot, #2461)
17
+
18
+ ### 4.0.2 / 2020-12-26
19
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.1...v4.0.2)
12
20
 
13
21
  Bug Fixes:
14
22
 
15
- * Prevent `driven_by(:selenium)` being called due to hook precedence.
16
- (Takumi Shotoku, #2188)
17
- * Prevent a `WrongScopeError` being thrown during loading fixtures on Rails
18
- 6.1 development version. (Edouard Chin, #2215)
19
- * Fix Mocha mocking support with `should`. (Phil Pirozhkov, #2256)
23
+ * Indent all extra failure lines output from system specs. (Alex Robbin, #2321)
24
+ * Generated request spec for update now uses the correct let. (Paul Hanyzewski, #2344)
25
+ * Return `true`/`false` from predicate methods in config rather than raw values.
26
+ (Phil Pirozhkov, Jon Rowe, #2353, #2354)
27
+ * Remove old #fixture_path feature detection code which broke under newer Rails.
28
+ (Koen Punt, Jon Rowe, #2370)
29
+
30
+ ### 4.0.1 / 2020-05-16
31
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.0...v4.0.1)
32
+
33
+ Bug Fixes:
34
+
35
+ * Remove warning when calling `driven_by` in system specs. (Aubin Lorieux, #2302)
36
+ * Fix comparison of times for `#at` in job matchers. (Jon Rowe, Markus Doits, #2304)
37
+ * Allow `have_enqueued_mail` to match when a sub class of `ActionMailer::DeliveryJob`
38
+ is set using `<Class>.delivery_job=`. (Atsushi Yoshida #2305)
39
+ * Restore Ruby 2.2.x compatibility. (Jon Rowe, #2332)
40
+ * Add `required_ruby_version` to gem spec. (Marc-André Lafortune, #2319, #2338)
20
41
 
21
- ### 4.0.0.beta3
22
- [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.0.beta2...v4.0.0.beta3)
42
+ ### 4.0.0 / 2020-03-24
43
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.9.1...v4.0.0)
23
44
 
24
45
  Enhancements:
25
46
 
47
+ * Adds support for Rails 6. (Penelope Phippen, Benoit Tigeot, Jon Rowe, #2071)
26
48
  * Adds support for JRuby on Rails 5.2 and 6
27
49
  * Add support for parameterised mailers (Ignatius Reza, #2125)
28
50
  * Add ActionMailbox spec helpers and test type (James Dabbs, #2119)
@@ -33,28 +55,18 @@ Enhancements:
33
55
  * Improve path parsing in view specs render options. (John Hawthorn, #2115)
34
56
  * Add routing spec template as an option for generating controller specs.
35
57
  (David Revelo, #2134)
36
-
37
- Bug Fixes:
38
-
39
- * Replace `before_teardown` as well as `after_teardown` to ensure screenshots
40
- are generated correctly. (Jon Rowe, #2164)
41
- * `ActionView::FixtureResolver#hash` has been renamed to `ActionView::FixtureResolver#data`.
42
- (Penelope Phippen, #2076)
43
- * Add missing require for `have_enqueued_mail` matcher. (Ignatius Reza, #2117)
44
-
45
- ### 4.0.0.beta2
46
- [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.0.beta1...v4.0.0.beta2)
47
-
48
- Bug Fixes:
49
-
50
- * Fix version dependencies in gemspec.
51
-
52
- ### 4.0.0.beta1
53
- [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.9.0...v4.0.0.beta1)
54
-
55
- Enhancements:
56
-
57
- * Adds support for Rails 6. (Penelope Phippen, Benoit Tigeot, Jon Rowe, #2071)
58
+ * Add argument matcher support to `have_enqueued_*` matchers. (Phil Pirozhkov, #2206)
59
+ * Switch generated templates to use ruby 1.9 hash keys. (Tanbir Hasan, #2224)
60
+ * Add `have_been_performed`/`have_performed_job`/`perform_job` ActiveJob
61
+ matchers (Isaac Seymour, #1785)
62
+ * Default to generating request specs rather than controller specs when
63
+ generating a controller (Luka Lüdicke, #2222)
64
+ * Allow `ActiveJob` matchers `#on_queue` modifier to take symbolic queue names. (Nils Sommer, #2283)
65
+ * The scaffold generator now generates request specs in preference to controller specs.
66
+ (Luka Lüdicke, #2288)
67
+ * Add configuration option to disable ActiveRecord. (Jon Rowe, Phil Pirozhkov, Hermann Mayer, #2266)
68
+ * Set `ActionDispatch::SystemTesting::Server.silence_puma = true` when running system specs.
69
+ (ta1kt0me, Benoit Tigeot, #2289)
58
70
 
59
71
  Bug Fixes:
60
72
 
@@ -64,12 +76,35 @@ Bug Fixes:
64
76
  deprecated. (Pavel Rosický, #2092)
65
77
  * `ActionView::Template#formats` has been deprecated and replaced by
66
78
  `ActionView::Template#format`(Seb Jacobs, #2100)
79
+ * Replace `before_teardown` as well as `after_teardown` to ensure screenshots
80
+ are generated correctly. (Jon Rowe, #2164)
81
+ * `ActionView::FixtureResolver#hash` has been renamed to `ActionView::FixtureResolver#data`.
82
+ (Penelope Phippen, #2076)
83
+ * Prevent `driven_by(:selenium)` being called due to hook precedence.
84
+ (Takumi Shotoku, #2188)
85
+ * Prevent a `WrongScopeError` being thrown during loading fixtures on Rails
86
+ 6.1 development version. (Edouard Chin, #2215)
87
+ * Fix Mocha mocking support with `should`. (Phil Pirozhkov, #2256)
88
+ * Restore previous conditional check for setting `default_url_options` in feature
89
+ specs, prevents a `NoMethodError` in some scenarios. (Eugene Kenny, #2277)
90
+ * Allow changing `ActiveJob::Base.queue_adapter` inside a system spec.
91
+ (Jonathan Rochkind, #2242)
92
+ * `rails generate generator` command now creates related spec file (Joel Azemar, #2217)
93
+ * Relax upper `capybara` version constraint to allow for Capybara 3.x (Phil Pirozhkov, #2281)
94
+ * Clear ActionMailer test mailbox after each example (Benoit Tigeot, #2293)
67
95
 
68
96
  Breaking Changes:
69
97
 
70
98
  * Drops support for Rails below 5.0
71
99
  * Drops support for Ruby below 2.3
72
100
 
101
+ ### 3.9.1 / 2020-03-10
102
+ [Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.9.0...v3.9.1)
103
+
104
+ Bug Fixes:
105
+
106
+ * Add missing require for have_enqueued_mail matcher. (Ignatius Reza, #2117)
107
+
73
108
  ### 3.9.0 / 2019-10-08
74
109
  [Full Changelog](https://github.com/rspec/rspec-rails/compare/v3.8.3...v3.9.0)
75
110
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # rspec-rails [![Build Status][]][travis-ci] [![Code Climate][]][code-climate] [![Gem Version][]](gem-version)
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,10 @@ 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
+ Use **[`rspec-rails` 3.x][]** for Rails earlier than 5.0.
11
12
  Use **[`rspec-rails` 1.x][]** for Rails 2.x.
12
13
 
13
- [Build Status]: https://secure.travis-ci.org/rspec/rspec-rails.svg?branch=master
14
+ [Build Status]: https://secure.travis-ci.org/rspec/rspec-rails.svg?branch=main
14
15
  [travis-ci]: https://travis-ci.org/rspec/rspec-rails
15
16
  [Code Climate]: https://codeclimate.com/github/rspec/rspec-rails.svg
16
17
  [code-climate]: https://codeclimate.com/github/rspec/rspec-rails
@@ -19,23 +20,27 @@ Use **[`rspec-rails` 1.x][]** for Rails 2.x.
19
20
  [RSpec]: https://rspec.info/
20
21
  [Ruby on Rails]: https://rubyonrails.org/
21
22
  [`rspec-rails` 1.x]: https://github.com/dchelimsky/rspec-rails
23
+ [`rspec-rails` 3.x]: https://github.com/rspec/rspec-rails/tree/3-9-maintenance
22
24
 
23
25
  ## Installation
24
26
 
27
+ **IMPORTANT** This README / branch refers to the `4.1.x` series of releases.
28
+ See the [`main` branch on Github](https://github.com/rspec/rspec-rails/tree/main) for more up to date releases.
29
+
25
30
  1. Add `rspec-rails` to **both** the `:development` and `:test` groups
26
31
  of your app’s `Gemfile`:
27
32
 
28
33
  ```ruby
29
34
  # Run against the latest stable release
30
35
  group :development, :test do
31
- gem 'rspec-rails', '~> 4.0'
36
+ gem 'rspec-rails', '~> 4.1.0'
32
37
  end
33
38
 
34
- # Or, run against the master branch
35
- # (requires master-branch versions of all related RSpec libraries)
39
+ # Or, run against the main branch
40
+ # (requires main-branch versions of all related RSpec libraries)
36
41
  group :development, :test do
37
42
  %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: 'master'
43
+ gem lib, git: "https://github.com/rspec/#{lib}.git", branch: 'main'
39
44
  end
40
45
  end
41
46
  ```
@@ -182,17 +187,17 @@ In addition to [the matchers that come standard in RSpec][],
182
187
  here are some extras that make it easier
183
188
  to test the various parts of a Rails system:
184
189
 
185
- | RSpec matcher | Delegates to | Available in | Notes |
186
- | ------------------------ | ----------------- | ------------------------------- | -------------------------------------------------------- |
187
- | [`be_a_new`][] | | all | primarily intended for controller specs |
188
- | [`render_template`][] | `assert_template` | request / controller / view | use with `expect(response).to` |
189
- | [`redirect_to`][] | `assert_redirect` | request / controller | use with `expect(response).to` |
190
- | [`route_to`] | `assert_routing` | routing / controller | replaces `route_for` from version 1.x |
191
- | [`be_routable`] | | routing / controller | usu. for `expect(...).not_to be_routable` |
192
- | [`have_http_status`][] | | request / controller / feature | |
193
- | [`match_array`][] | | all | for comparing arrays of ActiveRecord objects |
194
- | [`have_been_enqueued`][] | | all | requires config: `ActiveJob::Base.queue_adapter = :test` |
195
- | [`have_enqueued_job`][] | | all | requires config: `ActiveJob::Base.queue_adapter = :test` |
190
+ | RSpec matcher | Delegates to | Available in | Notes |
191
+ | ------------------------ | ------------------- | ------------------------------- | -------------------------------------------------------- |
192
+ | [`be_a_new`][] | | all | primarily intended for controller specs |
193
+ | [`render_template`][] | `assert_template` | request / controller / view | use with `expect(response).to` |
194
+ | [`redirect_to`][] | `assert_redirect` | request / controller | use with `expect(response).to` |
195
+ | [`route_to`] | `assert_recognizes` | routing / controller | use with `expect(...).to route_to` |
196
+ | [`be_routable`] | | routing / controller | use with `expect(...).not_to be_routable` |
197
+ | [`have_http_status`][] | | request / controller / feature | |
198
+ | [`match_array`][] | | all | for comparing arrays of ActiveRecord objects |
199
+ | [`have_been_enqueued`][] | | all | requires config: `ActiveJob::Base.queue_adapter = :test` |
200
+ | [`have_enqueued_job`][] | | all | requires config: `ActiveJob::Base.queue_adapter = :test` |
196
201
 
197
202
  Follow the links above for examples of how each matcher is used.
198
203
 
@@ -361,7 +366,7 @@ you can run the specs and Cucumber features, or submit a pull request.
361
366
  ### Recommended third-party extensions
362
367
 
363
368
  * [FactoryBot](https://github.com/thoughtbot/factory_bot)
364
- * [Capybara](https://github.com/jnicklas/capybara)
369
+ * [Capybara](https://github.com/teamcapybara/capybara)
365
370
  (Included by default in Rails 5.1+.
366
371
  Note that [additional configuration is required][] to use the Capybara DSL
367
372
  anywhere other than system specs and feature specs.)
@@ -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}_request_spec.rb")
19
+ File.join('spec/requests', class_path, "#{file_name}_spec.rb")
20
20
  end
21
21
 
22
22
  def generate_controller_spec
@@ -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
@@ -3,8 +3,8 @@ require 'generators/rspec'
3
3
  module Rspec
4
4
  module Generators
5
5
  # @private
6
- class GeneratorsGenerator < Base
7
- class_option :generator_specs, type: :boolean, default: false, desc: "Generate generator specs"
6
+ class GeneratorGenerator < Base
7
+ class_option :generator_specs, type: :boolean, default: true, desc: "Generate generator specs"
8
8
 
9
9
  def generate_generator_spec
10
10
  return unless options[:generator_specs]
@@ -20,7 +20,7 @@ require 'rspec/rails'
20
20
  # directory. Alternatively, in the individual `*_spec.rb` files, manually
21
21
  # require only the support files necessary.
22
22
  #
23
- # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }
23
+ # Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
24
24
 
25
25
  <% if RSpec::Rails::FeatureCheck.has_active_record_migration? -%>
26
26
  # Checks for pending migrations and applies them before tests are run.
@@ -42,6 +42,20 @@ RSpec.configure do |config|
42
42
  # instead of true.
43
43
  config.use_transactional_fixtures = true
44
44
 
45
+ # You can uncomment this line to turn off ActiveRecord support entirely.
46
+ # config.use_active_record = false
47
+
48
+ <% else -%>
49
+ # Remove this line to enable support for ActiveRecord
50
+ config.use_active_record = false
51
+
52
+ # If you enable ActiveRecord support you should unncomment these lines,
53
+ # note if you'd prefer not to run each example within a transaction, you
54
+ # should set use_transactional_fixtures to false.
55
+ #
56
+ # config.fixture_path = "#{::Rails.root}/spec/fixtures"
57
+ # config.use_transactional_fixtures = true
58
+
45
59
  <% end -%>
46
60
  # RSpec Rails can automatically mix in different behaviours to your tests
47
61
  # based on their file location, for example enabling you to call `get` and
@@ -14,7 +14,8 @@ module Rspec
14
14
  class_option :singleton, type: :boolean, desc: "Supply to create a singleton controller"
15
15
  class_option :api, type: :boolean, desc: "Skip specs unnecessary for API-only apps"
16
16
 
17
- class_option :controller_specs, type: :boolean, default: true, desc: "Generate controller specs"
17
+ class_option :controller_specs, type: :boolean, default: false, desc: "Generate controller specs"
18
+ class_option :request_specs, type: :boolean, default: true, desc: "Generate request specs"
18
19
  class_option :view_specs, type: :boolean, default: true, desc: "Generate view specs"
19
20
  class_option :helper_specs, type: :boolean, default: true, desc: "Generate helper specs"
20
21
  class_option :routing_specs, type: :boolean, default: true, desc: "Generate routing specs"
@@ -27,15 +28,20 @@ module Rspec
27
28
  def generate_controller_spec
28
29
  return unless options[:controller_specs]
29
30
 
30
- template_file = File.join(
31
- 'spec/controllers',
32
- controller_class_path,
33
- "#{controller_file_name}_controller_spec.rb"
34
- )
35
31
  if options[:api]
36
- template 'api_controller_spec.rb', template_file
32
+ template 'api_controller_spec.rb', template_file(folder: 'controllers', suffix: '_controller')
33
+ else
34
+ template 'controller_spec.rb', template_file(folder: 'controllers', suffix: '_controller')
35
+ end
36
+ end
37
+
38
+ def generate_request_spec
39
+ return unless options[:request_specs]
40
+
41
+ if options[:api]
42
+ template 'api_request_spec.rb', template_file(folder: 'requests')
37
43
  else
38
- template 'controller_spec.rb', template_file
44
+ template 'request_spec.rb', template_file(folder: 'requests')
39
45
  end
40
46
  end
41
47
 
@@ -60,8 +66,6 @@ module Rspec
60
66
  template 'routing_spec.rb', template_file
61
67
  end
62
68
 
63
- hook_for :integration_tool, as: :integration
64
-
65
69
  protected
66
70
 
67
71
  attr_reader :generator_args
@@ -116,6 +120,10 @@ module Rspec
116
120
  end
117
121
  end
118
122
 
123
+ def template_file(folder:, suffix: '')
124
+ File.join('spec', folder, controller_class_path, "#{controller_file_name}#{suffix}_spec.rb")
125
+ end
126
+
119
127
  def banner
120
128
  self.class.banner
121
129
  end