diff --git a/Gemfile b/Gemfile index 4ed27f8670..afec6680d3 100644 --- a/Gemfile +++ b/Gemfile @@ -12,22 +12,12 @@ group :documentation do gem 'relish', '~> 0.7.1' end -gem 'rake', '> 12' - -if RUBY_VERSION.to_f >= 2.3 - gem 'rubocop', '~> 0.80.1' -end - gem 'capybara' - -if RUBY_VERSION.to_f >= 2.3 - gem 'ffi', '~> 1.15.5' -else - gem 'ffi', '~> 1.12.0' -end +gem 'ffi', '~> 1.15.5' +gem 'rake', '> 12' +gem 'rubocop', '~> 0.80.1' custom_gemfile = File.expand_path('Gemfile-custom', __dir__) eval_gemfile custom_gemfile if File.exist?(custom_gemfile) -eval_gemfile 'Gemfile-sqlite-dependencies' eval_gemfile 'Gemfile-rails-dependencies' diff --git a/Gemfile-rails-dependencies b/Gemfile-rails-dependencies index 1e29eb66a0..7308a48c5d 100644 --- a/Gemfile-rails-dependencies +++ b/Gemfile-rails-dependencies @@ -11,6 +11,9 @@ def add_net_gems_dependency end end +# sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4` +gem 'sqlite3', '~> 1.4', platforms: [:ruby] + case version = ENV['RAILS_VERSION'] || (File.exist?(version_file) && File.read(version_file).chomp) || '' when /main/ gem "rails", :git => "https://github.com/rails/rails.git" diff --git a/Gemfile-sqlite-dependencies b/Gemfile-sqlite-dependencies deleted file mode 100644 index f7ab236d64..0000000000 --- a/Gemfile-sqlite-dependencies +++ /dev/null @@ -1,20 +0,0 @@ -version_file = File.expand_path('.rails-version', __dir__) -RAILS_VERSION = ENV['RAILS_VERSION'] || (File.exist?(version_file) && File.read(version_file).chomp) || "" - -MAJOR = - case RAILS_VERSION - when /5-2-stable/ - 5 - when /main/, /stable/, nil, false, '' - 6 - else - /(\d+)[\.|-]\d+/.match(RAILS_VERSION).captures.first.to_i - end - -if MAJOR >= 6 -# sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4` - gem 'sqlite3', '~> 1.4', platforms: [:ruby] -else -# Similarly, Rails 5.0 only supports '~> 1.3.6'. Rails 5.1-5.2 support '~> 1.3', '>= 1.3.6' - gem 'sqlite3', '~> 1.3.6', platforms: [:ruby] -end diff --git a/README_DEV.md b/README_DEV.md index 8c01e824e0..b9ea3c98c1 100644 --- a/README_DEV.md +++ b/README_DEV.md @@ -34,6 +34,6 @@ Rails than you are trying to use now. To run the specs against a different version of Rails, use the `thor` command: ```bash -bin/thor version:use 6.0.2.2 +bin/thor version:use 7.0.3.1 bin/rake ``` diff --git a/cucumber.yml b/cucumber.yml index 161eaa7c36..bfcd976ea1 100644 --- a/cucumber.yml +++ b/cucumber.yml @@ -1,3 +1,3 @@ -default: --require features --format progress --tags 'not @wip' -pretty: --require features --format pretty --tags 'not @wip' -wip: --require features --tags @wip +default: --publish-quiet --require features --format progress --tags 'not @wip' +pretty: --publish-quiet --require features --format pretty --tags 'not @wip' +wip: --publish-quiet --require features --tags @wip diff --git a/example_app_generator/config/initializers/sqlite3_fix.rb b/example_app_generator/config/initializers/sqlite3_fix.rb deleted file mode 100644 index 96ea148ac4..0000000000 --- a/example_app_generator/config/initializers/sqlite3_fix.rb +++ /dev/null @@ -1,3 +0,0 @@ -if Rails.application.config.respond_to?(:active_record) && RUBY_ENGINE != "jruby" - Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true -end diff --git a/example_app_generator/generate_action_mailer_specs.rb b/example_app_generator/generate_action_mailer_specs.rb index b66f052f49..16959ee81a 100644 --- a/example_app_generator/generate_action_mailer_specs.rb +++ b/example_app_generator/generate_action_mailer_specs.rb @@ -15,12 +15,7 @@ end CODE - rails_parent = - if Rails.version.to_f >= 6.0 - Rails.application.class.module_parent.to_s - else - Rails.application.class.parent.to_s - end + rails_parent = Rails.application.class.module_parent.to_s gsub_file 'config/initializers/action_mailer.rb', /ExampleApp/, rails_parent diff --git a/example_app_generator/generate_app.rb b/example_app_generator/generate_app.rb index 08ecbf2f65..13ca7a4c8f 100644 --- a/example_app_generator/generate_app.rb +++ b/example_app_generator/generate_app.rb @@ -11,7 +11,6 @@ 'ci_retry_bundle_install.sh' ) function_script_file = File.join(rspec_rails_repo_path, 'script/functions.sh') -sqlite_initializer = File.join(rspec_rails_repo_path, "example_app_generator/config/initializers/sqlite3_fix.rb") in_root do prepend_to_file "Rakefile", "require 'active_support/all'" @@ -27,31 +26,12 @@ append_to_file 'Gemfile', "gem 'rails-controller-testing'\n" - if Rails::VERSION::STRING >= '6' - gsub_file "Gemfile", /.*rails-controller-testing.*/, "gem 'rails-controller-testing', git: 'https://github.com/rails/rails-controller-testing'" + gsub_file "Gemfile", /.*rails-controller-testing.*/, "gem 'rails-controller-testing', git: 'https://github.com/rails/rails-controller-testing'" - # TODO: To remove when Rails released with https://github.com/rails/rails/pull/40281 - append_to_file 'Gemfile', <<-EOT.gsub(/^ +\|/, '') - |gem 'rexml' - EOT - end - - if Rails::VERSION::STRING >= '6' - # sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4` - gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.4'" - else - # Similarly, Rails 5.0 only supports '~> 1.3.6'. Rails 5.1-5.2 support '~> 1.3', '>= 1.3.6' - gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.3.6'" - end + # sqlite3 is an optional, unspecified, dependency and Rails 6.0 only supports `~> 1.4` + gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.4'" - # webdrivers 4 up until 4.3.0 don't specify `required_ruby_version`, but contain - # Ruby 2.2-incompatible syntax (safe navigation). - # That basically means we use pre-4.0 for Ruby 2.2, and 4.3+ for newer Rubies. - 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'" - - if Rails::VERSION::STRING < '6' - copy_file sqlite_initializer, 'config/initializers/sqlite3_fix.rb' - end + gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers'" if RUBY_ENGINE == "jruby" gsub_file "Gemfile", /.*jdbc.*/, '' diff --git a/example_app_generator/spec/support/default_preview_path b/example_app_generator/spec/support/default_preview_path index 5e6bb82cd9..64975fe299 100755 --- a/example_app_generator/spec/support/default_preview_path +++ b/example_app_generator/spec/support/default_preview_path @@ -26,11 +26,9 @@ require_file_stub 'config/environment' do require "action_controller/railtie" require "action_mailer/railtie" unless ENV['NO_ACTION_MAILER'] require "action_view/railtie" - if Rails::VERSION::STRING >= '6' - require "action_cable/engine" - require "active_job/railtie" - require "action_mailbox/engine" - end + require "action_cable/engine" + require "active_job/railtie" + require "action_mailbox/engine" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. diff --git a/example_app_generator/spec/verify_custom_renderers_spec.rb b/example_app_generator/spec/verify_custom_renderers_spec.rb index 2edab4b91c..f52b03dc94 100644 --- a/example_app_generator/spec/verify_custom_renderers_spec.rb +++ b/example_app_generator/spec/verify_custom_renderers_spec.rb @@ -36,12 +36,6 @@ def index expect(response).to render_template(:bar) end - - it "renders an empty string", skip: Rails::VERSION::STRING.to_f >= 6.0 do - get :index - - expect(response.body).to eq("") - end end context "with a custom renderer prepended to the view path" do diff --git a/features/README.md b/features/README.md index d908df11fc..56801b2253 100644 --- a/features/README.md +++ b/features/README.md @@ -4,9 +4,10 @@ routing. ## Rails -rspec-rails 5 supports Rails 5.2 to 6.1. For earlier versions of Rails, you -should use [rspec-rails-4](https://github.com/rspec/rspec-rails/tree/4-1-maintenance) -for Rails 5.x and [rspec-rails 3](https://github.com/rspec/rspec-rails/tree/3-9-maintenance) +rspec-rails 6 supports Rails 6.1 to 7.0. For earlier versions of Rails, you +should use [rspec-rails-5](https://github.com/rspec/rspec-rails/tree/5-1-maintenance) +for Rails 5.2 and 6.0, [rspec-rails-4](https://github.com/rspec/rspec-rails/tree/4-1-maintenance) +for Rails 5.x, and [rspec-rails 3](https://github.com/rspec/rspec-rails/tree/3-9-maintenance) for even older versions. ## Install @@ -26,7 +27,7 @@ This installs the following gems: Add rspec-rails to the :test and :development groups in the Gemfile: group :test, :development do - gem 'rspec-rails', '~> 5.0.0' + gem 'rspec-rails', '~> 6.0.0' end It needs to be in the :development group to expose generators and rake tasks diff --git a/features/channel_specs/channel_spec.feature b/features/channel_specs/channel_spec.feature index 3c48fdd7b2..314ab936eb 100644 --- a/features/channel_specs/channel_spec.feature +++ b/features/channel_specs/channel_spec.feature @@ -1,4 +1,3 @@ -@rails_post_6 Feature: channel spec Channel specs are marked by `:type => :channel` or if you have set diff --git a/features/controller_specs/anonymous_controller.feature b/features/controller_specs/anonymous_controller.feature index 9baf73fb8d..fa2c99e6c0 100644 --- a/features/controller_specs/anonymous_controller.feature +++ b/features/controller_specs/anonymous_controller.feature @@ -101,43 +101,6 @@ Feature: anonymous controller When I run `rspec spec` Then the examples should all pass - # Deprecated support removed in https://github.com/rails/rails/commit/d52d7739468153bd6cb7c629f60bd5cd7ebea3eb - @rails_pre_6 - Scenario: Specify error handling in `ApplicationController` with render :file - Given a file named "spec/controllers/application_controller_spec.rb" with: - """ruby - require "rails_helper" - - class ApplicationController < ActionController::Base - class AccessDenied < StandardError; end - - rescue_from AccessDenied, :with => :access_denied - - private - - def access_denied - render :file => "errors/401" - end - end - - RSpec.describe ApplicationController, :type => :controller do - controller do - def index - raise ApplicationController::AccessDenied - end - end - - describe "handling AccessDenied exceptions" do - it "renders the errors/401 template" do - get :index - expect(response).to render_template("errors/401") - end - end - end - """ - When I run `rspec spec` - Then the examples should all pass - Scenario: Specify error handling in a subclass Given a file named "spec/controllers/application_controller_subclass_spec.rb" with: """ruby diff --git a/features/controller_specs/controller_spec.feature b/features/controller_specs/controller_spec.feature index 6ce5706beb..d6caf84096 100644 --- a/features/controller_specs/controller_spec.feature +++ b/features/controller_specs/controller_spec.feature @@ -34,30 +34,6 @@ Feature: controller spec When I run `rspec spec` Then the example should pass - @rails_pre_6 - Scenario: setting a different content type for example json (request type) - Given a file named "spec/controllers/widgets_controller_spec.rb" with: - """ruby - require "rails_helper" - - RSpec.describe WidgetsController, :type => :controller do - describe "responds to" do - it "responds to html by default" do - post :create, :params => { :widget => { :name => "Any Name" } } - expect(response.content_type).to eq "text/html" - end - - it "responds to custom formats when provided in the params" do - post :create, :params => { :widget => { :name => "Any Name" }, :format => :json } - expect(response.content_type).to eq "application/json" - end - end - end - """ - When I run `rspec spec` - Then the example should pass - - @rails_post_6 Scenario: setting a different content type for example json (request type) Given a file named "spec/controllers/widgets_controller_spec.rb" with: """ruby @@ -80,7 +56,6 @@ Feature: controller spec When I run `rspec spec` Then the example should pass - @rails_post_6 Scenario: setting a different media type for example json (request type) Given a file named "spec/controllers/widgets_controller_spec.rb" with: """ruby diff --git a/features/mailbox_specs/mailbox_spec.feature b/features/mailbox_specs/mailbox_spec.feature index e1a9a62345..1a9423f91f 100644 --- a/features/mailbox_specs/mailbox_spec.feature +++ b/features/mailbox_specs/mailbox_spec.feature @@ -1,4 +1,3 @@ -@rails_post_6 Feature: action mailbox spec Mailbox specs provide alternative assertions to those available in `ActiveMailbox::TestHelper` and help assert behaviour of how the email diff --git a/features/matchers/have_broadcasted_matcher.feature b/features/matchers/have_broadcasted_matcher.feature index 1c0dc25777..40f8537ae3 100644 --- a/features/matchers/have_broadcasted_matcher.feature +++ b/features/matchers/have_broadcasted_matcher.feature @@ -1,4 +1,3 @@ -@rails_post_6 Feature: have_broadcasted matcher The `have_broadcasted_to` (also aliased as `broadcast_to`) matcher is used diff --git a/features/matchers/have_enqueued_mail_matcher.feature b/features/matchers/have_enqueued_mail_matcher.feature index dda6b46f9d..3ad05399a6 100644 --- a/features/matchers/have_enqueued_mail_matcher.feature +++ b/features/matchers/have_enqueued_mail_matcher.feature @@ -68,7 +68,6 @@ Feature: have_enqueued_mail matcher When I run `rspec spec/mailers/my_mailer_spec.rb` Then the examples should all pass - @rails_post_6 Scenario: Parameterize the mailer Given a file named "app/mailers/my_mailer.rb" with: """ruby @@ -98,7 +97,6 @@ Feature: have_enqueued_mail matcher When I run `rspec spec/mailers/my_mailer_spec.rb` Then the examples should all pass - @rails_post_6 Scenario: Parameterize and pass an argument to the mailer Given a file named "app/mailers/my_mailer.rb" with: """ruby diff --git a/features/matchers/have_stream_from_matcher.feature b/features/matchers/have_stream_from_matcher.feature index 01f2a5f36f..156b4043dd 100644 --- a/features/matchers/have_stream_from_matcher.feature +++ b/features/matchers/have_stream_from_matcher.feature @@ -1,4 +1,3 @@ -@rails_post_6 Feature: have_stream_from matcher The `have_stream_from` matcher is used to check if a channel has been subscribed to a given stream specified as a String. diff --git a/features/request_specs/request_spec.feature b/features/request_specs/request_spec.feature index aa312c8f12..31d21821c3 100644 --- a/features/request_specs/request_spec.feature +++ b/features/request_specs/request_spec.feature @@ -55,28 +55,6 @@ Feature: request spec When I run `rspec spec/requests/widget_management_spec.rb` Then the example should pass - @rails_pre_6 - Scenario: requesting a JSON response - Given a file named "spec/requests/widget_management_spec.rb" with: - """ruby - require "rails_helper" - - RSpec.describe "Widget management", :type => :request do - - it "creates a Widget" do - headers = { "ACCEPT" => "application/json" } - post "/widgets", :params => { :widget => {:name => "My Widget"} }, :headers => headers - - expect(response.content_type).to eq("application/json") - expect(response).to have_http_status(:created) - end - - end - """ - When I run `rspec spec/requests/widget_management_spec.rb` - Then the example should pass - - @rails_post_6 Scenario: requesting a JSON response Given a file named "spec/requests/widget_management_spec.rb" with: """ruby diff --git a/features/support/rails_versions.rb b/features/support/rails_versions.rb deleted file mode 100644 index 38d8b6f8c9..0000000000 --- a/features/support/rails_versions.rb +++ /dev/null @@ -1,22 +0,0 @@ -def rails_version - string_version = ENV.fetch("RAILS_VERSION", "~> 6.0.0") - if string_version == "main" || string_version.nil? - Float::INFINITY - else - string_version[/\d[\.-]\d/].tr('-', '.') - end -end - -Before "@rails_pre_6" do |scenario| - if rails_version.to_f >= 6.0 - warn "Skipping scenario #{scenario.name} on Rails v#{rails_version}" - skip_this_scenario - end -end - -Before "@rails_post_6" do |scenario| - if rails_version.to_f < 6.0 - warn "Skipping scenario #{scenario.name} on Rails v#{rails_version}" - skip_this_scenario - end -end diff --git a/features/support/rubinius.rb b/features/support/rubinius.rb deleted file mode 100644 index b09d67abbc..0000000000 --- a/features/support/rubinius.rb +++ /dev/null @@ -1,6 +0,0 @@ -# Required until https://github.com/rubinius/rubinius/issues/2430 is resolved -ENV['RBXOPT'] = "#{ENV['RBXOPT']} -Xcompiler.no_rbc" - -Around "@unsupported-on-rbx" do |_scenario, block| - block.call unless defined?(Rubinius) -end diff --git a/features/upgrade/README.md b/features/upgrade/README.md index 029861fdd9..5b91c9fcce 100644 --- a/features/upgrade/README.md +++ b/features/upgrade/README.md @@ -1,3 +1,9 @@ +# Upgrading from rspec-rails 5.x to version 6 + +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. + +If you are using an older version of Rails, you can use 5.x which hard supports 5.2 and 6.x. + # Upgrading from rspec-rails 4.x to version 5 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. diff --git a/lib/rspec-rails.rb b/lib/rspec-rails.rb index 361c777df7..45592fbd87 100644 --- a/lib/rspec-rails.rb +++ b/lib/rspec-rails.rb @@ -8,11 +8,7 @@ module Rails class Railtie < ::Rails::Railtie # As of Rails 5.1.0 you can register directories to work with `rake notes` require 'rails/source_annotation_extractor' - if ::Rails::VERSION::STRING >= '6.0' - ::Rails::SourceAnnotationExtractor::Annotation.register_directories("spec") - else - SourceAnnotationExtractor::Annotation.register_directories("spec") - end + ::Rails::SourceAnnotationExtractor::Annotation.register_directories("spec") generators = config.app_generators generators.integration_tool :rspec generators.test_framework :rspec diff --git a/lib/rspec/rails/example/system_example_group.rb b/lib/rspec/rails/example/system_example_group.rb index 046da3ebea..8e0bb5ffe6 100644 --- a/lib/rspec/rails/example/system_example_group.rb +++ b/lib/rspec/rails/example/system_example_group.rb @@ -54,23 +54,22 @@ def app ActionDispatch::SystemTesting::Server.silence_puma = true end + require 'action_dispatch/system_test_case' + begin require 'capybara' - require 'action_dispatch/system_test_case' rescue LoadError => e abort """ LoadError: #{e.message} - System test integration requires Rails >= 5.1 and has a hard + System test integration has a hard dependency on a webserver and `capybara`, please add capybara to your Gemfile and configure a webserver (e.g. `Capybara.server = - :webrick`) before attempting to use system specs. + :puma`) before attempting to use system specs. """.gsub(/\s+/, ' ').strip end - if ::Rails::VERSION::STRING >= '6.0' - original_before_teardown = - ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:before_teardown) - end + original_before_teardown = + ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:before_teardown) original_after_teardown = ::ActionDispatch::SystemTesting::TestHelpers::SetupAndTeardown.instance_method(:after_teardown) diff --git a/lib/rspec/rails/feature_check.rb b/lib/rspec/rails/feature_check.rb index 4a4d855d75..a19b2cfef2 100644 --- a/lib/rspec/rails/feature_check.rb +++ b/lib/rspec/rails/feature_check.rb @@ -24,7 +24,7 @@ def has_action_mailer_preview? end def has_action_cable_testing? - defined?(::ActionCable) && ActionCable::VERSION::MAJOR >= 6 + defined?(::ActionCable) end def has_action_mailer_parameterized? diff --git a/lib/rspec/rails/fixture_file_upload_support.rb b/lib/rspec/rails/fixture_file_upload_support.rb index ef4989c653..c321728504 100644 --- a/lib/rspec/rails/fixture_file_upload_support.rb +++ b/lib/rspec/rails/fixture_file_upload_support.rb @@ -6,41 +6,24 @@ module FixtureFileUploadSupport private - # In Rails 6.2 fixture file path needs to be relative to `file_fixture_path` instead, this change - # was brought in with a deprecation warning on 6.1. In Rails 6.2 expect to rework this to remove + # In Rails 7.0 fixture file path needs to be relative to `file_fixture_path` instead, this change + # was brought in with a deprecation warning on 6.1. In Rails 7.0 expect to rework this to remove # the old accessor. - if ::Rails.version.to_f >= 6.1 - def rails_fixture_file_wrapper - RailsFixtureFileWrapper.file_fixture_path = nil - resolved_fixture_path = - if respond_to?(:file_fixture_path) && !file_fixture_path.nil? - file_fixture_path.to_s - else - (RSpec.configuration.fixture_path || '').to_s - end - RailsFixtureFileWrapper.file_fixture_path = File.join(resolved_fixture_path, '') unless resolved_fixture_path.strip.empty? - RailsFixtureFileWrapper.instance - end - else - def rails_fixture_file_wrapper - RailsFixtureFileWrapper.fixture_path = nil - resolved_fixture_path = - if respond_to?(:fixture_path) && !fixture_path.nil? - fixture_path.to_s - else - (RSpec.configuration.fixture_path || '').to_s - end - RailsFixtureFileWrapper.fixture_path = File.join(resolved_fixture_path, '') unless resolved_fixture_path.strip.empty? - RailsFixtureFileWrapper.instance - end + def rails_fixture_file_wrapper + RailsFixtureFileWrapper.file_fixture_path = nil + resolved_fixture_path = + if respond_to?(:file_fixture_path) && !file_fixture_path.nil? + file_fixture_path.to_s + else + (RSpec.configuration.fixture_path || '').to_s + end + RailsFixtureFileWrapper.file_fixture_path = File.join(resolved_fixture_path, '') unless resolved_fixture_path.strip.empty? + RailsFixtureFileWrapper.instance end class RailsFixtureFileWrapper include ActionDispatch::TestProcess if defined?(ActionDispatch::TestProcess) - - if ::Rails.version.to_f >= 6.1 - include ActiveSupport::Testing::FileFixtures - end + include ActiveSupport::Testing::FileFixtures class << self attr_accessor :fixture_path diff --git a/lib/rspec/rails/vendor/capybara.rb b/lib/rspec/rails/vendor/capybara.rb index c6c735869a..97f8eb64e6 100644 --- a/lib/rspec/rails/vendor/capybara.rb +++ b/lib/rspec/rails/vendor/capybara.rb @@ -12,9 +12,7 @@ RSpec.configure do |c| if defined?(Capybara::DSL) c.include Capybara::DSL, type: :feature - if defined?(ActionPack) && ActionPack::VERSION::STRING >= "5.1" - c.include Capybara::DSL, type: :system - end + c.include Capybara::DSL, type: :system end if defined?(Capybara::RSpecMatchers) diff --git a/lib/rspec/rails/view_assigns.rb b/lib/rspec/rails/view_assigns.rb index e8bbb5fa75..2b9d05fa0c 100644 --- a/lib/rspec/rails/view_assigns.rb +++ b/lib/rspec/rails/view_assigns.rb @@ -13,26 +13,8 @@ def assign(key, value) end # Compat-shim for AbstractController::Rendering#view_assigns - # - # _assigns was deprecated in favor of view_assigns after - # Rails-3.0.0 was released. Since we are not able to predict when - # the _assigns/view_assigns patch will be released (I thought it - # would have been in 3.0.1, but 3.0.1 bypassed this change for a - # security fix), this bit ensures that we do the right thing without - # knowing anything about the Rails version we are dealing with. - # - # Once that change _is_ released, this can be changed to something - # that checks for the Rails version when the module is being - # interpreted, as it was before commit dd0095. def view_assigns super.merge(_encapsulated_assigns) - rescue - _assigns - end - - # @private - def _assigns - super.merge(_encapsulated_assigns) end private diff --git a/lib/rspec/rails/view_rendering.rb b/lib/rspec/rails/view_rendering.rb index 22eff75ba2..9ad81c50cc 100644 --- a/lib/rspec/rails/view_rendering.rb +++ b/lib/rspec/rails/view_rendering.rb @@ -62,14 +62,8 @@ def self.nullify_template_rendering(templates) end end - if ::Rails::VERSION::STRING >= '6' - def self.template_format(template) - template.format - end - else - def self.template_format(template) - template.formats - end + def self.template_format(template) + template.format end # Delegates all methods to the submitted resolver and for all methods diff --git a/rspec-rails.gemspec b/rspec-rails.gemspec index d285a90080..3e4ac70560 100644 --- a/rspec-rails.gemspec +++ b/rspec-rails.gemspec @@ -58,5 +58,5 @@ Gem::Specification.new do |s| s.add_development_dependency 'ammeter', '~> 1.1.5' s.add_development_dependency 'aruba', '~> 0.14.12' - s.add_development_dependency 'cucumber', '>= 3.2', '!= 4.0.0', '< 8.0.0' + s.add_development_dependency 'cucumber', '~> 7.0' end diff --git a/snippets/avoid_fixture_name_collision.rb b/snippets/avoid_fixture_name_collision.rb index 8f1768acc8..047d5c218d 100644 --- a/snippets/avoid_fixture_name_collision.rb +++ b/snippets/avoid_fixture_name_collision.rb @@ -20,7 +20,6 @@ # Those Gemfiles carefully pick the right versions depending on # settings in the ENV, `.rails-version` and `maintenance-branch`. Dir.chdir('..') do - eval_gemfile 'Gemfile-sqlite-dependencies' # This Gemfile expects `maintenance-branch` file to be present # in the current directory. eval_gemfile 'Gemfile-rspec-dependencies' diff --git a/snippets/use_active_record_false.rb b/snippets/use_active_record_false.rb index 2965223084..705af8a394 100644 --- a/snippets/use_active_record_false.rb +++ b/snippets/use_active_record_false.rb @@ -20,7 +20,6 @@ # Those Gemfiles carefully pick the right versions depending on # settings in the ENV, `.rails-version` and `maintenance-branch`. Dir.chdir('..') do - eval_gemfile 'Gemfile-sqlite-dependencies' # This Gemfile expects `maintenance-branch` file to be present # in the current directory. eval_gemfile 'Gemfile-rspec-dependencies' diff --git a/spec/rspec/rails/fixture_file_upload_support_spec.rb b/spec/rspec/rails/fixture_file_upload_support_spec.rb index af074704dd..3c5c0bda7c 100644 --- a/spec/rspec/rails/fixture_file_upload_support_spec.rb +++ b/spec/rspec/rails/fixture_file_upload_support_spec.rb @@ -35,11 +35,7 @@ def fixture_file_upload_resolved(fixture_name, fixture_path = nil) RSpec::Core::ExampleGroup.describe do include RSpec::Rails::FixtureFileUploadSupport - if ::Rails.version.to_f >= 6.1 - self.file_fixture_path = fixture_path - else - self.fixture_path = fixture_path - end + self.file_fixture_path = fixture_path it 'supports fixture file upload' do file = fixture_file_upload(fixture_name) diff --git a/spec/rspec/rails/fixture_support_spec.rb b/spec/rspec/rails/fixture_support_spec.rb index 62b08a303f..534a063125 100644 --- a/spec/rspec/rails/fixture_support_spec.rb +++ b/spec/rspec/rails/fixture_support_spec.rb @@ -39,7 +39,7 @@ def expect_to_pass(group) end end - it "will allow #setup_fixture to run successfully", skip: Rails.version.to_f <= 6.0 do + it "will allow #setup_fixture to run successfully" do group = RSpec::Core::ExampleGroup.describe do include FixtureSupport diff --git a/spec/rspec/rails/matchers/active_job_spec.rb b/spec/rspec/rails/matchers/active_job_spec.rb index d4c8e2ea94..70635ec380 100644 --- a/spec/rspec/rails/matchers/active_job_spec.rb +++ b/spec/rspec/rails/matchers/active_job_spec.rb @@ -379,22 +379,20 @@ def self.name; "LoggingJob"; end } end - if Rails.version.to_f >= 6.0 - it "passes with Time" do - usec_time = Time.iso8601('2016-07-01T00:00:00.000001Z') + it "passes with Time" do + usec_time = Time.iso8601('2016-07-01T00:00:00.000001Z') - expect { - hello_job.perform_later(usec_time) - }.to have_enqueued_job(hello_job).with(usec_time) - end + expect { + hello_job.perform_later(usec_time) + }.to have_enqueued_job(hello_job).with(usec_time) + end - it "passes with ActiveSupport::TimeWithZone" do - usec_time = Time.iso8601('2016-07-01T00:00:00.000001Z').in_time_zone + it "passes with ActiveSupport::TimeWithZone" do + usec_time = Time.iso8601('2016-07-01T00:00:00.000001Z').in_time_zone - expect { - hello_job.perform_later(usec_time) - }.to have_enqueued_job(hello_job).with(usec_time) - end + expect { + hello_job.perform_later(usec_time) + }.to have_enqueued_job(hello_job).with(usec_time) end end