From e3aedcc27a52d0a933d5908658ac8ef6068f8e33 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 3 Sep 2024 14:29:32 +0100 Subject: [PATCH 01/11] Updated ci build scripts (from rspec-dev) 3-13 --- .github/dependabot.yml | 2 +- .github/workflows/ci.yml | 2 +- .rubocop_rspec_base.yml | 2 +- script/ci_functions.sh | 2 +- script/clone_all_rspec_repos | 4 ++-- script/cucumber.sh | 2 +- script/functions.sh | 5 +---- script/legacy_setup.sh | 2 +- script/predicate_functions.sh | 11 +++-------- script/run_build | 2 +- script/run_rubocop | 2 +- script/update_rubygems_and_install_bundler | 2 +- 12 files changed, 15 insertions(+), 23 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c8d6ee094..851a34974 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,4 +1,4 @@ -# This file was generated on 2024-07-15T22:27:33+01:00 from the rspec-dev repo. +# This file was generated on 2024-09-03T14:29:32+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. version: 2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa95b8776..64524ee97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -# This file was generated on 2024-07-15T22:27:33+01:00 from the rspec-dev repo. +# This file was generated on 2024-09-03T14:29:32+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. name: RSpec CI diff --git a/.rubocop_rspec_base.yml b/.rubocop_rspec_base.yml index 49b4c1f47..b6ab82080 100644 --- a/.rubocop_rspec_base.yml +++ b/.rubocop_rspec_base.yml @@ -1,4 +1,4 @@ -# This file was generated on 2024-07-15T22:27:33+01:00 from the rspec-dev repo. +# This file was generated on 2024-09-03T14:29:32+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # This file contains defaults for RSpec projects. Individual projects diff --git a/script/ci_functions.sh b/script/ci_functions.sh index 1e93b3079..4d6dec0e5 100644 --- a/script/ci_functions.sh +++ b/script/ci_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2024-07-15T22:27:33+01:00 from the rspec-dev repo. +# This file was generated on 2024-09-03T14:29:32+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. # Taken from: diff --git a/script/clone_all_rspec_repos b/script/clone_all_rspec_repos index fdfdf341c..33ce8207e 100755 --- a/script/clone_all_rspec_repos +++ b/script/clone_all_rspec_repos @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2024-07-15T22:27:33+01:00 from the rspec-dev repo. +# This file was generated on 2024-09-03T14:29:32+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e @@ -12,7 +12,7 @@ if is_mri; then clone_repo "rspec-core" clone_repo "rspec-expectations" clone_repo "rspec-mocks" - clone_repo "rspec-rails" "rspec-rails" "6-1-maintenance" + clone_repo "rspec-rails" "rspec-rails" "7-0-maintenance" if rspec_support_compatible; then clone_repo "rspec-support" diff --git a/script/cucumber.sh b/script/cucumber.sh index 3e3ce5bb4..e3e51d2f6 100755 --- a/script/cucumber.sh +++ b/script/cucumber.sh @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2024-07-15T22:27:33+01:00 from the rspec-dev repo. +# This file was generated on 2024-09-03T14:29:32+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/functions.sh b/script/functions.sh index d715b9c16..31ddc7fbd 100644 --- a/script/functions.sh +++ b/script/functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2024-07-15T22:27:33+01:00 from the rspec-dev repo. +# This file was generated on 2024-09-03T14:29:32+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -204,9 +204,6 @@ 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" if rspec_rails_compatible; then - if ! is_ruby_27_plus; then - export RAILS_VERSION='~> 6.1.0' - fi fold "rspec-rails specs" run_spec_suite_for "rspec-rails" fi diff --git a/script/legacy_setup.sh b/script/legacy_setup.sh index 635c77ab9..07f051177 100755 --- a/script/legacy_setup.sh +++ b/script/legacy_setup.sh @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2024-07-15T22:27:33+01:00 from the rspec-dev repo. +# This file was generated on 2024-09-03T14:29:32+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/predicate_functions.sh b/script/predicate_functions.sh index a9b928b41..b3e837860 100644 --- a/script/predicate_functions.sh +++ b/script/predicate_functions.sh @@ -1,4 +1,4 @@ -# This file was generated on 2024-07-15T22:27:33+01:00 from the rspec-dev repo. +# This file was generated on 2024-09-03T14:29:32+01: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 { @@ -112,13 +112,8 @@ function is_ruby_31_plus { } function rspec_rails_compatible { - if is_ruby_25_plus; then - # TODO remove when RSpec-Rails build is 3.1 safe by default - if is_ruby_31_plus; then - return 1 - else - return 0 - fi + if is_ruby_27_plus; then + return 0 else return 1 fi diff --git a/script/run_build b/script/run_build index 70a4640dd..3eb289e86 100755 --- a/script/run_build +++ b/script/run_build @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2024-07-15T22:27:33+01:00 from the rspec-dev repo. +# This file was generated on 2024-09-03T14:29:32+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/run_rubocop b/script/run_rubocop index be676538b..c9a3433e5 100755 --- a/script/run_rubocop +++ b/script/run_rubocop @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2024-07-15T22:27:33+01:00 from the rspec-dev repo. +# This file was generated on 2024-09-03T14:29:32+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e diff --git a/script/update_rubygems_and_install_bundler b/script/update_rubygems_and_install_bundler index c9fa78d63..b1643541e 100755 --- a/script/update_rubygems_and_install_bundler +++ b/script/update_rubygems_and_install_bundler @@ -1,5 +1,5 @@ #!/bin/bash -# This file was generated on 2024-07-15T22:27:33+01:00 from the rspec-dev repo. +# This file was generated on 2024-09-03T14:29:32+01:00 from the rspec-dev repo. # DO NOT modify it by hand as your changes will get lost the next time it is generated. set -e From 3ce68cd0baab2c959f67052983da8c636f547bc9 Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Fri, 10 May 2024 09:41:22 +0300 Subject: [PATCH 02/11] Merge pull request #3084 from nevinera/nev--fix-simplecov-filters Use stronger path-matching for simplecov filters --- script/rspec_with_simplecov | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/script/rspec_with_simplecov b/script/rspec_with_simplecov index fc7c6469d..f40bb2902 100755 --- a/script/rspec_with_simplecov +++ b/script/rspec_with_simplecov @@ -28,10 +28,11 @@ begin require 'simplecov' SimpleCov.start do - add_filter "bundle/" - add_filter "tmp/" - add_filter "spec/" - minimum_coverage(100) + root File.expand_path("../..", __FILE__) + add_filter %r{/bundle/} + add_filter %r{/tmp/} + add_filter %r{/spec/} + minimum_coverage(99) end end rescue LoadError # rubocop:disable Lint/SuppressedException From 2d160fa5557bac2e53f7594de622516009a3d585 Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Wed, 15 May 2024 23:16:43 +0300 Subject: [PATCH 03/11] Merge pull request #3086 from nevinera/nev--full-test-coverage Restore 100% test coverage --- .github/workflows/ci.yml | 2 ++ lib/rspec/core/bisect/fork_runner.rb | 2 ++ lib/rspec/core/configuration_options.rb | 2 ++ lib/rspec/core/did_you_mean.rb | 6 +++++ .../core/formatters/exception_presenter.rb | 6 +++++ .../core/formatters/html_snippet_extractor.rb | 2 ++ lib/rspec/core/metadata.rb | 2 +- lib/rspec/core/rake_task.rb | 2 ++ script/rspec_with_simplecov | 2 +- .../integration/spec_file_load_errors_spec.rb | 17 ++++++++++++++ spec/rspec/core/bisect/shell_runner_spec.rb | 4 ++++ spec/rspec/core/drb_spec.rb | 4 ++++ .../formatters/exception_presenter_spec.rb | 2 +- spec/rspec/core/memoized_helpers_spec.rb | 22 +++++++++++++++++++ spec/rspec/core/metadata_spec.rb | 3 ++- 15 files changed, 74 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64524ee97..0d2b858cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,7 @@ env: RSPEC_CI: true # This tells rspec-rails what branch to run in ci RSPEC_VERSION: '~> 3.13.0' + ENFORCE_COVERAGE_AFTER: "3.2" jobs: rubocop: name: Rubocop @@ -130,6 +131,7 @@ jobs: env: ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true LEGACY_CI: true + NO_COVERAGE: true JRUBY_OPTS: ${{ matrix.container.jruby_opts || '--dev' }} NO_COVERAGE: true steps: diff --git a/lib/rspec/core/bisect/fork_runner.rb b/lib/rspec/core/bisect/fork_runner.rb index 4641a1442..16d20dcb9 100644 --- a/lib/rspec/core/bisect/fork_runner.rb +++ b/lib/rspec/core/bisect/fork_runner.rb @@ -102,6 +102,7 @@ def dispatch_specs(run_descriptor) private def run_specs(run_descriptor) + # :nocov: - Executed in a forked process, by integration/bisect_spec $stdout = $stderr = @spec_output formatter = CaptureFormatter.new(run_descriptor.failed_example_ids) @@ -125,6 +126,7 @@ def run_specs(run_descriptor) else @channel.send(latest_run_results) end + # :nocov: end end diff --git a/lib/rspec/core/configuration_options.rb b/lib/rspec/core/configuration_options.rb index 01325088e..5bebe7782 100644 --- a/lib/rspec/core/configuration_options.rb +++ b/lib/rspec/core/configuration_options.rb @@ -181,7 +181,9 @@ def options_file_as_erb_string(path) if RUBY_VERSION >= '2.6' ERB.new(File.read(path), :trim_mode => '-').result(binding) else + # :nocov: ERB.new(File.read(path), nil, '-').result(binding) + # :nocov: end end diff --git a/lib/rspec/core/did_you_mean.rb b/lib/rspec/core/did_you_mean.rb index 07daea966..643a86966 100644 --- a/lib/rspec/core/did_you_mean.rb +++ b/lib/rspec/core/did_you_mean.rb @@ -11,6 +11,7 @@ def initialize(relative_file_name) if defined?(::DidYouMean::SpellChecker) # provide probable suggestions + # :nocov: - not installed on CI def call checker = ::DidYouMean::SpellChecker.new(:dictionary => Dir["spec/**/*.rb"]) probables = checker.correct(relative_file_name.sub('./', ''))[0..2] @@ -18,15 +19,19 @@ def call formats probables end + # :nocov: else # return a hint if API for ::DidYouMean::SpellChecker not supported + # :nocov: def call "\nHint: Install the `did_you_mean` gem in order to provide suggestions for similarly named files." end + # :nocov: end private + # :nocov: def formats(probables) rspec_format = probables.map { |s, _| "rspec ./#{s}" } red_font(top_and_tail rspec_format) @@ -41,6 +46,7 @@ def red_font(mytext) colorizer = ::RSpec::Core::Formatters::ConsoleCodes colorizer.wrap mytext, :failure end + # :nocov: end end end diff --git a/lib/rspec/core/formatters/exception_presenter.rb b/lib/rspec/core/formatters/exception_presenter.rb index 22ac10aa6..6b0abd8f1 100644 --- a/lib/rspec/core/formatters/exception_presenter.rb +++ b/lib/rspec/core/formatters/exception_presenter.rb @@ -191,11 +191,13 @@ def exception_message_string(exception) "A #{exception.class} for which `exception.message.to_s` raises #{other.class}." end else + # :nocov: def exception_message_string(exception) exception.message.to_s rescue Exception => other "A #{exception.class} for which `exception.message.to_s` raises #{other.class}." end + # :nocov: end # rubocop:enable Lint/RescueException @@ -252,7 +254,9 @@ def read_failed_lines rescue SnippetExtractor::NoSuchLineError ["Unable to find matching line in #{file_path}"] rescue SecurityError + # :nocov: - SecurityError is no longer produced starting in ruby 2.7 ["Unable to read failed line"] + # :nocov: end def find_failed_line @@ -284,9 +288,11 @@ def encoded_description(description) encoded_string(description) end else # for 1.8.7 + # :nocov: def encoded_description(description) description end + # :nocov: end def exception_backtrace diff --git a/lib/rspec/core/formatters/html_snippet_extractor.rb b/lib/rspec/core/formatters/html_snippet_extractor.rb index 50fe297cb..992704b64 100644 --- a/lib/rspec/core/formatters/html_snippet_extractor.rb +++ b/lib/rspec/core/formatters/html_snippet_extractor.rb @@ -93,7 +93,9 @@ def lines_around(file, line) "# Couldn't get snippet for #{file}" end rescue SecurityError + # :nocov: - SecurityError is no longer produced starting in ruby 2.7 "# Couldn't get snippet for #{file}" + # :nocov: end # @api private diff --git a/lib/rspec/core/metadata.rb b/lib/rspec/core/metadata.rb index 5e0d7e2bd..9034214c8 100644 --- a/lib/rspec/core/metadata.rb +++ b/lib/rspec/core/metadata.rb @@ -47,7 +47,7 @@ def self.relative_path(line) return nil if line == '-e:1'.freeze line rescue SecurityError - # :nocov: + # :nocov: - SecurityError is no longer produced starting in ruby 2.7 nil # :nocov: end diff --git a/lib/rspec/core/rake_task.rb b/lib/rspec/core/rake_task.rb index 8cf474a94..1b60db037 100644 --- a/lib/rspec/core/rake_task.rb +++ b/lib/rspec/core/rake_task.rb @@ -47,6 +47,7 @@ class RakeTask < ::Rake::TaskLib if RUBY_VERSION < "1.9.0" || Support::Ruby.jruby? # Run RSpec with a clean (empty) environment is not supported + # :nocov: def with_clean_environment=(_value) raise ArgumentError, "Running in a clean environment is not supported on Ruby versions before 1.9.0" end @@ -55,6 +56,7 @@ def with_clean_environment=(_value) def with_clean_environment false end + # :nocov: else # Run RSpec with a clean (empty) environment. attr_accessor :with_clean_environment diff --git a/script/rspec_with_simplecov b/script/rspec_with_simplecov index f40bb2902..cf8678dc6 100755 --- a/script/rspec_with_simplecov +++ b/script/rspec_with_simplecov @@ -32,7 +32,7 @@ begin add_filter %r{/bundle/} add_filter %r{/tmp/} add_filter %r{/spec/} - minimum_coverage(99) + minimum_coverage(100) if RUBY_VERSION.to_f >= ENV['ENFORCE_COVERAGE_AFTER'].to_f end end rescue LoadError # rubocop:disable Lint/SuppressedException diff --git a/spec/integration/spec_file_load_errors_spec.rb b/spec/integration/spec_file_load_errors_spec.rb index a703e0275..d9acf96e9 100644 --- a/spec/integration/spec_file_load_errors_spec.rb +++ b/spec/integration/spec_file_load_errors_spec.rb @@ -30,6 +30,23 @@ end end + it 'nicely handles load errors from --require files' do + run_command "--require ./helper_with_load_error" + expect(last_cmd_exit_status).to eq(error_exit_code) + output = normalize_durations(last_cmd_stdout) + expect(output).to include("An error occurred while loading ./helper_with_load_error.") + expect(output).to include("LoadError:") + end + + it 'nicely handles syntax errors from --require files' do + write_file_formatted "helper_with_syntax_error.rb", "3 = hello" + + run_command "--require ./helper_with_syntax_error" + expect(last_cmd_exit_status).to eq(error_exit_code) + output = normalize_durations(last_cmd_stdout) + expect(output).to include("While loading ./helper_with_syntax_error a `raise SyntaxError` occurred, RSpec will now quit.") + end + it 'nicely handles load-time errors from --require files' do write_file_formatted "helper_with_error.rb", "raise 'boom'" diff --git a/spec/rspec/core/bisect/shell_runner_spec.rb b/spec/rspec/core/bisect/shell_runner_spec.rb index c5a10cfc6..4fc276ce7 100644 --- a/spec/rspec/core/bisect/shell_runner_spec.rb +++ b/spec/rspec/core/bisect/shell_runner_spec.rb @@ -8,6 +8,10 @@ module RSpec::Core let(:shell_command) { Bisect::ShellCommand.new(original_cli_args) } let(:runner) { described_class.new(server, shell_command) } + it "has the expected name" do + expect(described_class.name).to eq(:shell) + end + describe "#run" do let(:original_cli_args) { %w[ spec/1_spec.rb ] } let(:target_specs) { %w[ spec/1_spec.rb[1:1] spec/1_spec.rb[1:2] ] } diff --git a/spec/rspec/core/drb_spec.rb b/spec/rspec/core/drb_spec.rb index 308673716..c924b87e5 100644 --- a/spec/rspec/core/drb_spec.rb +++ b/spec/rspec/core/drb_spec.rb @@ -138,6 +138,10 @@ def drb_filter_manager_for(args) expect(drb_argv_for(%w[--failure-exit-code 2])).to include("--failure-exit-code", "2") end + it "includes --error-exit-code" do + expect(drb_argv_for(%w[--error-exit-code 5])).to include("--error-exit-code", "5") + end + it "includes --options" do expect(drb_argv_for(%w[--options custom.opts])).to include("--options", "custom.opts") end diff --git a/spec/rspec/core/formatters/exception_presenter_spec.rb b/spec/rspec/core/formatters/exception_presenter_spec.rb index 1c02ec15e..0f0c2b3ab 100644 --- a/spec/rspec/core/formatters/exception_presenter_spec.rb +++ b/spec/rspec/core/formatters/exception_presenter_spec.rb @@ -633,7 +633,7 @@ def read_failed_lines end end - context "when backtrace will generate a security error" do + context "when backtrace will generate a security error", :skip => !RSpec::Support::RubyFeatures.supports_taint? do let(:exception) { instance_double(Exception, :backtrace => [ "#{__FILE__}:#{__LINE__}"]) } it "is handled gracefully" do diff --git a/spec/rspec/core/memoized_helpers_spec.rb b/spec/rspec/core/memoized_helpers_spec.rb index 11310d499..77cd5f8a8 100644 --- a/spec/rspec/core/memoized_helpers_spec.rb +++ b/spec/rspec/core/memoized_helpers_spec.rb @@ -670,6 +670,28 @@ def supports_value_expectations? end end + RSpec.describe 'custom matcher that does not specify if it supports value expectations' do + let(:value_matcher_class) do + Class.new do + def matches?(_actual); true; end + def failure_message_when_negated; "oops"; end + end + end + let(:value_matcher) { value_matcher_class.new } + + before { expect(value_matcher).not_to respond_to(:supports_value_expectations?) } + + it '`should` does not print a deprecation warning when given a value' do + expect_no_deprecations + expect { should value_matcher }.not_to raise_error + end + + it '`should_not` does not print a deprecation warning when given a value' do + expect_no_deprecations + expect { should_not value_matcher }.to raise_error(Exception) + end + end + RSpec.describe 'Module#define_method' do it 'retains its normal private visibility on Ruby versions where it is normally private', :if => RUBY_VERSION < '2.5' do a_module = Module.new diff --git a/spec/rspec/core/metadata_spec.rb b/spec/rspec/core/metadata_spec.rb index 73319dee0..438da28f7 100644 --- a/spec/rspec/core/metadata_spec.rb +++ b/spec/rspec/core/metadata_spec.rb @@ -13,8 +13,9 @@ module Core it "returns nil if passed an unparseable file:line combo" do expect(Metadata.relative_path("-e:1")).to be_nil end + # I have no idea what line = line.sub(/\A([^:]+:\d+)$/, '\\1') is supposed to do - it "gracefully returns nil if run in a secure thread" do + it "gracefully returns nil if run in a secure thread", :skip => !RSpec::Support::RubyFeatures.supports_taint? do # Ensure our call to `File.expand_path` is not cached as that is the insecure operation. Metadata.instance_eval { @relative_path_regex = nil } From 19df53911afd40f1a6c185a474a7d7e7646f933a Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 9 Jul 2024 08:00:22 +0200 Subject: [PATCH 04/11] Merge pull request #3095 from makicamel/remove-redundunt-require Remove redundant require ostruct --- spec/rspec/core/configuration_options_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/rspec/core/configuration_options_spec.rb b/spec/rspec/core/configuration_options_spec.rb index 27c0c836a..4bf93974a 100644 --- a/spec/rspec/core/configuration_options_spec.rb +++ b/spec/rspec/core/configuration_options_spec.rb @@ -1,4 +1,3 @@ -require 'ostruct' require 'rspec/core/drb' RSpec.describe RSpec::Core::ConfigurationOptions, :isolated_directory => true, :isolated_home => true do From 203fe0a7558818d37a432c649fb34b874003d2f4 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Thu, 5 Sep 2024 09:15:40 +0100 Subject: [PATCH 05/11] Restore parity with rspec-dev #3098 --- .github/workflows/ci.yml | 2 -- lib/rspec/core/configuration_options.rb | 4 ++-- lib/rspec/core/formatters/exception_presenter.rb | 4 ++-- lib/rspec/core/option_parser.rb | 2 ++ 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d2b858cd..64524ee97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,6 @@ env: RSPEC_CI: true # This tells rspec-rails what branch to run in ci RSPEC_VERSION: '~> 3.13.0' - ENFORCE_COVERAGE_AFTER: "3.2" jobs: rubocop: name: Rubocop @@ -131,7 +130,6 @@ jobs: env: ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true LEGACY_CI: true - NO_COVERAGE: true JRUBY_OPTS: ${{ matrix.container.jruby_opts || '--dev' }} NO_COVERAGE: true steps: diff --git a/lib/rspec/core/configuration_options.rb b/lib/rspec/core/configuration_options.rb index 5bebe7782..fcde48fac 100644 --- a/lib/rspec/core/configuration_options.rb +++ b/lib/rspec/core/configuration_options.rb @@ -177,15 +177,15 @@ def args_from_options_file(path) FlatMap.flat_map(config_lines, &:shellsplit) end + # :nocov: def options_file_as_erb_string(path) if RUBY_VERSION >= '2.6' ERB.new(File.read(path), :trim_mode => '-').result(binding) else - # :nocov: ERB.new(File.read(path), nil, '-').result(binding) - # :nocov: end end + # :nocov: def custom_options_file command_line_options[:custom_options_file] diff --git a/lib/rspec/core/formatters/exception_presenter.rb b/lib/rspec/core/formatters/exception_presenter.rb index 6b0abd8f1..070c6d9a5 100644 --- a/lib/rspec/core/formatters/exception_presenter.rb +++ b/lib/rspec/core/formatters/exception_presenter.rb @@ -180,6 +180,7 @@ def failure_slash_error_lines end # rubocop:disable Lint/RescueException + # :nocov: if SyntaxError.instance_methods.include?(:detailed_message) def exception_message_string(exception) case exception @@ -191,14 +192,13 @@ def exception_message_string(exception) "A #{exception.class} for which `exception.message.to_s` raises #{other.class}." end else - # :nocov: def exception_message_string(exception) exception.message.to_s rescue Exception => other "A #{exception.class} for which `exception.message.to_s` raises #{other.class}." end - # :nocov: end + # :nocov: # rubocop:enable Lint/RescueException def exception_lines diff --git a/lib/rspec/core/option_parser.rb b/lib/rspec/core/option_parser.rb index 35ed0c950..e239e87a2 100644 --- a/lib/rspec/core/option_parser.rb +++ b/lib/rspec/core/option_parser.rb @@ -185,7 +185,9 @@ def parser(options) parser.on('-w', '--warnings', 'Enable ruby warnings') do if Object.const_defined?(:Warning) && Warning.respond_to?(:[]=) + # :nocov: on older Ruby without Warning Warning[:deprecated] = true + # :nocov: end $VERBOSE = true end From 551a386c285f44f60cad2818504fd9825d3a3501 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Thu, 5 Sep 2024 09:16:48 +0100 Subject: [PATCH 06/11] Remove coverage version check --- script/rspec_with_simplecov | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/rspec_with_simplecov b/script/rspec_with_simplecov index cf8678dc6..602b8c31e 100755 --- a/script/rspec_with_simplecov +++ b/script/rspec_with_simplecov @@ -32,7 +32,7 @@ begin add_filter %r{/bundle/} add_filter %r{/tmp/} add_filter %r{/spec/} - minimum_coverage(100) if RUBY_VERSION.to_f >= ENV['ENFORCE_COVERAGE_AFTER'].to_f + minimum_coverage(100) end end rescue LoadError # rubocop:disable Lint/SuppressedException From b1930256229c1789370ebf641141bbafe94700ab Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 11 Sep 2024 22:21:34 +0100 Subject: [PATCH 07/11] Merge pull request #3112 from the-spectator/proc_type docs: Add example of proc being acceptable as filter in config.include --- lib/rspec/core/configuration.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/rspec/core/configuration.rb b/lib/rspec/core/configuration.rb index 06aea65ab..8928f93ab 100644 --- a/lib/rspec/core/configuration.rb +++ b/lib/rspec/core/configuration.rb @@ -1402,6 +1402,9 @@ def exclusion_filter # # # included in examples with `:type => :request` metadata # config.include(AuthenticationHelpers, :type => :request) + # + # # included in examples where the `:type` metadata matches a proc condition + # config.include(AuthenticationHelpers, :type => proc { |type, _metadata| [:request, :controller].include?(type) }) # end # # describe "edit profile", :preferences, :type => :request do From fefe8b643f827b56510554bdaed91e2a7edf595b Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 1 Oct 2024 22:17:07 +0100 Subject: [PATCH 08/11] Merge pull request #3114 from rspec/fix-ruby-head-build Relax constraint for Ruby 3.4.0 in file load error spec --- spec/integration/spec_file_load_errors_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/integration/spec_file_load_errors_spec.rb b/spec/integration/spec_file_load_errors_spec.rb index d9acf96e9..435d2ff26 100644 --- a/spec/integration/spec_file_load_errors_spec.rb +++ b/spec/integration/spec_file_load_errors_spec.rb @@ -245,7 +245,7 @@ def foo 5 end EOS end - expect(formatted_output).to include "./tmp/aruba/broken_file.rb:5: syntax error" + expect(formatted_output).to include %r{./tmp/aruba/broken_file.rb:\d: syntax error} expect(formatted_output).to include unindent(<<-EOS) Finished in n.nnnn seconds (files took n.nnnn seconds to load) From d092c00482a4ffb9b1ced3e01992058bf2d4b33c Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Thu, 10 Oct 2024 01:13:23 +0100 Subject: [PATCH 09/11] Merge pull request #3118 from rspec/fix-ruby-head-hash-syntax Fix taging feature on Ruby head --- features/command_line/tag.feature | 34 +++++++------------ .../run_all_when_everything_filtered.feature | 4 +-- .../step_definitions/additional_cli_steps.rb | 17 ++++++++++ 3 files changed, 31 insertions(+), 24 deletions(-) diff --git a/features/command_line/tag.feature b/features/command_line/tag.feature index 2c74c1d0e..436eab730 100644 --- a/features/command_line/tag.feature +++ b/features/command_line/tag.feature @@ -39,61 +39,49 @@ Feature: `--tag` option Scenario: Filter examples with a simple tag When I run `rspec . --tag focus` - Then the output should contain "include {:focus=>true}" + Then the output should print the included tags {focus: true} And the examples should all pass Scenario: Filter examples with a simple tag and @ When I run `rspec . --tag @focus` - Then the output should contain "include {:focus=>true}" + Then the output should print the included tags {focus: true} Then the examples should all pass Scenario: Filter examples with a `name:value` tag When I run `rspec . --tag type:special` - Then the output should contain: - """ - include {:type=>"special"} - """ + Then the output should print the included tags {type: "special"} And the output should contain "2 examples" And the examples should all pass Scenario: Filter examples with a `name:value` tag and @ When I run `rspec . --tag @type:special` - Then the output should contain: - """ - include {:type=>"special"} - """ + Then the output should print the included tags {type: "special"} And the examples should all pass Scenario: Exclude examples with a simple tag When I run `rspec . --tag ~skip` - Then the output should contain "exclude {:skip=>true}" + Then the output should print the excluded tags {skip: true} Then the examples should all pass Scenario: Exclude examples with a simple tag and @ When I run `rspec . --tag ~@skip` - Then the output should contain "exclude {:skip=>true}" + Then the output should print the excluded tags {skip: true} Then the examples should all pass Scenario: Exclude examples with a `name:value` tag When I run `rspec . --tag ~speed:slow` - Then the output should contain: - """ - exclude {:speed=>"slow"} - """ + Then the output should print the excluded tags {speed: "slow"} Then the examples should all pass Scenario: Exclude examples with a `name:value` tag and @ When I run `rspec . --tag ~@speed:slow` - Then the output should contain: - """ - exclude {:speed=>"slow"} - """ + Then the output should print the excluded tags {speed: "slow"} Then the examples should all pass Scenario: Filter examples with a simple tag, exclude examples with another tag When I run `rspec . --tag focus --tag ~skip` - Then the output should contain "include {:focus=>true}" - And the output should contain "exclude {:skip=>true}" + Then the output should print the included tags {focus: true} + And the output should print the excluded tags {skip: true} And the examples should all pass Scenario: Exclude examples with multiple tags @@ -101,4 +89,6 @@ Feature: `--tag` option Then the output should contain one of the following: | exclude {:skip=>true, :speed=>"slow"} | | exclude {:speed=>"slow", :skip=>true} | + | exclude {skip: true, speed: "slow"} | + | exclude {speed: "slow", skip: true} | Then the examples should all pass diff --git a/features/configuration/run_all_when_everything_filtered.feature b/features/configuration/run_all_when_everything_filtered.feature index 64f6219ae..6de90e62b 100644 --- a/features/configuration/run_all_when_everything_filtered.feature +++ b/features/configuration/run_all_when_everything_filtered.feature @@ -62,7 +62,7 @@ Feature: Using `run_all_when_everything_filtered` """ When I run `rspec spec/example_spec.rb --tag some_tag` Then the output should contain "1 example, 0 failures" - And the output should contain "Run options: include {:some_tag=>true}" + And the output should contain in either hash syntax "Run options: include {:some_tag=>true}" Scenario: When the `run_all_when_everything_filtered` option is turned on, all the specs are run when the tag has no matches Given a file named "spec/example_spec.rb" with: @@ -78,5 +78,5 @@ Feature: Using `run_all_when_everything_filtered` """ When I run `rspec spec/example_spec.rb --tag some_tag` Then the output should contain "2 examples, 0 failures" - And the output should contain "All examples were filtered out; ignoring {:some_tag=>true}" + And the output should contain in either hash syntax "All examples were filtered out; ignoring {:some_tag=>true}" diff --git a/features/step_definitions/additional_cli_steps.rb b/features/step_definitions/additional_cli_steps.rb index ad75ba382..866340b51 100644 --- a/features/step_definitions/additional_cli_steps.rb +++ b/features/step_definitions/additional_cli_steps.rb @@ -2,6 +2,23 @@ require './spec/support/formatter_support' +# For Ruby 3.4.0 hash formatting +Then /^the output should print the (include|exclude)d tags {(\w+): (.*)}$/ do |word, key, value| + if RUBY_VERSION.to_f > 3.3 + expect(all_output).to include "#{word} {#{key}: #{value}}" + else + expect(all_output).to include "#{word} {:#{key}=>#{value}}" + end +end + +Then /^the output should contain in either hash syntax "(.*)"$/ do |string| + if RUBY_VERSION.to_f > 3.3 + step "the output should contain \"#{string.gsub(/:(\w+)=>/, '\1: ')}\"" + else + step "the output should contain \"#{string}\"" + end +end + Then /^the output should contain all of these:$/ do |table| table.raw.flatten.each do |string| expect(all_output).to include(string) From 55f9eade6992a4e7fbe27f41866b728ec6509137 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Thu, 10 Oct 2024 08:14:56 +0100 Subject: [PATCH 10/11] Merge pull request #3117 from rspec/push_requires_into_config_as_required As each file is required in RSpec::Core::Configuration, push it onto `requires`. --- Changelog.md | 5 +++++ lib/rspec/core/configuration.rb | 6 ++++-- spec/rspec/core/configuration_spec.rb | 10 ++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index 08e681ad7..c9a178ff8 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,11 @@ ### Development [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.13.1...3-13-maintenance) +Bug fixes: + +* `RSpec::Configuration#requires` will reflect files already required, whilst requiring + them. (Jon Rowe, #3117) + ### 3.13.1 / 2024-09-02 [Full Changelog](http://github.com/rspec/rspec-core/compare/v3.13.0...v3.13.1) diff --git a/lib/rspec/core/configuration.rb b/lib/rspec/core/configuration.rb index 8928f93ab..c207b7a7c 100644 --- a/lib/rspec/core/configuration.rb +++ b/lib/rspec/core/configuration.rb @@ -1597,8 +1597,10 @@ def configure_example(example, example_hooks) def requires=(paths) directories = ['lib', default_path].select { |p| File.directory? p } RSpec::Core::RubyProject.add_to_load_path(*directories) - paths.each { |path| load_file_handling_errors(:require, path) } - @requires += paths + paths.each { |path| + load_file_handling_errors(:require, path) + @requires << path + } end # @private diff --git a/spec/rspec/core/configuration_spec.rb b/spec/rspec/core/configuration_spec.rb index 165990f5a..0a806cc85 100644 --- a/spec/rspec/core/configuration_spec.rb +++ b/spec/rspec/core/configuration_spec.rb @@ -238,6 +238,16 @@ def absolute_path_to(dir) expect(config.requires).to eq ['a/path'] end + it 'stores required paths "per file"' do + allow(config).to receive(:require).with('a/path') + expect(config).to receive(:require).with('another/path') do + expect(config.requires).to eq ['a/path'] + end + + config.requires = ['a/path', 'another/path'] + expect(config.requires).to eq ['a/path', 'another/path'] + end + context "when `default_path` refers to a file rather than a directory" do it 'does not add it to the load path' do config.default_path = 'Rakefile' From 3bdf310e172836d28da49349f00e4747e6c29b05 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Fri, 18 Oct 2024 19:39:56 +0100 Subject: [PATCH 11/11] v3.13.2 --- Changelog.md | 5 ++++- lib/rspec/core/version.rb | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog.md b/Changelog.md index c9a178ff8..946c1924d 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,8 @@ ### Development -[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.13.1...3-13-maintenance) +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.13.2...3-13-maintenance) + +### 3.13.2 / 2024-10-18 +[Full Changelog](http://github.com/rspec/rspec-core/compare/v3.13.1...v3.13.2) Bug fixes: diff --git a/lib/rspec/core/version.rb b/lib/rspec/core/version.rb index 7fe73b304..51d7589a4 100644 --- a/lib/rspec/core/version.rb +++ b/lib/rspec/core/version.rb @@ -3,7 +3,7 @@ module Core # Version information for RSpec Core. module Version # Current version of RSpec Core, in semantic versioning format. - STRING = '3.13.1' + STRING = '3.13.2' end end end