Skip to content

Commit 0616111

Browse files
committed
Remove version-specific checks for unsupported Rails/Ruby
1 parent a67fb9d commit 0616111

27 files changed

+58
-244
lines changed

Gemfile

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,9 @@ group :documentation do
1313
end
1414

1515
gem 'rake', '> 12'
16-
17-
if RUBY_VERSION.to_f >= 2.3
18-
gem 'rubocop', '~> 0.80.1'
19-
end
20-
16+
gem 'rubocop', '~> 0.80.1'
2117
gem 'capybara'
22-
23-
if RUBY_VERSION.to_f >= 2.3
24-
gem 'ffi', '~> 1.15.5'
25-
else
26-
gem 'ffi', '~> 1.12.0'
27-
end
18+
gem 'ffi', '~> 1.15.5'
2819

2920
custom_gemfile = File.expand_path('Gemfile-custom', __dir__)
3021
eval_gemfile custom_gemfile if File.exist?(custom_gemfile)

README_DEV.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ Rails than you are trying to use now.
3434
To run the specs against a different version of Rails, use the `thor` command:
3535

3636
```bash
37-
bin/thor version:use 6.0.2.2
37+
bin/thor version:use 7.0.3.1
3838
bin/rake
3939
```

example_app_generator/generate_action_mailer_specs.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@
1515
end
1616
CODE
1717

18-
rails_parent =
19-
if Rails.version.to_f >= 6.0
20-
Rails.application.class.module_parent.to_s
21-
else
22-
Rails.application.class.parent.to_s
23-
end
18+
rails_parent = Rails.application.class.module_parent.to_s
2419

2520
gsub_file 'config/initializers/action_mailer.rb', /ExampleApp/, rails_parent
2621

example_app_generator/generate_app.rb

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,12 @@
2626

2727
append_to_file 'Gemfile', "gem 'rails-controller-testing'\n"
2828

29-
if Rails::VERSION::STRING >= '6'
30-
gsub_file "Gemfile", /.*rails-controller-testing.*/, "gem 'rails-controller-testing', git: 'https://github.com/rails/rails-controller-testing'"
31-
32-
# TODO: To remove when Rails released with https://github.com/rails/rails/pull/40281
33-
append_to_file 'Gemfile', <<-EOT.gsub(/^ +\|/, '')
34-
|gem 'rexml'
35-
EOT
36-
end
29+
gsub_file "Gemfile", /.*rails-controller-testing.*/, "gem 'rails-controller-testing', git: 'https://github.com/rails/rails-controller-testing'"
3730

3831
# sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4`
3932
gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.4'"
4033

41-
# webdrivers 4 up until 4.3.0 don't specify `required_ruby_version`, but contain
42-
# Ruby 2.2-incompatible syntax (safe navigation).
43-
# That basically means we use pre-4.0 for Ruby 2.2, and 4.3+ for newer Rubies.
44-
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers', '!= 4.0.0', '!= 4.0.1', '!= 4.1.0', '!= 4.1.1', '!= 4.1.2', '!= 4.1.3', '!= 4.2.0'"
34+
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers'"
4535

4636
if RUBY_ENGINE == "jruby"
4737
gsub_file "Gemfile", /.*jdbc.*/, ''

example_app_generator/spec/support/default_preview_path

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ require_file_stub 'config/environment' do
2626
require "action_controller/railtie"
2727
require "action_mailer/railtie" unless ENV['NO_ACTION_MAILER']
2828
require "action_view/railtie"
29-
if Rails::VERSION::STRING >= '6'
30-
require "action_cable/engine"
31-
require "active_job/railtie"
32-
require "action_mailbox/engine"
33-
end
29+
require "action_cable/engine"
30+
require "active_job/railtie"
31+
require "action_mailbox/engine"
3432

3533
# Require the gems listed in Gemfile, including any gems
3634
# you've limited to :test, :development, or :production.

example_app_generator/spec/verify_custom_renderers_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def index
3737
expect(response).to render_template(:bar)
3838
end
3939

40-
it "renders an empty string", skip: Rails::VERSION::STRING.to_f >= 6.0 do
40+
it "renders an empty string" do
4141
get :index
4242

4343
expect(response.body).to eq("")

features/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ routing.
44

55
## Rails
66

