diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9fdccd4..c3c79ce 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' }} @@ -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 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 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| 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'