From 89b3eec672e981243764101c97c9005964f09389 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sat, 15 Feb 2025 22:57:35 +0000 Subject: [PATCH 1/5] Update ubuntu runner --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9fdccd4..d5fe72b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ concurrency: jobs: rubocop: name: Rubocop - runs-on: 'ubuntu-20.04' + runs-on: 'ubuntu-latest' steps: - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 @@ -30,7 +30,7 @@ jobs: test: name: 'Ruby: ${{ matrix.ruby }}, Rails: ${{ matrix.env.RAILS_VERSION }}' - runs-on: ubuntu-20.04 + runs-on: 'ubuntu-latest' strategy: fail-fast: false matrix: @@ -213,7 +213,7 @@ jobs: legacy: name: Legacy Ruby Builds (${{ matrix.container.version }}) - runs-on: ubuntu-20.04 + runs-on: 'ubuntu-latest' container: image: ${{ matrix.container.tag }} options: ${{ matrix.container.options || '--add-host github-complains-if-this-is-empty.com:127.0.0.1' }} From f9ebfdb53c5269f81f8578e4d43b54848a8be200 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sat, 15 Feb 2025 23:48:51 +0000 Subject: [PATCH 2/5] Replace legacy git action with manual --- .github/workflows/ci.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5fe72b..c3c79ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -225,7 +225,6 @@ jobs: - container: version: "2.1.9" tag: ghcr.io/rspec/docker-ci:2.1.9 - post: git config --global --add safe.directory `pwd` env: RAILS_VERSION: '~> 4.2.0' - container: @@ -240,14 +239,16 @@ jobs: RAILS_VERSION: '~> 4.2.0' env: - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true LEGACY_CI: true JRUBY_OPTS: ${{ matrix.container.jruby_opts || '--dev' }} RAILS_VERSION: ${{ matrix.env.RAILS_VERSION }} steps: - - uses: actions/checkout@v3 + - run: git config --global --add safe.directory $GITHUB_WORKSPACE + - run: git init $GITHUB_WORKSPACE + - run: git remote add origin https://github.com/rspec/rspec-activemodel-mocks + - run: git config --local gc.auto 0 + - run: git fetch --no-tags --prune --no-recurse-submodules --depth=1 origin +$GITHUB_SHA:$GITHUB_REF + - run: git checkout --progress --force $GITHUB_REF - run: apt-get install libsqlite3-dev - - run: ${{ matrix.container.pre }} - run: script/legacy_setup.sh - - run: ${{ matrix.container.post }} - run: script/run_build From 53a0f4fce663db8e4c54bda86a6d49553d80eaf1 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sat, 15 Feb 2025 23:49:47 +0000 Subject: [PATCH 3/5] Work around legacy Rails logger issue --- spec/spec_helper.rb | 1 + templates/sample/spec/spec_helper.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2a571e1..bfdcf02 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true +require 'logger' require 'rspec/active_model/mocks' require 'active_record' diff --git a/templates/sample/spec/spec_helper.rb b/templates/sample/spec/spec_helper.rb index 830ae01..e143bcc 100644 --- a/templates/sample/spec/spec_helper.rb +++ b/templates/sample/spec/spec_helper.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true $:<< File.join(File.dirname(__FILE__), '..') +require 'logger' require 'active_record' require 'rspec/active_model/mocks' require 'model/widget' From 9dfe955e74948e4b3e8ad6c5311fad1cb3ef35c2 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 2 Mar 2025 22:23:56 +0000 Subject: [PATCH 4/5] Pin concurrent-ruby on older Rails --- Gemfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Gemfile b/Gemfile index 6e9fda7..9a68e2d 100644 --- a/Gemfile +++ b/Gemfile @@ -37,6 +37,10 @@ end version = ENV.fetch('RAILS_VERSION', '6.0.0') version_float = version.tr('-', '.').tr('~> ', '').to_f +if version_float < 7.1 + gem 'concurrent-ruby', '<= 1.3.4' +end + if version_float < 4 gem 'sqlite3', '~> 1.3.5' elsif version_float < 6 From d98ebceb1e713bb010508dbd2aa3aca917b86a65 Mon Sep 17 00:00:00 2001 From: Jon Rowe Date: Sun, 2 Mar 2025 22:27:26 +0000 Subject: [PATCH 5/5] Rework method to reflect intent but avoid rubocop --- lib/rspec/active_model/mocks/mocks.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/rspec/active_model/mocks/mocks.rb b/lib/rspec/active_model/mocks/mocks.rb index fa70939..8cfe696 100644 --- a/lib/rspec/active_model/mocks/mocks.rb +++ b/lib/rspec/active_model/mocks/mocks.rb @@ -176,8 +176,11 @@ def self.param_delimiter; "-"; end end unless stubs.key?(:has_attribute?) msingleton.__send__(:define_method, :respond_to?) do |method_name, *args| + return true if __model_class_has_column?(method_name) + include_private = args.first || false - __model_class_has_column?(method_name) ? true : super(method_name, include_private) + + super(method_name, include_private) end unless stubs.key?(:respond_to?) msingleton.__send__(:define_method, :method_missing) do |missing_m, *a, &b|