7-
rspec-rails 5 supports Rails 5.2 to 6.1. For earlier versions of Rails, you
8-
should use [rspec-rails-4](https://github.com/rspec/rspec-rails/tree/4-1-maintenance)
9-
for Rails 5.x and [rspec-rails 3](https://github.com/rspec/rspec-rails/tree/3-9-maintenance)
7+
rspec-rails 6 supports Rails 6.1 to 7.0. For earlier versions of Rails, you
8+
should use [rspec-rails-5](https://github.com/rspec/rspec-rails/tree/5-1-maintenance)
9+
for Rails 5.2 and 6.0, [rspec-rails-4](https://github.com/rspec/rspec-rails/tree/4-1-maintenance)
10+
for Rails 5.x, and [rspec-rails 3](https://github.com/rspec/rspec-rails/tree/3-9-maintenance)
1011
for even older versions.
1112

1213
## Install
@@ -26,7 +27,7 @@ This installs the following gems:
2627
Add rspec-rails to the :test and :development groups in the Gemfile:
2728

2829
group :test, :development do
29-
gem 'rspec-rails', '~> 5.0.0'
30+
gem 'rspec-rails', '~> 6.0.0'
3031
end
3132

3233
It needs to be in the :development group to expose generators and rake tasks

features/channel_specs/channel_spec.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@rails_post_6
21
Feature: channel spec
32

43
Channel specs are marked by `:type => :channel` or if you have set

features/controller_specs/anonymous_controller.feature

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -101,43 +101,6 @@ Feature: anonymous controller
101101
When I run `rspec spec`
102102
Then the examples should all pass
103103

104-
# Deprecated support removed in https://github.com/rails/rails/commit/d52d7739468153bd6cb7c629f60bd5cd7ebea3eb
105-
@rails_pre_6
106-
Scenario: Specify error handling in `ApplicationController` with render :file
107-
Given a file named "spec/controllers/application_controller_spec.rb" with:
108-
"""ruby
109-
require "rails_helper"
110-
111-
class ApplicationController < ActionController::Base
112-
class AccessDenied < StandardError; end
113-
114-
rescue_from AccessDenied, :with => :access_denied
115-
116-
private
117-
118-
def access_denied
119-
render :file => "errors/401"
120-
end
121-
end
122-
123-
RSpec.describe ApplicationController, :type => :controller do
124-
controller do
125-
def index
126-
raise ApplicationController::AccessDenied
127-
end
128-
end
129-
130-
describe "handling AccessDenied exceptions" do
131-
it "renders the errors/401 template" do
132-
get :index
133-
expect(response).to render_template("errors/401")
134-
end
135-
end
136-
end
137-
"""
138-
When I run `rspec spec`
139-
Then the examples should all pass
140-
141104
Scenario: Specify error handling in a subclass
142105
Given a file named "spec/controllers/application_controller_subclass_spec.rb" with:
143106
"""ruby

features/controller_specs/controller_spec.feature

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,6 @@ Feature: controller spec
3434
When I run `rspec spec`
3535
Then the example should pass
3636

37-
@rails_pre_6
38-
Scenario: setting a different content type for example json (request type)
39-
Given a file named "spec/controllers/widgets_controller_spec.rb" with:
40-
"""ruby
41-
require "rails_helper"
42-
43-
RSpec.describe WidgetsController, :type => :controller do
44-
describe "responds to" do
45-
it "responds to html by default" do
46-
post :create, :params => { :widget => { :name => "Any Name" } }
47-
expect(response.content_type).to eq "text/html"
48-
end
49-
50-
it "responds to custom formats when provided in the params" do
51-
post :create, :params => { :widget => { :name => "Any Name" }, :format => :json }
52-
expect(response.content_type).to eq "application/json"
53-
end
54-
end
55-
end
56-
"""
57-
When I run `rspec spec`
58-
Then the example should pass
59-
60-
@rails_post_6
6137
Scenario: setting a different content type for example json (request type)
6238
Given a file named "spec/controllers/widgets_controller_spec.rb" with:
6339
"""ruby
@@ -80,7 +56,6 @@ Feature: controller spec
8056
When I run `rspec spec`
8157
Then the example should pass
8258

83-
@rails_post_6
8459
Scenario: setting a different media type for example json (request type)
8560
Given a file named "spec/controllers/widgets_controller_spec.rb" with:
8661
"""ruby

features/mailbox_specs/mailbox_spec.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@rails_post_6
21
Feature: action mailbox spec
32

43
Mailbox specs provide alternative assertions to those available in `ActiveMailbox::TestHelper` and help assert behaviour of how the email

features/matchers/have_broadcasted_matcher.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@rails_post_6
21
Feature: have_broadcasted matcher
32

43
The `have_broadcasted_to` (also aliased as `broadcast_to`) matcher is used

features/matchers/have_enqueued_mail_matcher.feature

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ Feature: have_enqueued_mail matcher
6868
When I run `rspec spec/mailers/my_mailer_spec.rb`
6969
Then the examples should all pass
7070

71-
@rails_post_6
7271
Scenario: Parameterize the mailer
7372
Given a file named "app/mailers/my_mailer.rb" with:
7473
"""ruby
@@ -98,7 +97,6 @@ Feature: have_enqueued_mail matcher
9897
When I run `rspec spec/mailers/my_mailer_spec.rb`
9998
Then the examples should all pass
10099

101-
@rails_post_6
102100
Scenario: Parameterize and pass an argument to the mailer
103101
Given a file named "app/mailers/my_mailer.rb" with:
104102
"""ruby

features/matchers/have_stream_from_matcher.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@rails_post_6
21
Feature: have_stream_from matcher
32

43
The `have_stream_from` matcher is used to check if a channel has been subscribed to a given stream specified as a String.

features/request_specs/request_spec.feature

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,6 @@ Feature: request spec
5555
When I run `rspec spec/requests/widget_management_spec.rb`
5656
Then the example should pass
5757

58-
@rails_pre_6
59-
Scenario: requesting a JSON response
60-
Given a file named "spec/requests/widget_management_spec.rb" with:
61-
"""ruby
62-
require "rails_helper"
63-
64-
RSpec.describe "Widget management", :type => :request do
65-
66-
it "creates a Widget" do
67-
headers = { "ACCEPT" => "application/json" }
68-
post "/widgets", :params => { :widget => {:name => "My Widget"} }, :headers => headers
69-
70-
expect(response.content_type).to eq("application/json")
71-
expect(response).to have_http_status(:created)
72-
end
73-
74-
end
75-
"""
76-
When I run `rspec spec/requests/widget_management_spec.rb`
77-
Then the example should pass
78-
79-
@rails_post_6
8058
Scenario: requesting a JSON response
8159
Given a file named "spec/requests/widget_management_spec.rb" with:
8260
"""ruby

features/support/rails_versions.rb

Lines changed: 0 additions & 22 deletions
This file was deleted.

features/upgrade/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Upgrading from rspec-rails 5.x to version 6
2+
3+
RSpec Rails 6 is a major version under semantic versioning, it also follows our new versioning strategy for RSpec-Rails, which is to keep in step with Rails supported versions. Thus it supports 6.1 and 7.0. There are no changes required to upgrade to RSpec Rails 6 if you are using a supported version of Rails.
4+
5+
If you are using an older version of Rails, you can use 5.x which hard supports 5.2 and 6.x.
6+
17
# Upgrading from rspec-rails 4.x to version 5
28

39
RSpec Rails 5 is a major version under semantic versioning, it also follows our new versioning strategy for RSpec-Rails, which is to keep in step with Rails supported versions. Thus it supports 5.2, 6.0 and 6.1. There are no changes required to upgrade to RSpec Rails 5 if you are using a supported version of Rails.

lib/rspec-rails.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ module Rails
88
class Railtie < ::Rails::Railtie
99
# As of Rails 5.1.0 you can register directories to work with `rake notes`
1010
require 'rails/source_annotation_extractor'
11-
if ::Rails::VERSION::STRING >= '6.0'
12-
::Rails::SourceAnnotationExtractor::Annotation.register_directories("spec")
13-
else
14-
SourceAnnotationExtractor::Annotation.register_directories("spec")
15-
end
11+
::Rails::SourceAnnotationExtractor::Annotation.register_directories("spec")
1612
generators = config.app_generators
1713
generators.integration_tool :rspec
1814
generators.test_framework :rspec

lib/rspec/rails/example/system_example_group.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,22 @@ def app
5454
ActionDispatch::SystemTesting::Server.silence_puma = true
5555
end
5656

57+
require 'action_dispatch/system_test_case'
58+
5759
begin
5860
require 'capybara'
59-
require 'action_dispatch/system_test_case'
6061
rescue LoadError => e
6162
abort """
6263
LoadError: #{e.message}
63-
System test integration requires Rails >= 5.1 and has a hard
64+
System test integration has a hard
6465
dependency on a webserver and `capybara`, please add capybara to
6566
your Gemfile and configure a webserver (e.g. `Capybara.server =
66-
:webrick`) before attempting to use system specs.
67+
:puma`) before attempting to use system specs.
6768
""".gsub(/\s+/, ' ').strip
6869
end
6970

70-
if ::Rails::VERSION::STRING >= '6.0'
71-
original_before_teardown =
72-
::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:before_teardown)
73-
end
71+
original_before_teardown =
72+
::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:before_teardown)
7473

7574
original_after_teardown =
7675
::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:after_teardown)

lib/rspec/rails/feature_check.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def has_action_mailer_preview?
2424
end
2525

2626
def has_action_cable_testing?
27-
defined?(::ActionCable) && ActionCable::VERSION::MAJOR >= 6
27+
defined?(::ActionCable)
2828
end
2929

3030
def has_action_mailer_parameterized?

0 commit comments

Comments
 (0)