From 692db5fbac9f8f75071e8c7198260eb8d10f9d47 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 22 Oct 2024 22:34:11 +0100 Subject: [PATCH 1/6] Fix usage of example for when its redefined --- lib/rspec/its.rb | 4 +++- spec/rspec/its_spec.rb | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/rspec/its.rb b/lib/rspec/its.rb index 4eb83ba..6d357a1 100644 --- a/lib/rspec/its.rb +++ b/lib/rspec/its.rb @@ -1,6 +1,8 @@ require 'rspec/its/version' require 'rspec/core' +RSpec::Core::ExampleGroup.define_example_method :__its_example + module RSpec module Its @@ -166,7 +168,7 @@ def should_not(matcher=nil, message=nil) options << {} unless options.last.kind_of?(Hash) options.last.merge!(:caller => its_caller) - example(nil, *options, &block) + __its_example(nil, *options, &block) end end diff --git a/spec/rspec/its_spec.rb b/spec/rspec/its_spec.rb index ebc59d5..239b2e4 100644 --- a/spec/rspec/its_spec.rb +++ b/spec/rspec/its_spec.rb @@ -9,6 +9,7 @@ module RSpec its([]) { expect(described_class).to be Its } end end + context "with explicit subject" do subject do Class.new do @@ -375,6 +376,20 @@ def terminator raise_error(ArgumentError, '`will_not` only supports block expectations') end end + + context "when example is redefined" do + subject do + Class.new do + def will_still_work; true; end + end.new + end + + def self.example(*_args) + raise + end + + its(:will_still_work) { is_expected.to be true } + end end end end From 1c245c483122ef8586fa64d1769de945a9844605 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 22 Oct 2024 22:34:49 +0100 Subject: [PATCH 2/6] Remove deprecated raise_error --- spec/rspec/its_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/rspec/its_spec.rb b/spec/rspec/its_spec.rb index 239b2e4..9f894df 100644 --- a/spec/rspec/its_spec.rb +++ b/spec/rspec/its_spec.rb @@ -270,7 +270,6 @@ def bad end its(:good) { will_not raise_error } - its(:bad) { will raise_error } its(:bad) { will raise_error(ArgumentError) } its(:bad) { will raise_error("message") } its(:bad) { will raise_error(ArgumentError, "message") } From 4c5ce670c486d58f9aa1cee03dfcaab2a9e46480 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 22 Oct 2024 22:59:05 +0100 Subject: [PATCH 3/6] Fix rspec-metagem --- Gemfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Gemfile b/Gemfile index 9818aa7..b9feb99 100644 --- a/Gemfile +++ b/Gemfile @@ -6,8 +6,11 @@ gemspec %w[rspec rspec-core rspec-expectations rspec-mocks rspec-support].each do |lib| branch = ENV.fetch('BRANCH','main') library_path = File.expand_path("../../#{lib}", __FILE__) + if File.exist?(library_path) && !ENV['USE_GIT_REPOS'] gem lib, :path => library_path + elsif lib == 'rspec' + gem 'rspec', :git => "https://github.com/rspec/rspec-metagem.git", :branch => branch else gem lib, :git => "https://github.com/rspec/#{lib}.git", :branch => branch end From 0020fd3caa6d4e79828b5352faab8a44c4d94bcf Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Tue, 22 Oct 2024 23:05:36 +0100 Subject: [PATCH 4/6] allow insecure node version on legacy ci --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5e54ac..e82dedd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -122,6 +122,7 @@ jobs: - version: "JRuby 1.7" tag: rspec/ci:jruby-1.7 env: + ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true LEGACY_CI: true JRUBY_OPTS: ${{ matrix.container.jruby_opts || '--dev' }} steps: From d25c18ffd756095201766ed8814b2cbc5802b05f Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 23 Oct 2024 08:42:50 +0100 Subject: [PATCH 5/6] Modernise legacy ruby setup --- .github/workflows/ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e82dedd..6a55734 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -110,17 +110,19 @@ jobs: legacy: name: Legacy Ruby Builds (${{ matrix.container.version }}) runs-on: ubuntu-20.04 - container: ${{ matrix.container.tag }} + container: + image: ${{ matrix.container.tag }} + options: ${{ matrix.container.options || '--add-host github-complains-if-this-is-empty.com:127.0.0.1' }} strategy: fail-fast: false matrix: container: - version: "2.0" - tag: rspec/ci:2.0.0 + tag: ghcr.io/rspec/docker-ci:2.0.0 - version: "1.9.3" - tag: rspec/ci:1.9.3 + tag: ghcr.io/rspec/docker-ci:1.9.3 - version: "JRuby 1.7" - tag: rspec/ci:jruby-1.7 + tag: ghcr.io/rspec/docker-ci:jruby-1.7 env: ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true LEGACY_CI: true From 0fd24f5bd4f1c9e005075a8a799a8475f1befd8f Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Wed, 23 Oct 2024 08:43:07 +0100 Subject: [PATCH 6/6] Move JRUby 9.1.17 to legacy setup --- .github/workflows/ci.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a55734..94e8dc5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,11 +35,6 @@ jobs: - ruby: jruby-9.2.13.0 env: JRUBY_OPTS: "--dev" - - ruby: jruby-9.1.17.0 - bundler: 1 - os: ubuntu-18.04 - env: - JRUBY_OPTS: "--dev" # Compatibility builds - ruby: '3.2' name_extra: "against RSpec 3.12" @@ -123,6 +118,9 @@ jobs: tag: ghcr.io/rspec/docker-ci:1.9.3 - version: "JRuby 1.7" tag: ghcr.io/rspec/docker-ci:jruby-1.7 + - version: "JRuby 9.1.17.0" + tag: ghcr.io/rspec/docker-ci:jruby-9.1.17.0 + options: "--add-host rubygems.org:151.101.129.227 --add-host api.rubygems.org:151.101.129.227" env: ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true LEGACY_CI: true