From 06a799c1cb73a2c02951db049bfd736184b8f58b Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Sun, 8 Dec 2019 13:39:45 +0300 Subject: [PATCH 1/4] Cleanup support of Ruby < 2.2 & Rails < 5.2 --- .rubocop.yml | 12 - .rubocop_todo.yml | 11 + .travis.yml | 32 -- Gemfile | 2 +- Gemfile-custom.sample | 7 - Gemfile-rails-dependencies | 10 +- README.md | 3 +- Rakefile | 21 +- appveyor.yml | 2 - example_app_generator/generate_app.rb | 41 +- .../app/models/in_memory/model.rb | 3 - .../spec/verify_mailer_preview_path_spec.rb | 8 +- .../travis_retry_bundle_install.sh | 2 +- .../anonymous_controller.feature | 403 ------------------ .../controller_specs/controller_spec.feature | 25 +- .../controller_specs/engine_routes.feature | 1 - features/feature_specs/feature_spec.feature | 29 -- features/mailer_specs/mailer_spec.feature | 28 -- features/mailer_specs/url_helpers.feature | 41 -- .../have_enqueued_mail_matcher.feature | 38 -- .../matchers/have_http_status_matcher.feature | 26 -- features/matchers/redirect_to_matcher.feature | 34 -- features/request_specs/request_spec.feature | 77 +--- features/routing_specs/engine_routes.feature | 1 - .../step_definitions/additional_cli_steps.rb | 6 - features/support/capybara.rb | 10 +- features/support/rails_versions.rb | 4 - features/view_specs/view_spec.feature | 19 - .../install/templates/spec/rails_helper.rb | 4 - .../scaffold/templates/api_controller_spec.rb | 36 -- .../scaffold/templates/controller_spec.rb | 48 --- .../rspec/system/system_generator.rb | 30 +- lib/rspec-rails.rb | 15 +- lib/rspec/rails/configuration.rb | 6 +- .../rails/example/controller_example_group.rb | 9 +- lib/rspec/rails/feature_check.rb | 4 - lib/rspec/rails/file_fixture_support.rb | 20 +- lib/rspec/rails/fixture_support.rb | 6 +- lib/rspec/rails/matchers/base_matcher.rb | 10 +- lib/rspec/rails/tasks/rspec.rake | 13 +- rspec-rails.gemspec | 2 +- script/clone_all_rspec_repos | 5 +- script/custom_build_functions.sh | 2 +- script/functions.sh | 14 +- script/predicate_functions.sh | 69 +-- .../rspec/system/system_generator_spec.rb | 52 ++- spec/rspec/rails/configuration_spec.rb | 6 +- .../example/mailer_example_group_spec.rb | 6 - 48 files changed, 112 insertions(+), 1141 deletions(-) delete mode 100644 features/support/rails_versions.rb diff --git a/.rubocop.yml b/.rubocop.yml index a65610a4e5..3df2c75ce0 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -246,12 +246,6 @@ Style/ParallelAssignment: Style/ParenthesesAroundCondition: Enabled: false -Style/PerlBackrefs: - Exclude: - # We probably can refactor the backref out, but for now excluding it since - # we can't use named matches in 1.8.7 - - lib/generators/rspec/scaffold/scaffold_generator.rb - Style/PercentLiteralDelimiters: PreferredDelimiters: '%': () # double-quoted string @@ -264,12 +258,6 @@ Style/PercentLiteralDelimiters: '%W': '[]' # array of double-quoted strings '%x': () # a shell command as a string -# On 1.8 `proc` was `lambda`, so we used `Proc.new` to ensure we got real procs -# on all supported versions. -# http://batsov.com/articles/2014/02/04/the-elements-of-style-in-ruby-number-12-proc-vs-proc-dot-new/ -Style/Proc: - Enabled: false - Style/RegexpLiteral: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d4dffc2e57..fde501f88f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -25,3 +25,14 @@ Style/HashSyntax: # the new lambda syntax was not supported in ruby 1.8.7 Style/Lambda: Enabled: false + +# previously we couldn't use named matches in ruby 1.8.7 +Style/PerlBackrefs: + Exclude: + - lib/generators/rspec/scaffold/scaffold_generator.rb + +# On 1.8 `proc` was `lambda`, so we used `Proc.new` to ensure we got real procs +# on all supported versions. +# http://batsov.com/articles/2014/02/04/the-elements-of-style-in-ruby-number-12-proc-vs-proc-dot-new/ +Style/Proc: + Enabled: false diff --git a/.travis.yml b/.travis.yml index f3e3a596da..019301f116 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,36 +65,4 @@ matrix: - rvm: 2.3.8 env: RAILS_VERSION='~> 5.2.0' - # Rails 5.1 Builds >= 2.2.2 - - rvm: 2.6.3 - env: RAILS_VERSION='~> 5.1.0' - - rvm: 2.5.5 - env: RAILS_VERSION='~> 5.1.0' - - rvm: 2.4.6 - env: RAILS_VERSION='~> 5.1.0' - - rvm: 2.3.8 - env: RAILS_VERSION='~> 5.1.0' - - # Rails 5.0 Builds >= 2.2.2 - - rvm: 2.6.3 - env: RAILS_VERSION='~> 5.0.0' - - rvm: 2.5.5 - env: RAILS_VERSION='~> 5.0.0' - - rvm: 2.4.6 - env: RAILS_VERSION='~> 5.0.0' - - rvm: 2.3.8 - env: RAILS_VERSION='~> 5.0.0' - - # Rails 4.2 Builds >= 1.9.3 - - rvm: 2.5.5 - env: RAILS_VERSION='~> 4.2.0' - - rvm: 2.4.6 - env: RAILS_VERSION='~> 4.2.0' - - rvm: 2.4.6 - env: RAILS_VERSION='~> 4.2.0' - - rvm: 2.3.8 - env: RAILS_VERSION='~> 4.2.0' - - rvm: 2.3.8 - env: RAILS_VERSION='~> 4.2.0' - fast_finish: true diff --git a/Gemfile b/Gemfile index ec02a32457..3a44a2db4c 100644 --- a/Gemfile +++ b/Gemfile @@ -29,7 +29,7 @@ when /stable/ MINOR = 0 when nil, false, "" MAJOR = 5 - MINOR = 0 + MINOR = 2 else match = /(\d+)(\.|-)(\d+)/.match(RAILS_VERSION) MAJOR, MINOR = match.captures.map(&:to_i).compact diff --git a/Gemfile-custom.sample b/Gemfile-custom.sample index a5017674b5..81bbe0e475 100644 --- a/Gemfile-custom.sample +++ b/Gemfile-custom.sample @@ -8,12 +8,5 @@ group :development do platform :mri do gem 'rb-fsevent', '~> 0.9.0' gem 'ruby-prof', '~> 0.10.0' - - case RUBY_VERSION - when /^1.8/ - gem 'ruby-debug' - when /^1.9/ - gem 'debugger' - end end end diff --git a/Gemfile-rails-dependencies b/Gemfile-rails-dependencies index 0353dc70a2..f028671194 100644 --- a/Gemfile-rails-dependencies +++ b/Gemfile-rails-dependencies @@ -15,21 +15,21 @@ when /master/ gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', platforms: [:jruby] when /stable$/ gem_list = %w[rails railties actionmailer actionpack activerecord activesupport] - gem_list << 'activejob' if version >= '4-2-stable' - gem_list << 'actionview' if version >= '4-2-stable' - gem 'puma', "3.12.1" if version > '5-0-stable' + gem_list << 'activejob' + gem_list << 'actionview' + gem 'puma', "3.12.1" gem 'activerecord-jdbcsqlite3-adapter', git: 'https://github.com/jruby/activerecord-jdbc-adapter', platforms: [:jruby] gem_list.each do |rails_gem| gem rails_gem, :git => "https://github.com/rails/rails.git", :branch => version end when nil, false, "" - gem "rails", "~> 5.0.0" + gem "rails", "~> 5.2.0" gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby] else gem "rails", version - if version >= '5-1-stable' && RUBY_VERSION >= "2.3" + if RUBY_VERSION >= "2.3" gem "puma" end diff --git a/README.md b/README.md index 3dc5247470..441015765f 100644 --- a/README.md +++ b/README.md @@ -119,8 +119,7 @@ $ bundle exec rspec --help ``` **Optional:** If `bundle exec rspec` is too verbose for you, -you can generate a binstub at `bin/rspec` -and use that instead (Rails 4+ only): +you can generate a binstub at `bin/rspec` and use that instead: ```sh $ bundle binstubs rspec-core diff --git a/Rakefile b/Rakefile index d7d4f3c2d0..72bfb3f157 100644 --- a/Rakefile +++ b/Rakefile @@ -27,29 +27,12 @@ RSpec::Core::RakeTask.new(:spec) do |t| end Cucumber::Rake::Task.new(:cucumber) do |t| - version = ENV.fetch("RAILS_VERSION", "~> 4.2.0")[/\d[\.-]\d/] + version = ENV.fetch("RAILS_VERSION", "~> 5.2.0")[/\d[\.-]\d/] if version == "master" || version.nil? version = Float::INFINITY end tags = [] - if version.to_f >= 5.1 - tags << "~@rails_pre_5.1" - end - - if version.to_f >= 5.0 - tags << "~@rails_pre_5" - end - - if version.to_f == 5.0 - tags << "~@system_test" - end - - if tags.empty? - tags << "~@rails_post_5" - tags << "~@system_test" - end - if version.to_f >= 6.0 tags << "~@rails_pre_6" end @@ -69,7 +52,7 @@ namespace :generate do unless File.directory?('./tmp/example_app') bindir = File.expand_path("bin") - # Rails 4 cannot use a `rails` binstub generated by Bundler + # Rails 4+ cannot use a `rails` binstub generated by Bundler sh "rm -f #{bindir}/rails" sh "bundle exec rails new ./tmp/example_app --no-rc --skip-javascript --skip-bootsnap -skip-sprockets --skip-git --skip-test-unit --skip-listen --skip-bundle --template=example_app_generator/generate_app.rb" diff --git a/appveyor.yml b/appveyor.yml index b2fac867df..14d789b27f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -33,8 +33,6 @@ test_script: environment: matrix: - - ruby_version: 200 - - ruby_version: 21 - ruby_version: 22 - ruby_version: 23-x64 - ruby_version: 24-x64 diff --git a/example_app_generator/generate_app.rb b/example_app_generator/generate_app.rb index a407888601..905af11a40 100644 --- a/example_app_generator/generate_app.rb +++ b/example_app_generator/generate_app.rb @@ -25,31 +25,24 @@ gsub_file "Gemfile", /.*puma.*/, "" gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.3.6'" gsub_file "Gemfile", /.*bootsnap.*/, "" - if RUBY_VERSION < '2.2.2' - gsub_file "Gemfile", /.*rdoc.*/, "gem 'rdoc', '< 6'" - end - if Rails::VERSION::STRING >= '5.0.0' - append_to_file('Gemfile', "gem 'rails-controller-testing'\n") - end + append_to_file('Gemfile', "gem 'rails-controller-testing'\n") if Rails::VERSION::STRING >= '6' gsub_file "Gemfile", /.*gem..sqlite3.*/, "gem 'sqlite3', '~> 1.4'" gsub_file "Gemfile", /.*rails-controller-testing.*/, "gem 'rails-controller-testing', git: 'https://github.com/rails/rails-controller-testing'" end - if Rails::VERSION::STRING >= "5.1.0" - if RUBY_VERSION < "2.4" - gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.15.0'" - end - if Rails::VERSION::STRING >= "5.2.0" && RUBY_VERSION < '2.3.0' - gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers', '< 4.0.0'" - else - gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers'" - end + if RUBY_VERSION < "2.4" + gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.15.0'" + end + if RUBY_VERSION < '2.3.0' + gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers', '< 4.0.0'" + else + gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers'" end - if Rails::VERSION::STRING >= '5.2.0' && Rails::VERSION::STRING < '6' + if Rails::VERSION::STRING < '6' copy_file sqlite_initializer, 'config/initializers/sqlite3_fix.rb' end @@ -63,21 +56,7 @@ # Use our version of RSpec and Rails append_to_file 'Gemfile', <<-EOT.gsub(/^ +\|/, '') - |# Rack::Cache 1.3.0 requires Ruby >= 2.0.0 - |gem 'rack-cache', '< 1.3.0' if RUBY_VERSION < '2.0.0' - | - |if RUBY_VERSION >= '2.0.0' - | gem 'rake', '>= 10.0.0' - |elsif RUBY_VERSION >= '1.9.3' - | gem 'rake', '< 12.0.0' # rake 12 requires Ruby 2.0.0 or later - |else - | gem 'rake', '< 11.0.0' # rake 11 requires Ruby 1.9.3 or later - |end - | - |# Version 3 of mime-types 3 requires Ruby 2.0 - |if RUBY_VERSION < '2.0.0' - | gem 'mime-types', '< 3' - |end + |gem 'rake', '>= 10.0.0' | |gem 'rspec-rails', | :path => '#{rspec_rails_repo_path}', diff --git a/example_app_generator/no_active_record/app/models/in_memory/model.rb b/example_app_generator/no_active_record/app/models/in_memory/model.rb index 8e6cea7f8a..79ae3d83ed 100644 --- a/example_app_generator/no_active_record/app/models/in_memory/model.rb +++ b/example_app_generator/no_active_record/app/models/in_memory/model.rb @@ -1,6 +1,3 @@ -# Rails 4.0.x seems to be the only version that does not autoload `ActiveModel` -require 'active_model' - raise "ActiveRecord is defined but should not be!" if defined?(::ActiveRecord) module InMemory diff --git a/example_app_generator/spec/verify_mailer_preview_path_spec.rb b/example_app_generator/spec/verify_mailer_preview_path_spec.rb index 2b27522206..d4e5e49e72 100644 --- a/example_app_generator/spec/verify_mailer_preview_path_spec.rb +++ b/example_app_generator/spec/verify_mailer_preview_path_spec.rb @@ -16,12 +16,8 @@ def as_commandline(ops) end def capture_exec(*ops) - io = if RUBY_VERSION.to_f < 1.9 - IO.popen(as_commandline(ops)) - else - ops << { :err => [:child, :out] } - IO.popen(ops) - end + ops << { :err => [:child, :out] } + io = IO.popen(ops) # Necessary to ignore warnings from Rails code base out = io.readlines. reject { |line| line =~ /warning: circular argument reference/ }. diff --git a/example_app_generator/travis_retry_bundle_install.sh b/example_app_generator/travis_retry_bundle_install.sh index cdcc0644e1..bcc4467919 100755 --- a/example_app_generator/travis_retry_bundle_install.sh +++ b/example_app_generator/travis_retry_bundle_install.sh @@ -4,7 +4,7 @@ set -e source FUNCTIONS_SCRIPT_FILE echo "Starting bundle install using shared bundle path" -if is_mri_192_plus; then +if is_mri; then travis_retry eval "RUBYOPT=$RUBYOPT:' --enable rubygems' bundle install --gemfile ./Gemfile --path REPLACE_BUNDLE_PATH --retry=3 --jobs=3" else travis_retry eval "bundle install --gemfile ./Gemfile --path REPLACE_BUNDLE_PATH --retry=3 --jobs=3" diff --git a/features/controller_specs/anonymous_controller.feature b/features/controller_specs/anonymous_controller.feature index 283d6a6342..7892b4dfac 100644 --- a/features/controller_specs/anonymous_controller.feature +++ b/features/controller_specs/anonymous_controller.feature @@ -175,32 +175,6 @@ Feature: anonymous controller When I run `rspec spec` Then the examples should all pass - @rails_pre_5 - Scenario: Infer base class from the described class - Given a file named "spec/controllers/base_class_can_be_inferred_spec.rb" with: - """ruby - require "rails_helper" - - class ApplicationController < ActionController::Base; end - - class FoosController < ApplicationController; end - - RSpec.describe FoosController, :type => :controller do - controller do - def index - render :text => "Hello World" - end - end - - it "creates anonymous controller derived from FoosController" do - expect(controller).to be_a_kind_of(FoosController) - end - end - """ - When I run `rspec spec` - Then the examples should all pass - - @rails_post_5 Scenario: Infer base class from the described class Given a file named "spec/controllers/base_class_can_be_inferred_spec.rb" with: """ruby @@ -225,41 +199,6 @@ Feature: anonymous controller When I run `rspec spec` Then the examples should all pass - @rails_pre_5 - Scenario: Use `name` and `controller_name` from the described class - Given a file named "spec/controllers/get_name_and_controller_name_from_described_class_spec.rb" with: - """ruby - require "rails_helper" - - class ApplicationController < ActionController::Base; end - class FoosController < ApplicationController; end - - RSpec.describe "Access controller names", :type => :controller do - controller FoosController do - def index - @name = self.class.name - @controller_name = controller_name - render :text => "Hello World" - end - end - - before do - get :index - end - - it "gets the class name as described" do - expect(assigns[:name]).to eq('FoosController') - end - - it "gets the controller_name as described" do - expect(assigns[:controller_name]).to eq('foos') - end - end - """ - When I run `rspec spec` - Then the examples should all pass - - @rails_post_5 Scenario: Use `name` and `controller_name` from the described class Given a file named "spec/controllers/get_name_and_controller_name_from_described_class_spec.rb" with: """ruby @@ -293,39 +232,6 @@ Feature: anonymous controller When I run `rspec spec` Then the examples should all pass - @rails_pre_5 - Scenario: Invoke `around_filter` and `around_action` in base class - Given a file named "spec/controllers/application_controller_around_filter_spec.rb" with: - """ruby - require "rails_helper" - - class ApplicationController < ActionController::Base - around_filter :an_around_filter - - def an_around_filter - @callback_invoked = true - yield - end - end - - RSpec.describe ApplicationController, :type => :controller do - controller do - def index - render :nothing => true - end - end - - it "invokes the callback" do - get :index - - expect(assigns[:callback_invoked]).to be_truthy - end - end - """ - When I run `rspec spec` - Then the examples should all pass - - @rails_post_5 Scenario: Invoke `around_filter` and `around_action` in base class Given a file named "spec/controllers/application_controller_around_filter_spec.rb" with: """ruby @@ -357,192 +263,6 @@ Feature: anonymous controller When I run `rspec spec` Then the examples should all pass - @rails_pre_5 - Scenario: Anonymous controllers only create resource routes - Given a file named "spec/controllers/application_controller_spec.rb" with: - """ruby - require "rails_helper" - - if defined?(ActionController::UrlGenerationError) - ExpectedRoutingError = ActionController::UrlGenerationError - else - ExpectedRoutingError = ActionController::RoutingError - end - - RSpec.describe ApplicationController, :type => :controller do - controller do - def index - render :text => "index called" - end - - def create - render :text => "create called" - end - - def new - render :text => "new called" - end - - def show - render :text => "show called" - end - - def edit - render :text => "edit called" - end - - def update - render :text => "update called" - end - - def destroy - render :text => "destroy called" - end - - def willerror - render :text => "will not render" - end - end - - describe "#index" do - it "responds to GET" do - get :index - expect(response.body).to eq "index called" - end - - it "also responds to POST" do - post :index - expect(response.body).to eq "index called" - end - - it "also responds to PUT" do - put :index - expect(response.body).to eq "index called" - end - - it "also responds to DELETE" do - delete :index - expect(response.body).to eq "index called" - end - end - - describe "#create" do - it "responds to POST" do - post :create - expect(response.body).to eq "create called" - end - - # And the rest... - %w{get post put delete}.each do |calltype| - it "responds to #{calltype}" do - send(calltype, :create) - expect(response.body).to eq "create called" - end - end - end - - describe "#new" do - it "responds to GET" do - get :new - expect(response.body).to eq "new called" - end - - # And the rest... - %w{get post put delete}.each do |calltype| - it "responds to #{calltype}" do - send(calltype, :new) - expect(response.body).to eq "new called" - end - end - end - - describe "#edit" do - it "responds to GET" do - get :edit, :id => "anyid" - expect(response.body).to eq "edit called" - end - - it "requires the :id parameter" do - expect { get :edit }.to raise_error(ExpectedRoutingError) - end - - # And the rest... - %w{get post put delete}.each do |calltype| - it "responds to #{calltype}" do - send(calltype, :edit, {:id => "anyid"}) - expect(response.body).to eq "edit called" - end - end - end - - describe "#show" do - it "responds to GET" do - get :show, :id => "anyid" - expect(response.body).to eq "show called" - end - - it "requires the :id parameter" do - expect { get :show }.to raise_error(ExpectedRoutingError) - end - - # And the rest... - %w{get post put delete}.each do |calltype| - it "responds to #{calltype}" do - send(calltype, :show, {:id => "anyid"}) - expect(response.body).to eq "show called" - end - end - end - - describe "#update" do - it "responds to PUT" do - put :update, :id => "anyid" - expect(response.body).to eq "update called" - end - - it "requires the :id parameter" do - expect { put :update }.to raise_error(ExpectedRoutingError) - end - - # And the rest... - %w{get post put delete}.each do |calltype| - it "responds to #{calltype}" do - send(calltype, :update, {:id => "anyid"}) - expect(response.body).to eq "update called" - end - end - end - - describe "#destroy" do - it "responds to DELETE" do - delete :destroy, :id => "anyid" - expect(response.body).to eq "destroy called" - end - - it "requires the :id parameter" do - expect { delete :destroy }.to raise_error(ExpectedRoutingError) - end - - # And the rest... - %w{get post put delete}.each do |calltype| - it "responds to #{calltype}" do - send(calltype, :destroy, {:id => "anyid"}) - expect(response.body).to eq "destroy called" - end - end - end - - describe "#willerror" do - it "cannot be called" do - expect { get :willerror }.to raise_error(ExpectedRoutingError) - end - end - end - """ - When I run `rspec spec` - Then the examples should all pass - - @rails_post_5 Scenario: Anonymous controllers only create resource routes Given a file named "spec/controllers/application_controller_spec.rb" with: """ruby @@ -727,31 +447,6 @@ Feature: anonymous controller When I run `rspec spec` Then the examples should all pass - @rails_pre_5 - Scenario: Draw custom routes for anonymous controllers - Given a file named "spec/controllers/application_controller_spec.rb" with: - """ruby - require "rails_helper" - - RSpec.describe ApplicationController, :type => :controller do - controller do - def custom - render :text => "custom called" - end - end - - specify "manually draw the route to request a custom action" do - routes.draw { get "custom" => "anonymous#custom" } - - get :custom - expect(response.body).to eq "custom called" - end - end - """ - When I run `rspec spec` - Then the examples should all pass - - @rails_post_5 Scenario: Draw custom routes for anonymous controllers Given a file named "spec/controllers/application_controller_spec.rb" with: """ruby @@ -775,33 +470,6 @@ Feature: anonymous controller When I run `rspec spec` Then the examples should all pass - @rails_pre_5 - Scenario: Draw custom routes for anonymous controllers which don't inherit from application controller - Given a file named "spec/controllers/other_controller_spec.rb" with: - """ruby - require "rails_helper" - class OtherController < ActionController::Base - end - - RSpec.describe OtherController, :type => :controller do - controller do - def custom - render :text => "custom called" - end - end - - specify "manually draw the route to request a custom action" do - routes.draw { get "custom" => "other#custom" } - - get :custom - expect(response.body).to eq "custom called" - end - end - """ - When I run `rspec spec` - Then the examples should all pass - - @rails_post_5 Scenario: Draw custom routes for anonymous controllers which don't inherit from application controller Given a file named "spec/controllers/other_controller_spec.rb" with: """ruby @@ -827,33 +495,6 @@ Feature: anonymous controller When I run `rspec spec` Then the examples should all pass - @rails_pre_5 - Scenario: Draw custom routes for defined controllers - Given a file named "spec/controllers/application_controller_spec.rb" with: - """ruby - require "rails_helper" - - class FoosController < ApplicationController; end - - RSpec.describe ApplicationController, :type => :controller do - controller FoosController do - def custom - render :text => "custom called" - end - end - - specify "manually draw the route to request a custom action" do - routes.draw { get "custom" => "foos#custom" } - - get :custom - expect(response.body).to eq "custom called" - end - end - """ - When I run `rspec spec` - Then the examples should all pass - - @rails_post_5 Scenario: Draw custom routes for defined controllers Given a file named "spec/controllers/application_controller_spec.rb" with: """ruby @@ -879,50 +520,6 @@ Feature: anonymous controller When I run `rspec spec` Then the examples should all pass - @rails_pre_5 - Scenario: Works with namespaced controllers - Given a file named "spec/controllers/namespaced_controller_spec.rb" with: - """ruby - require "rails_helper" - - class ApplicationController < ActionController::Base; end - - module Outer - module Inner - class FoosController < ApplicationController; end - end - end - - RSpec.describe Outer::Inner::FoosController, :type => :controller do - controller do - def index - @name = self.class.name - @controller_name = controller_name - render :text => "Hello World" - end - end - - it "creates anonymous controller derived from the namespace" do - expect(controller).to be_a_kind_of(Outer::Inner::FoosController) - end - - it "gets the class name as described" do - expect{ get :index }.to change{ - assigns[:name] - }.to eq('Outer::Inner::FoosController') - end - - it "gets the controller_name as described" do - expect{ get :index }.to change{ - assigns[:controller_name] - }.to eq('foos') - end - end - """ - When I run `rspec spec` - Then the examples should all pass - - @rails_post_5 Scenario: Works with namespaced controllers Given a file named "spec/controllers/namespaced_controller_spec.rb" with: """ruby diff --git a/features/controller_specs/controller_spec.feature b/features/controller_specs/controller_spec.feature index d4c8e41dfb..6ce5706beb 100644 --- a/features/controller_specs/controller_spec.feature +++ b/features/controller_specs/controller_spec.feature @@ -34,30 +34,7 @@ Feature: controller spec When I run `rspec spec` Then the example should pass - @rails_pre_5 - 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, { :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, { :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_5 @rails_pre_6 + @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 diff --git a/features/controller_specs/engine_routes.feature b/features/controller_specs/engine_routes.feature index 35845c6a0e..6493c6008f 100644 --- a/features/controller_specs/engine_routes.feature +++ b/features/controller_specs/engine_routes.feature @@ -3,7 +3,6 @@ Feature: engine routes for controllers Controller specs can specify the routeset that will be used for the example group. This is most useful when testing Rails engines. - @unsupported-on-rails-3-0 Scenario: specify engine route Given a file named "spec/controllers/widgets_controller_spec.rb" with: """ruby diff --git a/features/feature_specs/feature_spec.feature b/features/feature_specs/feature_spec.feature index 59558d72d7..fb8c771a9f 100644 --- a/features/feature_specs/feature_spec.feature +++ b/features/feature_specs/feature_spec.feature @@ -20,35 +20,6 @@ Feature: Feature spec [customer](http://c2.com/cgi/wiki?CustomerTest) and [acceptance](http://c2.com/cgi/wiki?AcceptanceTest) tests. When capybara is required it sets `:type => :feature` automatically for you. - @rails_pre_5.1 - Scenario: Feature specs are skipped without Capybara - Given a file named "spec/features/widget_management_spec.rb" with: - """ruby - require "rails_helper" - - RSpec.feature "Widget management", :type => :feature do - scenario "User creates a new widget" do - visit "/widgets/new" - - fill_in "Name", :with => "My Widget" - click_button "Create Widget" - - expect(page).to have_text("Widget was successfully created.") - end - end - """ - When I run `rspec spec/features/widget_management_spec.rb` - Then the exit status should be 0 - And the output should contain "1 example, 0 failures, 1 pending" - And the output should contain: - """ - Pending: (Failures listed here are expected and do not affect your suite's status) - - 1) Widget management User creates a new widget - # Feature specs require the Capybara (https://github.com/jnicklas/capybara) gem, version 2.2.0 or later. We recommend version 2.4.0 or later to avoid some deprecation warnings and have support for `config.expose_dsl_globally = false`. - # ./spec/features/widget_management_spec.rb:4 - """ - @capybara Scenario: specify creating a Widget by driving the application with capybara Given a file named "spec/features/widget_management_spec.rb" with: diff --git a/features/mailer_specs/mailer_spec.feature b/features/mailer_specs/mailer_spec.feature index cd36e4ff5d..7036193018 100644 --- a/features/mailer_specs/mailer_spec.feature +++ b/features/mailer_specs/mailer_spec.feature @@ -1,6 +1,5 @@ Feature: mailer spec - @rails_post_5 Scenario: simple passing example Given a file named "spec/mailers/notifications_mailer_spec.rb" with: """ruby @@ -24,30 +23,3 @@ Feature: mailer spec """ When I run `rspec spec` Then the example should pass - - @rails_pre_5 - Scenario: using URL helpers without default options - Given a file named "config/initializers/mailer_defaults.rb" with: - """ruby - # no default options - """ - And a file named "spec/mailers/notifications_spec.rb" with: - """ruby - require 'rails_helper' - - RSpec.describe Notifications, :type => :mailer do - let(:mail) { Notifications.signup } - - it "renders the headers" do - expect(mail.subject).to eq("Signup") - expect(mail.to).to eq(["to@example.org"]) - expect(mail.from).to eq(["from@example.com"]) - end - - it 'renders the body' do - expect(mail.body.encoded).to match("Hi") - end - end - """ - When I run `rspec spec` - Then the examples should all pass diff --git a/features/mailer_specs/url_helpers.feature b/features/mailer_specs/url_helpers.feature index 8c1353022e..4e82101303 100644 --- a/features/mailer_specs/url_helpers.feature +++ b/features/mailer_specs/url_helpers.feature @@ -3,7 +3,6 @@ Feature: URL helpers in mailer examples Mailer specs are marked by `:type => :mailer` or if you have set `config.infer_spec_type_from_file_location!` by placing them in `spec/mailers`. - @rails_post_5 Scenario: using URL helpers with default options Given a file named "config/initializers/mailer_defaults.rb" with: """ruby @@ -22,7 +21,6 @@ Feature: URL helpers in mailer examples When I run `rspec spec` Then the examples should all pass - @rails_post_5 Scenario: using URL helpers without default options Given a file named "config/initializers/mailer_defaults.rb" with: """ruby @@ -41,42 +39,3 @@ Feature: URL helpers in mailer examples """ When I run `rspec spec` Then the examples should all pass - - @rails_pre_5 - Scenario: using URL helpers with default options - Given a file named "config/initializers/mailer_defaults.rb" with: - """ruby - Rails.configuration.action_mailer.default_url_options = { :host => 'example.com' } - """ - And a file named "spec/mailers/notifications_spec.rb" with: - """ruby - require 'rails_helper' - - RSpec.describe Notifications, :type => :mailer do - it 'should have access to URL helpers' do - expect { gadgets_url }.not_to raise_error - end - end - """ - When I run `rspec spec` - Then the examples should all pass - - @rails_pre_5 - Scenario: using URL helpers without default options - Given a file named "config/initializers/mailer_defaults.rb" with: - """ruby - # no default options - """ - And a file named "spec/mailers/notifications_spec.rb" with: - """ruby - require 'rails_helper' - - RSpec.describe Notifications, :type => :mailer do - it 'should have access to URL helpers' do - expect { gadgets_url :host => 'example.com' }.not_to raise_error - expect { gadgets_url }.to raise_error - end - end - """ - When I run `rspec spec` - Then the examples should all pass diff --git a/features/matchers/have_enqueued_mail_matcher.feature b/features/matchers/have_enqueued_mail_matcher.feature index e1ebbf886e..9942c5cbd7 100644 --- a/features/matchers/have_enqueued_mail_matcher.feature +++ b/features/matchers/have_enqueued_mail_matcher.feature @@ -5,7 +5,6 @@ Feature: have_enqueued_mail matcher Background: Given active job is available - @rails_post_5 Scenario: Checking mailer class and method name Given a file named "spec/mailers/user_mailer_spec.rb" with: """ruby @@ -23,7 +22,6 @@ Feature: have_enqueued_mail matcher When I run `rspec spec/mailers/user_mailer_spec.rb` Then the examples should all pass - @rails_post_5 Scenario: Checking mailer enqueued time Given a file named "spec/mailers/user_mailer_spec.rb" with: """ruby @@ -40,39 +38,3 @@ Feature: have_enqueued_mail matcher """ When I run `rspec spec/mailers/user_mailer_spec.rb` Then the examples should all pass - - @rails_pre_5 - Scenario: Checking mailer class and method name - Given a file named "spec/mailers/user_mailer_spec.rb" with: - """ruby - require "rails_helper" - - RSpec.describe Notifications do - it "matches with enqueued mailer" do - ActiveJob::Base.queue_adapter = :test - expect { - Notifications.signup.deliver_later - }.to have_enqueued_mail(Notifications, :signup) - end - end - """ - When I run `rspec spec/mailers/user_mailer_spec.rb` - Then the examples should all pass - - @rails_pre_5 - Scenario: Checking mailer enqueued time - Given a file named "spec/mailers/user_mailer_spec.rb" with: - """ruby - require "rails_helper" - - RSpec.describe Notifications do - it "matches with enqueued mailer" do - ActiveJob::Base.queue_adapter = :test - expect { - Notifications.signup.deliver_later(:wait_until => Date.tomorrow.noon) - }.to have_enqueued_mail.at(Date.tomorrow.noon) - end - end - """ - When I run `rspec spec/mailers/user_mailer_spec.rb` - Then the examples should all pass diff --git a/features/matchers/have_http_status_matcher.feature b/features/matchers/have_http_status_matcher.feature index 38f6252924..27690ecda9 100644 --- a/features/matchers/have_http_status_matcher.feature +++ b/features/matchers/have_http_status_matcher.feature @@ -104,32 +104,6 @@ Feature: `have_http_status` matcher When I run `rspec spec/controllers/gadgets_spec.rb` Then the examples should all pass - @rails_pre_5 - Scenario: Using in a request spec - Given a file named "spec/requests/gadgets/widget_management_spec.rb" with: - """ruby - require "rails_helper" - - RSpec.describe "Widget management", :type => :request do - - it "creates a Widget and redirects to the Widget's page" do - get "/widgets/new" - expect(response).to have_http_status(:ok) - - post "/widgets", :widget => {:name => "My Widget"} - expect(response).to have_http_status(302) - - follow_redirect! - - expect(response).to have_http_status(:success) - end - - end - """ - When I run `rspec spec/requests` - Then the examples should all pass - - @rails_post_5 Scenario: Using in a request spec Given a file named "spec/requests/gadgets/widget_management_spec.rb" with: """ruby diff --git a/features/matchers/redirect_to_matcher.feature b/features/matchers/redirect_to_matcher.feature index e58c95aee0..a4b634202e 100644 --- a/features/matchers/redirect_to_matcher.feature +++ b/features/matchers/redirect_to_matcher.feature @@ -7,40 +7,6 @@ Feature: redirect_to matcher It is available in controller specs (spec/controllers) and request specs (spec/requests). - @rails_pre_5 - Scenario: redirect_to with four possible options - Given a file named "spec/controllers/widgets_controller_spec.rb" with: - """ruby - require "rails_helper" - - RSpec.describe WidgetsController do - - describe "#create" do - subject { post :create, :widget => { :name => "Foo" } } - - it "redirects to widget_url(@widget)" do - expect(subject).to redirect_to(widget_url(assigns(:widget))) - end - - it "redirects_to :action => :show" do - expect(subject).to redirect_to :action => :show, - :id => assigns(:widget).id - end - - it "redirects_to(@widget)" do - expect(subject).to redirect_to(assigns(:widget)) - end - - it "redirects_to /widgets/:id" do - expect(subject).to redirect_to("/widgets/#{assigns(:widget).id}") - end - end - end - """ - When I run `rspec spec/controllers/widgets_controller_spec.rb` - Then the examples should all pass - - @rails_post_5 Scenario: redirect_to with four possible options Given a file named "spec/controllers/widgets_controller_spec.rb" with: """ruby diff --git a/features/request_specs/request_spec.feature b/features/request_specs/request_spec.feature index 085a94fb4a..78aaae4fed 100644 --- a/features/request_specs/request_spec.feature +++ b/features/request_specs/request_spec.feature @@ -26,37 +26,6 @@ Feature: request spec request specs as of Capybara 2.0.0. The recommended way to use Capybara is with [feature specs](../feature-specs/feature-spec). - @rails_pre_5 - Scenario: specify managing a Widget with Rails integration methods - 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 and redirects to the Widget's page" do - get "/widgets/new" - expect(response).to render_template(:new) - - post "/widgets", :widget => {:name => "My Widget"} - - expect(response).to redirect_to(assigns(:widget)) - follow_redirect! - - expect(response).to render_template(:show) - expect(response.body).to include("Widget was successfully created.") - end - - it "does not render a different template" do - get "/widgets/new" - expect(response).to_not render_template(:show) - end - end - """ - When I run `rspec spec/requests/widget_management_spec.rb` - Then the example should pass - - @rails_post_5 Scenario: specify managing a Widget with Rails integration methods Given a file named "spec/requests/widget_management_spec.rb" with: """ruby @@ -86,31 +55,7 @@ Feature: request spec When I run `rspec spec/requests/widget_management_spec.rb` Then the example should pass - @unsupported-on-rails-3-0 @rails_pre_5 - 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", # This is what Rails 4 accepts - "HTTP_ACCEPT" => "application/json" # This is what Rails 3 accepts - } - post "/widgets", { :widget => {:name => "My Widget"} }, 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_5 @rails_pre_6 + @rails_pre_6 Scenario: requesting a JSON response Given a file named "spec/requests/widget_management_spec.rb" with: """ruby @@ -150,26 +95,6 @@ Feature: request spec When I run `rspec spec/requests/widget_management_spec.rb` Then the example should pass - @rails_pre_5 - Scenario: providing JSON data - 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 and redirects to the Widget's page" do - headers = { "CONTENT_TYPE" => "application/json" } - post "/widgets", '{ "widget": { "name":"My Widget" } }', headers - expect(response).to redirect_to(assigns(:widget)) - end - - end - """ - When I run `rspec spec/requests/widget_management_spec.rb` - Then the example should pass - - @rails_post_5 Scenario: providing JSON data Given a file named "spec/requests/widget_management_spec.rb" with: """ruby diff --git a/features/routing_specs/engine_routes.feature b/features/routing_specs/engine_routes.feature index 327809394d..dfa9764fbe 100644 --- a/features/routing_specs/engine_routes.feature +++ b/features/routing_specs/engine_routes.feature @@ -3,7 +3,6 @@ Feature: engine routes Routing specs can specify the routeset that will be used for the example group. This is most useful when testing Rails engines. - @unsupported-on-rails-3-0 Scenario: specify engine route Given a file named "spec/routing/engine_routes_spec.rb" with: """ruby diff --git a/features/step_definitions/additional_cli_steps.rb b/features/step_definitions/additional_cli_steps.rb index 622ddbec33..f397dd73b7 100644 --- a/features/step_definitions/additional_cli_steps.rb +++ b/features/step_definitions/additional_cli_steps.rb @@ -27,12 +27,6 @@ end end -Given /file fixtures are available/ do - if !RSpec::Rails::FeatureCheck.has_file_fixture? - pending "file fixtures are not available" - end -end - Given /action cable testing is available/ do if !RSpec::Rails::FeatureCheck.has_action_cable_testing? pending "Action Cable testing is not available" diff --git a/features/support/capybara.rb b/features/support/capybara.rb index f9894f995d..6009be9f3e 100644 --- a/features/support/capybara.rb +++ b/features/support/capybara.rb @@ -1,10 +1,4 @@ Around "@capybara" do |scenario, block| - # We are caught in a weird situation here. rspec-rails supports 1.8.7 and - # above, but capybara beyond a certain version only supports 1.9.3 and above. - # On 1.8.7 and 1.9.2, we run most of the rspec-rails test suite but leave out - # parts that require capybara. - if RUBY_VERSION >= '1.9.3' - require 'capybara' - block.call - end + require 'capybara' + block.call end diff --git a/features/support/rails_versions.rb b/features/support/rails_versions.rb deleted file mode 100644 index c2fb48cf0f..0000000000 --- a/features/support/rails_versions.rb +++ /dev/null @@ -1,4 +0,0 @@ -Around "@unsupported-on-rails-3-0" do |scenario, block| - require 'rails' - block.call unless ::Rails.version.to_s.start_with?("3.0") -end diff --git a/features/view_specs/view_spec.feature b/features/view_specs/view_spec.feature index 21a1af2c85..724bc4cae2 100644 --- a/features/view_specs/view_spec.feature +++ b/features/view_specs/view_spec.feature @@ -197,25 +197,6 @@ Feature: view spec When I run `rspec spec/views` Then the examples should all pass - @rails_pre_5 - Scenario: View specs can render text - Given a file named "spec/views/widgets/direct.html.erb_spec.rb" with: - """ruby - require "rails_helper" - - RSpec.describe "rendering text directly" do - it "displays the given text" do - - render :text => "This is directly rendered" - - expect(rendered).to match /directly rendered/ - end - end - """ - When I run `rspec spec/views` - Then the examples should all pass - - @rails_post_5 Scenario: View specs can render text Given a file named "spec/views/widgets/direct.html.erb_spec.rb" with: """ruby diff --git a/lib/generators/rspec/install/templates/spec/rails_helper.rb b/lib/generators/rspec/install/templates/spec/rails_helper.rb index 03672af7f6..eb579d9e45 100644 --- a/lib/generators/rspec/install/templates/spec/rails_helper.rb +++ b/lib/generators/rspec/install/templates/spec/rails_helper.rb @@ -1,11 +1,7 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' -<% if RUBY_VERSION >= '2.0.0' %> require File.expand_path('../config/environment', __dir__) -<% else %> -require File.expand_path('../../config/environment', __FILE__) -<% end %> # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rails.env.production? require 'rspec/rails' diff --git a/lib/generators/rspec/scaffold/templates/api_controller_spec.rb b/lib/generators/rspec/scaffold/templates/api_controller_spec.rb index 39d055b674..47347f5ead 100644 --- a/lib/generators/rspec/scaffold/templates/api_controller_spec.rb +++ b/lib/generators/rspec/scaffold/templates/api_controller_spec.rb @@ -46,11 +46,7 @@ describe "GET #index" do it "returns a success response" do <%= file_name %> = <%= class_name %>.create! valid_attributes -<% if RUBY_VERSION < '1.9.3' -%> - get :index, {}, valid_session -<% else -%> get :index, params: {}, session: valid_session -<% end -%> expect(response).to be_successful end end @@ -59,11 +55,7 @@ describe "GET #show" do it "returns a success response" do <%= file_name %> = <%= class_name %>.create! valid_attributes -<% if RUBY_VERSION < '1.9.3' -%> - get :show, {:id => <%= file_name %>.to_param}, valid_session -<% else -%> get :show, params: {id: <%= file_name %>.to_param}, session: valid_session -<% end -%> expect(response).to be_successful end end @@ -72,20 +64,12 @@ context "with valid params" do it "creates a new <%= class_name %>" do expect { -<% if RUBY_VERSION < '1.9.3' -%> - post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session -<% else -%> post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session -<% end -%> }.to change(<%= class_name %>, :count).by(1) end it "renders a JSON response with the new <%= ns_file_name %>" do -<% if RUBY_VERSION < '1.9.3' -%> - post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session -<% else %> post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session -<% end -%> expect(response).to have_http_status(:created) expect(response.content_type).to eq('application/json') expect(response.location).to eq(<%= ns_file_name %>_url(<%= class_name %>.last)) @@ -94,11 +78,7 @@ context "with invalid params" do it "renders a JSON response with errors for the new <%= ns_file_name %>" do -<% if RUBY_VERSION < '1.9.3' -%> - post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session -<% else %> post :create, params: {<%= ns_file_name %>: invalid_attributes}, session: valid_session -<% end -%> expect(response).to have_http_status(:unprocessable_entity) expect(response.content_type).to eq('application/json') end @@ -113,22 +93,14 @@ it "updates the requested <%= ns_file_name %>" do <%= file_name %> = <%= class_name %>.create! valid_attributes -<% if RUBY_VERSION < '1.9.3' -%> - put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => new_attributes}, valid_session -<% else -%> put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, session: valid_session -<% end -%> <%= file_name %>.reload skip("Add assertions for updated state") end it "renders a JSON response with the <%= ns_file_name %>" do <%= file_name %> = <%= class_name %>.create! valid_attributes -<% if RUBY_VERSION < '1.9.3' -%> - put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session -<% else %> put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, session: valid_session -<% end -%> expect(response).to have_http_status(:ok) expect(response.content_type).to eq('application/json') end @@ -137,11 +109,7 @@ context "with invalid params" do it "renders a JSON response with errors for the <%= ns_file_name %>" do <%= file_name %> = <%= class_name %>.create! valid_attributes -<% if RUBY_VERSION < '1.9.3' -%> - put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session -<% else %> put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, session: valid_session -<% end -%> expect(response).to have_http_status(:unprocessable_entity) expect(response.content_type).to eq('application/json') end @@ -152,11 +120,7 @@ it "destroys the requested <%= ns_file_name %>" do <%= file_name %> = <%= class_name %>.create! valid_attributes expect { -<% if RUBY_VERSION < '1.9.3' -%> - delete :destroy, {:id => <%= file_name %>.to_param}, valid_session -<% else -%> delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session -<% end -%> }.to change(<%= class_name %>, :count).by(-1) end end diff --git a/lib/generators/rspec/scaffold/templates/controller_spec.rb b/lib/generators/rspec/scaffold/templates/controller_spec.rb index 7f5799a199..094089a272 100644 --- a/lib/generators/rspec/scaffold/templates/controller_spec.rb +++ b/lib/generators/rspec/scaffold/templates/controller_spec.rb @@ -46,11 +46,7 @@ describe "GET #index" do it "returns a success response" do <%= class_name %>.create! valid_attributes -<% if Rails::VERSION::STRING < '5.0' -%> - get :index, {}, valid_session -<% else -%> get :index, params: {}, session: valid_session -<% end -%> expect(response).to be_successful end end @@ -59,22 +55,14 @@ describe "GET #show" do it "returns a success response" do <%= file_name %> = <%= class_name %>.create! valid_attributes -<% if Rails::VERSION::STRING < '5.0' -%> - get :show, {:id => <%= file_name %>.to_param}, valid_session -<% else -%> get :show, params: {id: <%= file_name %>.to_param}, session: valid_session -<% end -%> expect(response).to be_successful end end describe "GET #new" do it "returns a success response" do -<% if Rails::VERSION::STRING < '5.0' -%> - get :new, {}, valid_session -<% else -%> get :new, params: {}, session: valid_session -<% end -%> expect(response).to be_successful end end @@ -82,11 +70,7 @@ describe "GET #edit" do it "returns a success response" do <%= file_name %> = <%= class_name %>.create! valid_attributes -<% if Rails::VERSION::STRING < '5.0' -%> - get :edit, {:id => <%= file_name %>.to_param}, valid_session -<% else -%> get :edit, params: {id: <%= file_name %>.to_param}, session: valid_session -<% end -%> expect(response).to be_successful end end @@ -95,31 +79,19 @@ context "with valid params" do it "creates a new <%= class_name %>" do expect { -<% if Rails::VERSION::STRING < '5.0' -%> - post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session -<% else -%> post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session -<% end -%> }.to change(<%= class_name %>, :count).by(1) end it "redirects to the created <%= ns_file_name %>" do -<% if Rails::VERSION::STRING < '5.0' -%> - post :create, {:<%= ns_file_name %> => valid_attributes}, valid_session -<% else -%> post :create, params: {<%= ns_file_name %>: valid_attributes}, session: valid_session -<% end -%> expect(response).to redirect_to(<%= class_name %>.last) end end context "with invalid params" do it "returns a success response (i.e. to display the 'new' template)" do -<% if Rails::VERSION::STRING < '5.0' -%> - post :create, {:<%= ns_file_name %> => invalid_attributes}, valid_session -<% else -%> post :create, params: {<%= ns_file_name %>: invalid_attributes}, session: valid_session -<% end -%> expect(response).to be_successful end end @@ -133,22 +105,14 @@ it "updates the requested <%= ns_file_name %>" do <%= file_name %> = <%= class_name %>.create! valid_attributes -<% if Rails::VERSION::STRING < '5.0' -%> - put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => new_attributes}, valid_session -<% else -%> put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: new_attributes}, session: valid_session -<% end -%> <%= file_name %>.reload skip("Add assertions for updated state") end it "redirects to the <%= ns_file_name %>" do <%= file_name %> = <%= class_name %>.create! valid_attributes -<% if Rails::VERSION::STRING < '5.0' -%> - put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => valid_attributes}, valid_session -<% else -%> put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: valid_attributes}, session: valid_session -<% end -%> expect(response).to redirect_to(<%= file_name %>) end end @@ -156,11 +120,7 @@ context "with invalid params" do it "returns a success response (i.e. to display the 'edit' template)" do <%= file_name %> = <%= class_name %>.create! valid_attributes -<% if Rails::VERSION::STRING < '5.0' -%> - put :update, {:id => <%= file_name %>.to_param, :<%= ns_file_name %> => invalid_attributes}, valid_session -<% else -%> put :update, params: {id: <%= file_name %>.to_param, <%= ns_file_name %>: invalid_attributes}, session: valid_session -<% end -%> expect(response).to be_successful end end @@ -170,21 +130,13 @@ it "destroys the requested <%= ns_file_name %>" do <%= file_name %> = <%= class_name %>.create! valid_attributes expect { -<% if Rails::VERSION::STRING < '5.0' -%> - delete :destroy, {:id => <%= file_name %>.to_param}, valid_session -<% else -%> delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session -<% end -%> }.to change(<%= class_name %>, :count).by(-1) end it "redirects to the <%= table_name %> list" do <%= file_name %> = <%= class_name %>.create! valid_attributes -<% if Rails::VERSION::STRING < '5.0' -%> - delete :destroy, {:id => <%= file_name %>.to_param}, valid_session -<% else -%> delete :destroy, params: {id: <%= file_name %>.to_param}, session: valid_session -<% end -%> expect(response).to redirect_to(<%= index_helper %>_url) end end diff --git a/lib/generators/rspec/system/system_generator.rb b/lib/generators/rspec/system/system_generator.rb index 937241733e..029726976b 100644 --- a/lib/generators/rspec/system/system_generator.rb +++ b/lib/generators/rspec/system/system_generator.rb @@ -1,25 +1,23 @@ require 'generators/rspec' -if ::Rails::VERSION::STRING >= '5.1' - module Rspec - module Generators - # @private - class SystemGenerator < Base - class_option :system_specs, :type => :boolean, :default => true, :desc => "Generate system specs" +module Rspec + module Generators + # @private + class SystemGenerator < Base + class_option :system_specs, :type => :boolean, :default => true, :desc => "Generate system specs" - def generate_system_spec - return unless options[:system_specs] + def generate_system_spec + return unless options[:system_specs] - template template_name, File.join('spec/system', class_path, filename) - end + template template_name, File.join('spec/system', class_path, filename) + end - def template_name - 'system_spec.rb' - end + def template_name + 'system_spec.rb' + end - def filename - "#{table_name}_spec.rb" - end + def filename + "#{table_name}_spec.rb" end end end diff --git a/lib/rspec-rails.rb b/lib/rspec-rails.rb index 2cabaaf16a..460c01818e 100644 --- a/lib/rspec-rails.rb +++ b/lib/rspec-rails.rb @@ -7,16 +7,13 @@ module Rails # Railtie to hook into Rails. class Railtie < ::Rails::Railtie # As of Rails 5.1.0 you can register directories to work with `rake notes` - if ::Rails::VERSION::STRING >= '5.1' - require 'rails/source_annotation_extractor' - if ::Rails::VERSION::STRING >= '6.0' - ::Rails::SourceAnnotationExtractor::Annotation.register_directories("spec") - else - SourceAnnotationExtractor::Annotation.register_directories("spec") - end + 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-3.0.1 requires config.app_generators instead of 3.0.0's config.generators - generators = config.respond_to?(:app_generators) ? config.app_generators : config.generators + generators = config.app_generators generators.integration_tool :rspec generators.test_framework :rspec diff --git a/lib/rspec/rails/configuration.rb b/lib/rspec/rails/configuration.rb index 38d67f9501..9c37df8af6 100644 --- a/lib/rspec/rails/configuration.rb +++ b/lib/rspec/rails/configuration.rb @@ -79,10 +79,8 @@ def self.initialize_configuration(config) # `RSpec::Rails::FixtureSupport` directly instead config.include RSpec::Rails::FixtureSupport - if ::Rails::VERSION::STRING > '5' - config.add_setting :file_fixture_path, :default => 'spec/fixtures/files' - config.include RSpec::Rails::FileFixtureSupport - end + config.add_setting :file_fixture_path, :default => 'spec/fixtures/files' + config.include RSpec::Rails::FileFixtureSupport # Add support for fixture_path on fixture_file_upload config.include RSpec::Rails::FixtureFileUploadSupport diff --git a/lib/rspec/rails/example/controller_example_group.rb b/lib/rspec/rails/example/controller_example_group.rb index 198f22ab5f..6c1d370b55 100644 --- a/lib/rspec/rails/example/controller_example_group.rb +++ b/lib/rspec/rails/example/controller_example_group.rb @@ -29,18 +29,11 @@ def controller_class # `body` in that context. Also sets up implicit routes for this # controller, that are separate from those defined in "config/routes.rb". # - # @note Due to Ruby 1.8 scoping rules in anonymous subclasses, constants - # defined in `ApplicationController` must be fully qualified (e.g. - # `ApplicationController::AccessDenied`) in the block passed to the - # `controller` method. Any instance methods, filters, etc, that are - # defined in `ApplicationController`, however, are accessible from - # within the block. - # # @example # describe ApplicationController do # controller do # def index - # raise ApplicationController::AccessDenied + # raise AccessDenied # end # end # diff --git a/lib/rspec/rails/feature_check.rb b/lib/rspec/rails/feature_check.rb index 3f48a9cb76..1c410be6bb 100644 --- a/lib/rspec/rails/feature_check.rb +++ b/lib/rspec/rails/feature_check.rb @@ -54,10 +54,6 @@ def has_action_mailbox? defined?(::ActionMailbox) end - def has_file_fixture? - ::Rails::VERSION::STRING > '5.0' - end - def type_metatag(type) "type: :#{type}" end diff --git a/lib/rspec/rails/file_fixture_support.rb b/lib/rspec/rails/file_fixture_support.rb index f434ca5cda..45059a38d1 100644 --- a/lib/rspec/rails/file_fixture_support.rb +++ b/lib/rspec/rails/file_fixture_support.rb @@ -1,16 +1,14 @@ -if ::Rails::VERSION::STRING > '5' - require 'active_support/testing/file_fixtures' +require 'active_support/testing/file_fixtures' - module RSpec - module Rails - # @private - module FileFixtureSupport - extend ActiveSupport::Concern - include ActiveSupport::Testing::FileFixtures +module RSpec + module Rails + # @private + module FileFixtureSupport + extend ActiveSupport::Concern + include ActiveSupport::Testing::FileFixtures - included do - self.file_fixture_path = RSpec.configuration.file_fixture_path - end + included do + self.file_fixture_path = RSpec.configuration.file_fixture_path end end end diff --git a/lib/rspec/rails/fixture_support.rb b/lib/rspec/rails/fixture_support.rb index 1855588261..81716d32b2 100644 --- a/lib/rspec/rails/fixture_support.rb +++ b/lib/rspec/rails/fixture_support.rb @@ -22,11 +22,7 @@ module FixtureSupport # /TODO self.fixture_path = RSpec.configuration.fixture_path - if ::Rails::VERSION::STRING > '5' - self.use_transactional_tests = RSpec.configuration.use_transactional_fixtures - else - self.use_transactional_fixtures = RSpec.configuration.use_transactional_fixtures - end + self.use_transactional_tests = RSpec.configuration.use_transactional_fixtures self.use_instantiated_fixtures = RSpec.configuration.use_instantiated_fixtures def self.fixtures(*args) diff --git a/lib/rspec/rails/matchers/base_matcher.rb b/lib/rspec/rails/matchers/base_matcher.rb index 7d9130a506..7f8682d2a5 100644 --- a/lib/rspec/rails/matchers/base_matcher.rb +++ b/lib/rspec/rails/matchers/base_matcher.rb @@ -119,15 +119,7 @@ def assert_ivars(*expected_ivars) raise "#{self.class.name} needs to supply#{ivar_list}" end - if RUBY_VERSION.to_f < 1.9 - # :nocov: - def present_ivars - instance_variables.map(&:to_sym) - end - # :nocov: - else - alias present_ivars instance_variables - end + alias present_ivars instance_variables # @private module HashFormatting diff --git a/lib/rspec/rails/tasks/rspec.rake b/lib/rspec/rails/tasks/rspec.rake index 339de95bc6..fea97cf031 100644 --- a/lib/rspec/rails/tasks/rspec.rake +++ b/lib/rspec/rails/tasks/rspec.rake @@ -35,14 +35,11 @@ namespace :spec do end end - # RCov task only enabled for Ruby 1.8 - if RUBY_VERSION < '1.9' - desc "Run all specs with rcov" - RSpec::Core::RakeTask.new(:rcov => "spec:prepare") do |t| - t.rcov = true - t.pattern = "./spec/**/*_spec.rb" - t.rcov_opts = '--exclude /gems/,/Library/,/usr/,lib/tasks,.bundle,config,/lib/rspec/,/lib/rspec-,spec' - end + desc "Run all specs with rcov" + RSpec::Core::RakeTask.new(:rcov => "spec:prepare") do |t| + t.rcov = true + t.pattern = "./spec/**/*_spec.rb" + t.rcov_opts = '--exclude /gems/,/Library/,/usr/,lib/tasks,.bundle,config,/lib/rspec/,/lib/rspec-,spec' end task :statsetup do diff --git a/rspec-rails.gemspec b/rspec-rails.gemspec index 0e3c63c500..a1354d4ef7 100644 --- a/rspec-rails.gemspec +++ b/rspec-rails.gemspec @@ -11,7 +11,7 @@ Gem::Specification.new do |s| s.email = "rspec@googlegroups.com" s.homepage = "https://github.com/rspec/rspec-rails" s.summary = "RSpec for Rails" - s.description = "rspec-rails is a testing framework for Rails 4+." + s.description = "rspec-rails is a testing framework for Rails 5.2+." s.metadata = { 'bug_tracker_uri' => 'https://github.com/rspec/rspec-rails/issues', diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index 70b9e0a4e7..a06debe501 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -13,10 +13,7 @@ if is_mri; then clone_repo "rspec-expectations" clone_repo "rspec-mocks" clone_repo "rspec-rails" - - if rspec_support_compatible; then - clone_repo "rspec-support" - fi + clone_repo "rspec-support" popd else diff --git a/script/custom_build_functions.sh b/script/custom_build_functions.sh index f8b0f06b48..256211d5e7 100644 --- a/script/custom_build_functions.sh +++ b/script/custom_build_functions.sh @@ -1,5 +1,5 @@ function run_cukes { - if is_mri_192_plus; then + if is_mri; then bin/rake acceptance --trace return $? elif is_jruby; then diff --git a/script/functions.sh b/script/functions.sh index 2af14387be..fb071142a4 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -13,7 +13,7 @@ MAINTENANCE_BRANCH=`cat maintenance-branch` # Don't allow rubygems to pollute what's loaded. Also, things boot faster # without the extra load time of rubygems. Only works on MRI Ruby 1.9+ -if is_mri_192_plus; then +if is_mri; then export RUBYOPT="--disable=gem" fi @@ -47,12 +47,7 @@ function run_cukes { echo "${PWD}/bin/cucumber" - if is_mri_192; then - # For some reason we get SystemStackError on 1.9.2 when using - # the bin/cucumber approach below. That approach is faster - # (as it avoids the bundler tax), so we use it on rubies where we can. - bundle exec cucumber --strict - elif is_jruby; then + if is_jruby; then # For some reason JRuby doesn't like our improved bundler setup RUBYOPT="-I${PWD}/../bundle -rbundler/setup" \ PATH="${PWD}/bin:$PATH" \ @@ -188,8 +183,5 @@ function run_all_spec_suites { fold "rspec-expectations specs" run_spec_suite_for "rspec-expectations" fold "rspec-mocks specs" run_spec_suite_for "rspec-mocks" fold "rspec-rails specs" run_spec_suite_for "rspec-rails" - - if rspec_support_compatible; then - fold "rspec-support specs" run_spec_suite_for "rspec-support" - fi + fold "rspec-support specs" run_spec_suite_for "rspec-support" } diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index 953b676495..f86117ede0 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,10 +1,5 @@ -# This file was generated on 2019-07-24T15:33:53+02:00 from the rspec-dev repo. -# DO NOT modify it by hand as your changes will get lost the next time it is generated. - function is_mri { - if ruby -e "exit(!defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby')"; then - # RUBY_ENGINE only returns 'ruby' on MRI. - # MRI 1.8.7 lacks the constant but all other rubies have it (including JRuby in 1.8 mode) + if ruby -e "exit(RUBY_ENGINE == 'ruby')"; then return 0 else return 1 @@ -12,59 +7,13 @@ function is_mri { } function is_jruby { - if ruby -e "exit(defined?(RUBY_PLATFORM) && RUBY_PLATFORM == 'java')"; then - # RUBY_ENGINE only returns 'ruby' on MRI. - # MRI 1.8.7 lacks the constant but all other rubies have it (including JRuby in 1.8 mode) + if ruby -e "exit(RUBY_PLATFORM == 'java')"; then return 0 else return 1 fi; } -function is_mri_192 { - if is_mri; then - if ruby -e "exit(RUBY_VERSION == '1.9.2')"; then - return 0 - else - return 1 - fi - else - return 1 - fi -} - -function is_mri_192_plus { - if is_mri; then - if ruby -e "exit(RUBY_VERSION.to_f > 1.8)"; then - return 0 - else - return 1 - fi - else - return 1 - fi -} - -function is_mri_2plus { - if is_mri; then - if ruby -e "exit(RUBY_VERSION.to_f > 2.0)"; then - return 0 - else - return 1 - fi - else - return 1 - fi -} - -function is_ruby_23 { - if ruby -e "exit(RUBY_VERSION.to_f == 2.3)"; then - return 0 - else - return 1 - fi -} - function is_ruby_23_plus { if ruby -e "exit(RUBY_VERSION.to_f >= 2.3)"; then return 0 @@ -73,14 +22,6 @@ function is_ruby_23_plus { fi } -function rspec_support_compatible { - if [ "$MAINTENANCE_BRANCH" != "2-99-maintenance" ] && [ "$MAINTENANCE_BRANCH" != "2-14-maintenance" ]; then - return 0 - else - return 1 - fi -} - function additional_specs_available { type run_additional_specs > /dev/null 2>&1 return $? @@ -88,11 +29,7 @@ function additional_specs_available { function documentation_enforced { if [ -x ./bin/yard ]; then - if is_mri_2plus; then - return 0 - else - return 1 - fi + return 0 else return 1 fi diff --git a/spec/generators/rspec/system/system_generator_spec.rb b/spec/generators/rspec/system/system_generator_spec.rb index b63bf66623..f93ba9a58b 100644 --- a/spec/generators/rspec/system/system_generator_spec.rb +++ b/spec/generators/rspec/system/system_generator_spec.rb @@ -1,38 +1,36 @@ # Generators are not automatically loaded by rails -if ::Rails::VERSION::STRING >= '5.1' - require 'generators/rspec/system/system_generator' +require 'generators/rspec/system/system_generator' require 'support/generators' - RSpec.describe Rspec::Generators::SystemGenerator, :type => :generator do - setup_default_destination +RSpec.describe Rspec::Generators::SystemGenerator, :type => :generator do + setup_default_destination - describe "system specs" do - subject(:system_spec) { file("spec/system/posts_spec.rb") } - describe "are generated independently from the command line" do - before do - run_generator %w(posts) + describe "system specs" do + subject(:system_spec) { file("spec/system/posts_spec.rb") } + describe "are generated independently from the command line" do + before do + run_generator %w(posts) + end + describe "the spec" do + it "exists" do + expect(system_spec).to exist + end + it "contains 'rails_helper'" do + expect(system_spec).to contain(/require 'rails_helper'/) end - describe "the spec" do - it "exists" do - expect(system_spec).to exist - end - it "contains 'rails_helper'" do - expect(system_spec).to contain(/require 'rails_helper'/) - end - it "contains the system" do - expect(system_spec).to contain(/^RSpec.describe \"Posts\", #{type_metatag(:system)}/) - end + it "contains the system" do + expect(system_spec).to contain(/^RSpec.describe \"Posts\", #{type_metatag(:system)}/) end end + end - describe "are not generated" do - before do - run_generator %w(posts --no-system-specs) - end - describe "the spec" do - it "does not exist" do - expect(system_spec).to_not exist - end + describe "are not generated" do + before do + run_generator %w(posts --no-system-specs) + end + describe "the spec" do + it "does not exist" do + expect(system_spec).to_not exist end end end diff --git a/spec/rspec/rails/configuration_spec.rb b/spec/rspec/rails/configuration_spec.rb index 5538eeffa8..6c5b532240 100644 --- a/spec/rspec/rails/configuration_spec.rb +++ b/spec/rspec/rails/configuration_spec.rb @@ -253,9 +253,7 @@ def in_inferring_type_from_location_environment end end - if ::Rails::VERSION::STRING > '5' - it "has a default #file_fixture_path of 'spec/fixtures/files'" do - expect(config.file_fixture_path).to eq("spec/fixtures/files") - end + it "has a default #file_fixture_path of 'spec/fixtures/files'" do + expect(config.file_fixture_path).to eq("spec/fixtures/files") end end diff --git a/spec/rspec/rails/example/mailer_example_group_spec.rb b/spec/rspec/rails/example/mailer_example_group_spec.rb index 6145231049..82a6960087 100644 --- a/spec/rspec/rails/example/mailer_example_group_spec.rb +++ b/spec/rspec/rails/example/mailer_example_group_spec.rb @@ -9,12 +9,6 @@ module ::Rails; end allow(Rails).to receive_message_chain(:configuration, :action_mailer, :default_url_options).and_return({}) end - # On 1.9.2, we're getting travis failures from warnings being emitted by these specs - # only on 1.9.2 (and only on travis; can't repro locally). The warning is: - # /home/travis/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/net/smtp.rb:584: warning: previous definition of tlsconnect was here - # For now, we're just going to silence the warning. - around { |ex| with_isolated_stderr(&ex) } if RUBY_VERSION == '1.9.2' - it_behaves_like "an rspec-rails example group mixin", :mailer, './spec/mailers/', '.\\spec\\mailers\\' end From b6d9abf5c4fb8da62555843e7cf336dd74081147 Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Sun, 8 Dec 2019 22:21:43 +0300 Subject: [PATCH 2/4] Update nokogiri dependency 1.8.5 fails hard `rake` locally with: rm config/application.rb bin/rake app:template LOCATION='../../example_app_generator/generate_stuff.rb' rake aborted! LoadError: dlopen(/Users/pirj/source/rspec-dev/repos/bundle/ruby/2.5.0/gems/nokogiri-1.8.5/lib/nokogiri/nokogiri.bundle, 9): Library not loaded: /Users/pirj/.rvm/rubies/ruby-2.5.3/lib/libruby.2.5.dylib Referenced from: /Users/pirj/source/rspec-dev/repos/bundle/ruby/2.5.0/gems/nokogiri-1.8.5/lib/nokogiri/nokogiri.bundle Reason: image not found - /Users/pirj/source/rspec-dev/repos/bundle/ruby/2.5.0/gems/nokogiri-1.8.5/lib/nokogiri/nokogiri.bundle /Users/pirj/source/rspec-dev/repos/bundle/ruby/2.5.0/gems/nokogiri-1.8.5/lib/nokogiri.rb:32:in `require' ... Caused by: LoadError: cannot load such file -- nokogiri/2.5/nokogiri /Users/pirj/source/rspec-dev/repos/bundle/ruby/2.5.0/gems/nokogiri-1.8.5/lib/nokogiri.rb:30:in `require' /Users/pirj/source/rspec-dev/repos/bundle/ruby/2.5.0/gems/nokogiri-1.8.5/lib/nokogiri.rb:30:in `' /Users/pirj/source/rspec-dev/repos/bundle/ruby/2.5.0/gems/loofah-2.4.0/lib/loofah.rb:4:in `require' 1.9.1 supports Ruby 2.1+. --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 3a44a2db4c..214bb6aa10 100644 --- a/Gemfile +++ b/Gemfile @@ -60,7 +60,7 @@ end gem 'capybara', '~> 2.13', :require => false if MAJOR < 6 - gem 'nokogiri', '1.8.5' + gem 'nokogiri', '1.9.1' else gem 'nokogiri', '>= 1.10.4' end From 1e8923ac7e36fdbebee30d10d88bfe3b37808ea0 Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Sun, 8 Dec 2019 22:40:27 +0300 Subject: [PATCH 3/4] Set RuboCop target Ruby version RuboCop 0.77 only supports 2.3, support for 2.2 was dropped in 0.69 --- .rubocop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop.yml b/.rubocop.yml index 3df2c75ce0..4594642454 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,6 +2,7 @@ inherit_from: - .rubocop_todo.yml AllCops: + TargetRubyVersion: 2.3 Exclude: # Templates are really ERB which Rubocop does not parse - 'lib/generators/rspec/*/templates/**/*' From 5ebd00ef222327906370443793548b7fa0790a9a Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Sun, 8 Dec 2019 23:12:50 +0300 Subject: [PATCH 4/4] fixup! Drop support for Rails 3 --- lib/rspec/rails/extensions/active_record/proxy.rb | 10 +--------- spec/spec_helper.rb | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/rspec/rails/extensions/active_record/proxy.rb b/lib/rspec/rails/extensions/active_record/proxy.rb index 56152ff806..b60ecb6a73 100644 --- a/lib/rspec/rails/extensions/active_record/proxy.rb +++ b/lib/rspec/rails/extensions/active_record/proxy.rb @@ -2,15 +2,7 @@ # Delay this in order to give users a chance to configure `expect_with`... rspec.before(:suite) do if defined?(RSpec::Matchers) && RSpec::Matchers.configuration.syntax.include?(:should) && defined?(ActiveRecord::Associations) - # In Rails 3.0, it was AssociationProxy. - # In 3.1+, it's CollectionProxy. - const_name = [:CollectionProxy, :AssociationProxy].find do |const| - ActiveRecord::Associations.const_defined?(const) - end - - proxy_class = ActiveRecord::Associations.const_get(const_name) - - RSpec::Matchers.configuration.add_should_and_should_not_to proxy_class + RSpec::Matchers.configuration.add_should_and_should_not_to ActiveRecord::Associations::CollectionProxy end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6d0b0001f8..f94353c66f 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,7 +2,7 @@ module RSpecRails class Application < ::Rails::Application - self.config.secret_key_base = 'ASecretString' if config.respond_to? :secret_key_base + self.config.secret_key_base = 'ASecretString' if defined?(ActionCable) ActionCable.server.config.cable = { "adapter" => "test" }