rspec-rails 4.0.0.beta4 → 4.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51903b359e44b4d8c3323a4af3caa9de3495e02009b61da605af24d7ae588b0b
4
- data.tar.gz: 11e9ff4ad45a88a32e9f0a4294cd6c8f7c75febd5ba07c1382fed86ebdcd64aa
3
+ metadata.gz: 2cf0a532366cef497e1b49006e7091da23b57071c1c4748b91dc7e4fb1f1b382
4
+ data.tar.gz: 8ae957b352b26a7bec08b5c07aab62906d662996aba06398d19f036016b09477
5
5
  SHA512:
6
- metadata.gz: 8e9b40e1404bb29508e00c460db05b7d499ca86daa332cbe3e517dfd922ec860302023e6f71e15e7445f07c7eb39979306cd98ef296b7794ae2c87e3d5865b59
7
- data.tar.gz: bb8b7f0411f6d1eff0550b952117bbd58aa59ca082c54d2a145e808fc14a400de0885bb8a8b5503b04baef787527b50a08054e471444123e433d3138c8b45fe1
6
+ metadata.gz: c9992d5aea4659d31b69b48e741c87d50deb3df2151bef86adb6084a3b6feb421d20408d52b0157481dce4e9b0aef31ebdeacfa71efdb97bedc26f7f310f211e
7
+ data.tar.gz: f6f524c072df299e3566abcb99d603eafefe8edc47440bc13e31fa87cf84a2f325c7cd8519eeecedf8cee4c647cbbdccac806e1cc905f9c6068b38a84bfbf025
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -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.
@@ -1,3 +1,22 @@
1
+ ### 4.0.0.rc1 / 2020-03-13
2
+ [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.0.beta4...v4.0.0.rc1)
3
+
4
+ Enhancements:
5
+
6
+ * Allow `ActiveJob` matchers `#on_queue` modifier to take symbolic queue names. (Nils Sommer, #2283)
7
+ * The scaffold generator now generates request specs in preference to controller specs.
8
+ (Luka Lüdicke, #2288)
9
+ * Add configuration option to disable ActiveRecord. (Jon Rowe, Phil Pirozhkov, Hermann Mayer, #2266)
10
+
11
+ Bug Fixes:
12
+
13
+ * Restore previous conditional check for setting `default_url_options` in feature
14
+ specs, prevents a `NoMethodError` in some scenarios. (Eugene Kenny, #2277)
15
+ * Allow changing `ActiveJob::Base.queue_adapter` inside a system spec.
16
+ (Jonathan Rochkind, #2242)
17
+ * `rails generate generator` command now creates related spec file (Joel Azemar, #2217)
18
+ * Relax upper `capybara` version constraint to allow for Capybara 3.x (Phil Pirozhkov, #2281)
19
+
1
20
  ### 4.0.0.beta4
2
21
  [Full Changelog](https://github.com/rspec/rspec-rails/compare/v4.0.0.beta3...v4.0.0.beta4)
3
22
 
data/README.md CHANGED
@@ -361,7 +361,7 @@ you can run the specs and Cucumber features, or submit a pull request.
361
361
  ### Recommended third-party extensions
362
362
 
363
363
  * [FactoryBot](https://github.com/thoughtbot/factory_bot)
364
- * [Capybara](https://github.com/jnicklas/capybara)
364
+ * [Capybara](https://github.com/teamcapybara/capybara)
365
365
  (Included by default in Rails 5.1+.
366
366
  Note that [additional configuration is required][] to use the Capybara DSL
367
367
  anywhere other than system specs and feature specs.)
@@ -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
@@ -0,0 +1,131 @@
1
+ require 'rails_helper'
2
+
3
+ # This spec was generated by rspec-rails when you ran the scaffold generator.
4
+ # It demonstrates how one might use RSpec to test the controller code that
5
+ # was generated by Rails when you ran the scaffold generator.
6
+ #
7
+ # It assumes that the implementation code is generated by the rails scaffold
8
+ # generator. If you are using any extension libraries to generate different
9
+ # controller code, this generated spec may or may not pass.
10
+ #
11
+ # It only uses APIs available in rails and/or rspec-rails. There are a number
12
+ # of tools you can use to make these specs even more expressive, but we're
13
+ # sticking to rails and rspec-rails APIs to keep things simple and stable.
14
+
15
+ <% module_namespacing do -%>
16
+ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %> do
17
+ # This should return the minimal set of attributes required to create a valid
18
+ # <%= class_name %>. As you add validations to <%= class_name %>, be sure to
19
+ # adjust the attributes here as well.
20
+ let(:valid_attributes) {
21
+ skip("Add a hash of attributes valid for your model")
22
+ }
23
+
24
+ let(:invalid_attributes) {
25
+ skip("Add a hash of attributes invalid for your model")
26
+ }
27
+
28
+ # This should return the minimal set of values that should be in the headers
29
+ # in order to pass any filters (e.g. authentication) defined in
30
+ # <%= controller_class_name %>Controller, or in your router and rack
31
+ # middleware. Be sure to keep this updated too.
32
+ let(:valid_headers) {
33
+ {}
34
+ }
35
+
36
+ <% unless options[:singleton] -%>
37
+ describe "GET /index" do
38
+ it "renders a successful response" do
39
+ <%= class_name %>.create! valid_attributes
40
+ get <%= index_helper %>_url, headers: valid_headers, as: :json
41
+ expect(response).to be_successful
42
+ end
43
+ end
44
+ <% end -%>
45
+
46
+ describe "GET /show" do
47
+ it "renders a successful response" do
48
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
49
+ get <%= show_helper.tr('@', '') %>, as: :json
50
+ expect(response).to be_successful
51
+ end
52
+ end
53
+
54
+ describe "POST /create" do
55
+ context "with valid parameters" do
56
+ it "creates a new <%= class_name %>" do
57
+ expect {
58
+ post <%= index_helper %>_url,
59
+ params: { <%= ns_file_name %>: valid_attributes }, headers: valid_headers, as: :json
60
+ }.to change(<%= class_name %>, :count).by(1)
61
+ end
62
+
63
+ it "renders a JSON response with the new <%= ns_file_name %>" do
64
+ post <%= index_helper %>_url,
65
+ params: { <%= ns_file_name %>: valid_attributes }, headers: valid_headers, as: :json
66
+ expect(response).to have_http_status(:created)
67
+ expect(response.content_type).to match(a_string_including("application/json"))
68
+ end
69
+ end
70
+
71
+ context "with invalid parameters" do
72
+ it "does not create a new <%= class_name %>" do
73
+ expect {
74
+ post <%= index_helper %>_url,
75
+ params: { <%= ns_file_name %>: invalid_attributes }, as: :json
76
+ }.to change(<%= class_name %>, :count).by(0)
77
+ end
78
+
79
+ it "renders a JSON response with errors for the new <%= ns_file_name %>" do
80
+ post <%= index_helper %>_url,
81
+ params: { <%= ns_file_name %>: invalid_attributes }, headers: valid_headers, as: :json
82
+ expect(response).to have_http_status(:unprocessable_entity)
83
+ expect(response.content_type).to eq("application/json")
84
+ end
85
+ end
86
+ end
87
+
88
+ describe "PATCH /update" do
89
+ context "with valid parameters" do
90
+ let(:new_attributes) {
91
+ skip("Add a hash of attributes valid for your model")
92
+ }
93
+
94
+ it "updates the requested <%= ns_file_name %>" do
95
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
96
+ patch <%= show_helper.tr('@', '') %>,
97
+ params: { <%= singular_table_name %>: invalid_attributes }, headers: valid_headers, as: :json
98
+ <%= file_name %>.reload
99
+ skip("Add assertions for updated state")
100
+ end
101
+
102
+ it "renders a JSON response with the <%= ns_file_name %>" do
103
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
104
+ patch <%= show_helper.tr('@', '') %>,
105
+ params: { <%= singular_table_name %>: invalid_attributes }, headers: valid_headers, as: :json
106
+ expect(response).to have_http_status(:ok)
107
+ expect(response.content_type).to eq("application/json")
108
+ end
109
+ end
110
+
111
+ context "with invalid parameters" do
112
+ it "renders a JSON response with errors for the <%= ns_file_name %>" do
113
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
114
+ patch <%= show_helper.tr('@', '') %>,
115
+ params: { <%= singular_table_name %>: invalid_attributes }, headers: valid_headers, as: :json
116
+ expect(response).to have_http_status(:unprocessable_entity)
117
+ expect(response.content_type).to eq("application/json")
118
+ end
119
+ end
120
+ end
121
+
122
+ describe "DELETE /destroy" do
123
+ it "destroys the requested <%= ns_file_name %>" do
124
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
125
+ expect {
126
+ delete <%= show_helper.tr('@', '') %>, headers: valid_headers, as: :json
127
+ }.to change(<%= class_name %>, :count).by(-1)
128
+ end
129
+ end
130
+ end
131
+ <% end -%>
@@ -0,0 +1,133 @@
1
+ require 'rails_helper'
2
+
3
+ # This spec was generated by rspec-rails when you ran the scaffold generator.
4
+ # It demonstrates how one might use RSpec to test the controller code that
5
+ # was generated by Rails when you ran the scaffold generator.
6
+ #
7
+ # It assumes that the implementation code is generated by the rails scaffold
8
+ # generator. If you are using any extension libraries to generate different
9
+ # controller code, this generated spec may or may not pass.
10
+ #
11
+ # It only uses APIs available in rails and/or rspec-rails. There are a number
12
+ # of tools you can use to make these specs even more expressive, but we're
13
+ # sticking to rails and rspec-rails APIs to keep things simple and stable.
14
+
15
+ <% module_namespacing do -%>
16
+ RSpec.describe "/<%= name.underscore.pluralize %>", <%= type_metatag(:request) %> do
17
+ # <%= class_name %>. As you add validations to <%= class_name %>, be sure to
18
+ # adjust the attributes here as well.
19
+ let(:valid_attributes) {
20
+ skip("Add a hash of attributes valid for your model")
21
+ }
22
+
23
+ let(:invalid_attributes) {
24
+ skip("Add a hash of attributes invalid for your model")
25
+ }
26
+
27
+ <% unless options[:singleton] -%>
28
+ describe "GET /index" do
29
+ it "renders a successful response" do
30
+ <%= class_name %>.create! valid_attributes
31
+ get <%= index_helper %>_url
32
+ expect(response).to be_successful
33
+ end
34
+ end
35
+ <% end -%>
36
+
37
+ describe "GET /show" do
38
+ it "renders a successful response" do
39
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
40
+ get <%= show_helper.tr('@', '') %>
41
+ expect(response).to be_successful
42
+ end
43
+ end
44
+
45
+ describe "GET /new" do
46
+ it "renders a successful response" do
47
+ get <%= new_helper %>
48
+ expect(response).to be_successful
49
+ end
50
+ end
51
+
52
+ describe "GET /edit" do
53
+ it "render a successful response" do
54
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
55
+ get <%= edit_helper.tr('@','') %>
56
+ expect(response).to be_successful
57
+ end
58
+ end
59
+
60
+ describe "POST /create" do
61
+ context "with valid parameters" do
62
+ it "creates a new <%= class_name %>" do
63
+ expect {
64
+ post <%= index_helper %>_url, params: { <%= ns_file_name %>: valid_attributes }
65
+ }.to change(<%= class_name %>, :count).by(1)
66
+ end
67
+
68
+ it "redirects to the created <%= ns_file_name %>" do
69
+ post <%= index_helper %>_url, params: { <%= ns_file_name %>: valid_attributes }
70
+ expect(response).to redirect_to(<%= show_helper.gsub("\@#{file_name}", class_name+".last") %>)
71
+ end
72
+ end
73
+
74
+ context "with invalid parameters" do
75
+ it "does not create a new <%= class_name %>" do
76
+ expect {
77
+ post <%= index_helper %>_url, params: { <%= ns_file_name %>: invalid_attributes }
78
+ }.to change(<%= class_name %>, :count).by(0)
79
+ end
80
+
81
+ it "renders a successful response (i.e. to display the 'new' template)" do
82
+ post <%= index_helper %>_url, params: { <%= ns_file_name %>: invalid_attributes }
83
+ expect(response).to be_successful
84
+ end
85
+ end
86
+ end
87
+
88
+ describe "PATCH /update" do
89
+ context "with valid parameters" do
90
+ let(:new_attributes) {
91
+ skip("Add a hash of attributes valid for your model")
92
+ }
93
+
94
+ it "updates the requested <%= ns_file_name %>" do
95
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
96
+ patch <%= show_helper.tr('@', '') %>, params: { <%= singular_table_name %>: new_attributes }
97
+ <%= file_name %>.reload
98
+ skip("Add assertions for updated state")
99
+ end
100
+
101
+ it "redirects to the <%= ns_file_name %>" do
102
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
103
+ patch <%= show_helper.tr('@', '') %>, params: { <%= singular_table_name %>: new_attributes }
104
+ <%= file_name %>.reload
105
+ expect(response).to redirect_to(<%= singular_table_name %>_url(<%= file_name %>))
106
+ end
107
+ end
108
+
109
+ context "with invalid parameters" do
110
+ it "renders a successful response (i.e. to display the 'edit' template)" do
111
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
112
+ patch <%= show_helper.tr('@', '') %>, params: { <%= singular_table_name %>: invalid_attributes }
113
+ expect(response).to be_successful
114
+ end
115
+ end
116
+ end
117
+
118
+ describe "DELETE /destroy" do
119
+ it "destroys the requested <%= ns_file_name %>" do
120
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
121
+ expect {
122
+ delete <%= show_helper.tr('@', '') %>
123
+ }.to change(<%= class_name %>, :count).by(-1)
124
+ end
125
+
126
+ it "redirects to the <%= table_name %> list" do
127
+ <%= file_name %> = <%= class_name %>.create! valid_attributes
128
+ delete <%= show_helper.tr('@', '') %>
129
+ expect(response).to redirect_to(<%= index_helper %>_url)
130
+ end
131
+ end
132
+ end
133
+ <% end -%>
@@ -31,8 +31,8 @@ module RSpec
31
31
  # sets the default for the `preview_path`
32
32
  initializer "rspec_rails.action_mailer",
33
33
  before: "action_mailer.set_configs" do |app|
34
- setup_preview_path(app)
35
- end
34
+ setup_preview_path(app)
35
+ end
36
36
 
37
37
  private
38
38
 
@@ -146,9 +146,9 @@ module RSpec
146
146
  # examples without exposing non-assertion methods in Test::Unit or
147
147
  # Minitest.
148
148
  def assertion_method_names
149
- ::RSpec::Rails::Assertions.
150
- public_instance_methods.
151
- select do |m|
149
+ ::RSpec::Rails::Assertions
150
+ .public_instance_methods
151
+ .select do |m|
152
152
  m.to_s =~ /^(assert|flunk|refute)/
153
153
  end
154
154
  end
@@ -55,8 +55,7 @@ module RSpec
55
55
  end
56
56
 
57
57
  # @private
58
- # rubocop:disable Metrics/MethodLength
59
- def self.initialize_configuration(config)
58
+ def self.initialize_configuration(config) # rubocop:disable Metrics/MethodLength
60
59
  config.backtrace_exclusion_patterns << /vendor\//
61
60
  config.backtrace_exclusion_patterns << %r{lib/rspec/rails}
62
61
 
@@ -64,6 +63,7 @@ module RSpec
64
63
  config.add_setting :infer_base_class_for_anonymous_controllers, default: true
65
64
 
66
65
  # fixture support
66
+ config.add_setting :use_active_record, default: true
67
67
  config.add_setting :use_transactional_fixtures, alias_with: :use_transactional_examples
68
68
  config.add_setting :use_instantiated_fixtures
69
69
  config.add_setting :global_fixtures
@@ -151,7 +151,6 @@ module RSpec
151
151
  config.include RSpec::Rails::MailboxExampleGroup, type: :mailbox
152
152
  end
153
153
  end
154
- # rubocop:enable Metrics/MethodLength
155
154
 
156
155
  initialize_configuration RSpec.configuration
157
156
  end
@@ -34,7 +34,7 @@ if RSpec::Rails::FeatureCheck.has_action_cable_testing?
34
34
  next if klass <= ::ActionCable::Channel::Base
35
35
 
36
36
  raise "Described class is not a channel class.\n" \
37
- "Specify the channel class in the `describe` statement "\
37
+ "Specify the channel class in the `describe` statement " \
38
38
  "or set it manually using `tests MyChannelClass`"
39
39
  end
40
40
  end
@@ -45,7 +45,7 @@ if RSpec::Rails::FeatureCheck.has_action_cable_testing?
45
45
  next if klass <= ::ActionCable::Connection::Base
46
46
 
47
47
  raise "Described class is not a connection class.\n" \
48
- "Specify the connection class in the `describe` statement "\
48
+ "Specify the connection class in the `describe` statement " \
49
49
  "or set it manually using `tests MyConnectionClass`"
50
50
  end
51
51
  end
@@ -15,7 +15,9 @@ module RSpec
15
15
  include app.routes.url_helpers if app.routes.respond_to?(:url_helpers)
16
16
  include app.routes.mounted_helpers if app.routes.respond_to?(:mounted_helpers)
17
17
 
18
- default_url_options[:host] ||= ::RSpec::Rails::FeatureExampleGroup::DEFAULT_HOST
18
+ if respond_to?(:default_url_options)
19
+ default_url_options[:host] ||= ::RSpec::Rails::FeatureExampleGroup::DEFAULT_HOST
20
+ end
19
21
  end
20
22
  end
21
23
 
@@ -38,34 +40,14 @@ unless RSpec.respond_to?(:feature)
38
40
  capybara_feature: true,
39
41
  type: :feature,
40
42
  skip: <<-EOT.squish
41
- Feature specs require the Capybara (https://github.com/jnicklas/capybara)
42
- gem, version 2.2.0 or later. We recommend version 2.4.0 or later to avoid
43
- some deprecation warnings and have support for
44
- `config.expose_dsl_globally = false`.
43
+ Feature specs require the Capybara (https://github.com/teamcapybara/capybara)
44
+ gem, version 2.13.0 or later.
45
45
  EOT
46
46
  }
47
47
 
48
- # Capybara's monkey patching causes us to have to jump through some hoops
49
- top_level = self
50
- main_feature = nil
51
- if defined?(Capybara) && ::Capybara::VERSION.to_f < 2.4
52
- # Capybara 2.2 and 2.3 do not use `alias_example_xyz`
53
- opts[:skip] = <<-EOT.squish
54
- Capybara < 2.4.0 does not support RSpec's namespace or
55
- `config.expose_dsl_globally = false`. Upgrade to Capybara >= 2.4.0.
56
- EOT
57
- main_feature = top_level.method(:feature) if top_level.respond_to?(:feature)
58
- end
59
-
60
48
  RSpec.configure do |c|
61
- main_feature = nil unless c.expose_dsl_globally?
62
49
  c.alias_example_group_to :feature, opts
63
50
  c.alias_example_to :scenario
64
51
  c.alias_example_to :xscenario, skip: 'Temporarily skipped with xscenario'
65
52
  end
66
-
67
- # Due to load order issues and `config.expose_dsl_globally?` defaulting to
68
- # `true` we need to put Capybara's monkey patch method back. Otherwise,
69
- # app upgrades have a high likelyhood of having all feature specs skipped.
70
- top_level.define_singleton_method(:feature, &main_feature) if main_feature
71
53
  end
@@ -71,7 +71,6 @@ module RSpec
71
71
  original_after_teardown =
72
72
  ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:after_teardown)
73
73
 
74
- other.include ActionDispatch::IntegrationTest::Behavior
75
74
  other.include ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown
76
75
  other.include ::ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper
77
76
  other.include BlowAwayTeardownHooks
@@ -149,7 +149,7 @@ module RSpec
149
149
  # the original string.
150
150
  match = path_regex.match(_default_file_to_render)
151
151
 
152
- render_options = { template: match[:template] }
152
+ render_options = {template: match[:template]}
153
153
  render_options[:handlers] = [match[:handler]] if match[:handler]
154
154
  render_options[:formats] = [match[:format].to_sym] if match[:format]
155
155
  render_options[:locales] = [match[:locale]] if match[:locale]
@@ -10,42 +10,53 @@ module RSpec
10
10
  include ActiveRecord::TestFixtures
11
11
 
12
12
  included do
13
- self.fixture_path = RSpec.configuration.fixture_path
14
- if ::Rails::VERSION::STRING > '5'
15
- self.use_transactional_tests = RSpec.configuration.use_transactional_fixtures
16
- else
17
- self.use_transactional_fixtures = RSpec.configuration.use_transactional_fixtures
13
+ if RSpec.configuration.use_active_record?
14
+ include Fixtures
15
+
16
+ self.fixture_path = RSpec.configuration.fixture_path
17
+ if ::Rails::VERSION::STRING > '5'
18
+ self.use_transactional_tests = RSpec.configuration.use_transactional_fixtures
19
+ else
20
+ self.use_transactional_fixtures = RSpec.configuration.use_transactional_fixtures
21
+ end
22
+ self.use_instantiated_fixtures = RSpec.configuration.use_instantiated_fixtures
23
+
24
+ fixtures RSpec.configuration.global_fixtures if RSpec.configuration.global_fixtures
18
25
  end
19
- self.use_instantiated_fixtures = RSpec.configuration.use_instantiated_fixtures
26
+ end
20
27
 
21
- def self.fixtures(*args)
22
- orig_methods = private_instance_methods
23
- super.tap do
24
- new_methods = private_instance_methods - orig_methods
25
- new_methods.each do |method_name|
26
- proxy_method_warning_if_called_in_before_context_scope(method_name)
28
+ module Fixtures
29
+ extend ActiveSupport::Concern
30
+
31
+ class_methods do
32
+ def fixtures(*args)
33
+ orig_methods = private_instance_methods
34
+ super.tap do
35
+ new_methods = private_instance_methods - orig_methods
36
+ new_methods.each do |method_name|
37
+ proxy_method_warning_if_called_in_before_context_scope(method_name)
38
+ end
27
39
  end
28
40
  end
29
- end
30
41
 
31
- def self.proxy_method_warning_if_called_in_before_context_scope(method_name)
32
- orig_implementation = instance_method(method_name)
33
- define_method(method_name) do |*args, &blk|
34
- if inspect.include?("before(:context)")
35
- RSpec.warn_with("Calling fixture method in before :context ")
36
- else
37
- orig_implementation.bind(self).call(*args, &blk)
42
+ def proxy_method_warning_if_called_in_before_context_scope(method_name)
43
+ orig_implementation = instance_method(method_name)
44
+ define_method(method_name) do |*args, &blk|
45
+ if inspect.include?("before(:context)")
46
+ RSpec.warn_with("Calling fixture method in before :context ")
47
+ else
48
+ orig_implementation.bind(self).call(*args, &blk)
49
+ end
38
50
  end
39
51
  end
40
52
  end
41
53
 
42
54
  if ::Rails.version.to_f >= 6.1
55
+ # @private return the example name for TestFixtures
43
56
  def name
44
57
  @example
45
58
  end
46
59
  end
47
-
48
- fixtures RSpec.configuration.global_fixtures if RSpec.configuration.global_fixtures
49
60
  end
50
61
  end
51
62
  end
@@ -8,15 +8,15 @@ module RSpec
8
8
  def initialize(target, channel:)
9
9
  @target = target
10
10
  @channel = channel
11
- @block = Proc.new {}
11
+ @block = proc { }
12
12
  @data = nil
13
13
  set_expected_number(:exactly, 1)
14
14
  end
15
15
 
16
- def with(data = nil)
16
+ def with(data = nil, &block)
17
17
  @data = data
18
18
  @data = @data.with_indifferent_access if @data.is_a?(Hash)
19
- @block = Proc.new if block_given?
19
+ @block = block if block
20
20
  self
21
21
  end
22
22
 
@@ -15,7 +15,7 @@ module RSpec
15
15
  @args = []
16
16
  @queue = nil
17
17
  @at = nil
18
- @block = Proc.new {}
18
+ @block = proc { }
19
19
  set_expected_number(:exactly, 1)
20
20
  end
21
21
 
@@ -26,7 +26,7 @@ module RSpec
26
26
  end
27
27
 
28
28
  def on_queue(queue)
29
- @queue = queue
29
+ @queue = queue.to_s
30
30
  self
31
31
  end
32
32
 
@@ -93,7 +93,7 @@ module RSpec
93
93
  end
94
94
 
95
95
  def yield_mail_args(block)
96
- Proc.new { |*job_args| block.call(*(job_args - base_mailer_args)) }
96
+ proc { |*job_args| block.call(*(job_args - base_mailer_args)) }
97
97
  end
98
98
 
99
99
  def check_active_job_adapter
@@ -26,7 +26,7 @@ module RSpec
26
26
  path, query = *verb_to_path_map.values.first.split('?')
27
27
  @scope.assert_recognizes(
28
28
  @expected,
29
- { method: verb_to_path_map.keys.first, path: path },
29
+ {method: verb_to_path_map.keys.first, path: path},
30
30
  Rack::Utils.parse_nested_query(query)
31
31
  )
32
32
  end
@@ -115,7 +115,7 @@ module RSpec
115
115
  # Shorthand method for matching this type of route.
116
116
  %w[get post put patch delete options head].each do |method|
117
117
  define_method method do |path|
118
- { method.to_sym => path }
118
+ {method.to_sym => path}
119
119
  end
120
120
  end
121
121
  end
@@ -12,10 +12,10 @@ RSpec::Core::RakeTask.new(spec: "spec:prepare")
12
12
 
13
13
  namespace :spec do
14
14
  types = begin
15
- dirs = Dir['./spec/**/*_spec.rb'].
16
- map { |f| f.sub(/^\.\/(spec\/\w+)\/.*/, '\\1') }.
17
- uniq.
18
- select { |f| File.directory?(f) }
15
+ dirs = Dir['./spec/**/*_spec.rb']
16
+ .map { |f| f.sub(/^\.\/(spec\/\w+)\/.*/, '\\1') }
17
+ .uniq
18
+ .select { |f| File.directory?(f) }
19
19
  Hash[dirs.map { |d| [d.split('/').last, d] }]
20
20
  end
21
21
 
@@ -9,11 +9,6 @@ rescue LoadError
9
9
  end
10
10
 
11
11
  if defined?(Capybara)
12
- require 'rspec/support/comparable_version'
13
- unless RSpec::Support::ComparableVersion.new(Capybara::VERSION) >= '2.2.0'
14
- raise "You are using capybara #{Capybara::VERSION}. RSpec requires >= 2.2.0."
15
- end
16
-
17
12
  RSpec.configure do |c|
18
13
  if defined?(Capybara::DSL)
19
14
  c.include Capybara::DSL, type: :feature
@@ -3,7 +3,7 @@ module RSpec
3
3
  # Version information for RSpec Rails.
4
4
  module Version
5
5
  # Current version of RSpec Rails, in semantic versioning format.
6
- STRING = '4.0.0.beta4'
6
+ STRING = '4.0.0.rc1'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.beta4
4
+ version: 4.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chelimsky
@@ -44,10 +44,10 @@ cert_chain:
44
44
  ZsVDj6a7lH3cNqtWXZxrb2wO38qV5AkYj8SQK7Hj3/Yui9myUX3crr+PdetazSqQ
45
45
  F3MdtaDehhjC
46
46
  -----END CERTIFICATE-----
47
- date: 2020-01-12 00:00:00.000000000 Z
47
+ date: 2020-03-13 00:00:00.000000000 Z
48
48
  dependencies:
49
49
  - !ruby/object:Gem::Dependency
50
- name: activesupport
50
+ name: actionpack
51
51
  requirement: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - ">="
@@ -61,7 +61,7 @@ dependencies:
61
61
  - !ruby/object:Gem::Version
62
62
  version: '4.2'
63
63
  - !ruby/object:Gem::Dependency
64
- name: actionpack
64
+ name: activesupport
65
65
  requirement: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - ">="
@@ -145,19 +145,19 @@ dependencies:
145
145
  - !ruby/object:Gem::Version
146
146
  version: '3.9'
147
147
  - !ruby/object:Gem::Dependency
148
- name: cucumber
148
+ name: ammeter
149
149
  requirement: !ruby/object:Gem::Requirement
150
150
  requirements:
151
151
  - - "~>"
152
152
  - !ruby/object:Gem::Version
153
- version: 1.3.5
153
+ version: 1.1.2
154
154
  type: :development
155
155
  prerelease: false
156
156
  version_requirements: !ruby/object:Gem::Requirement
157
157
  requirements:
158
158
  - - "~>"
159
159
  - !ruby/object:Gem::Version
160
- version: 1.3.5
160
+ version: 1.1.2
161
161
  - !ruby/object:Gem::Dependency
162
162
  name: aruba
163
163
  requirement: !ruby/object:Gem::Requirement
@@ -173,19 +173,19 @@ dependencies:
173
173
  - !ruby/object:Gem::Version
174
174
  version: 0.14.12
175
175
  - !ruby/object:Gem::Dependency
176
- name: ammeter
176
+ name: cucumber
177
177
  requirement: !ruby/object:Gem::Requirement
178
178
  requirements:
179
179
  - - "~>"
180
180
  - !ruby/object:Gem::Version
181
- version: 1.1.2
181
+ version: 1.3.5
182
182
  type: :development
183
183
  prerelease: false
184
184
  version_requirements: !ruby/object:Gem::Requirement
185
185
  requirements:
186
186
  - - "~>"
187
187
  - !ruby/object:Gem::Version
188
- version: 1.1.2
188
+ version: 1.3.5
189
189
  description: rspec-rails is a testing framework for Rails 5+.
190
190
  email: rspec@googlegroups.com
191
191
  executables: []
@@ -209,8 +209,8 @@ files:
209
209
  - lib/generators/rspec/feature/feature_generator.rb
210
210
  - lib/generators/rspec/feature/templates/feature_singular_spec.rb
211
211
  - lib/generators/rspec/feature/templates/feature_spec.rb
212
- - lib/generators/rspec/generators/generator_generator.rb
213
- - lib/generators/rspec/generators/templates/generator_spec.rb
212
+ - lib/generators/rspec/generator/generator_generator.rb
213
+ - lib/generators/rspec/generator/templates/generator_spec.rb
214
214
  - lib/generators/rspec/helper/helper_generator.rb
215
215
  - lib/generators/rspec/helper/templates/helper_spec.rb
216
216
  - lib/generators/rspec/install/install_generator.rb
@@ -231,10 +231,12 @@ files:
231
231
  - lib/generators/rspec/request/request_generator.rb
232
232
  - lib/generators/rspec/scaffold/scaffold_generator.rb
233
233
  - lib/generators/rspec/scaffold/templates/api_controller_spec.rb
234
+ - lib/generators/rspec/scaffold/templates/api_request_spec.rb
234
235
  - lib/generators/rspec/scaffold/templates/controller_spec.rb
235
236
  - lib/generators/rspec/scaffold/templates/edit_spec.rb
236
237
  - lib/generators/rspec/scaffold/templates/index_spec.rb
237
238
  - lib/generators/rspec/scaffold/templates/new_spec.rb
239
+ - lib/generators/rspec/scaffold/templates/request_spec.rb
238
240
  - lib/generators/rspec/scaffold/templates/routing_spec.rb
239
241
  - lib/generators/rspec/scaffold/templates/show_spec.rb
240
242
  - lib/generators/rspec/system/system_generator.rb
@@ -294,7 +296,7 @@ licenses:
294
296
  - MIT
295
297
  metadata:
296
298
  bug_tracker_uri: https://github.com/rspec/rspec-rails/issues
297
- changelog_uri: https://github.com/rspec/rspec-rails/blob/v4.0.0.beta4/Changelog.md
299
+ changelog_uri: https://github.com/rspec/rspec-rails/blob/v4.0.0.rc1/Changelog.md
298
300
  documentation_uri: https://rspec.info/documentation/
299
301
  mailing_list_uri: https://groups.google.com/forum/#!forum/rspec
300
302
  source_code_uri: https://github.com/rspec/rspec-rails
metadata.gz.sig CHANGED
Binary file