diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..af69493d --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,32 @@ +name: CI + +on: + push: + branches: + - master + pull_request: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + oldest_supported_rubocop: + runs-on: ubuntu-latest + name: The oldest supported RuboCop version + steps: + - uses: actions/checkout@v4 + - name: Use the oldest supported RuboCop + run: | + sed -e "/gem 'rubocop', github: 'rubocop\/rubocop'/d" -i Gemfile + cat << EOF > Gemfile.local + gem 'rubocop', '1.39.0' # Specify the oldest supported RuboCop version + EOF + - name: set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + bundler-cache: true + - name: test + run: bundle exec rake diff --git a/changelog/fix_error_for_minitest_assert_operator_and_refute_operator.md b/changelog/fix_error_for_minitest_assert_operator_and_refute_operator.md new file mode 100644 index 00000000..a890e1df --- /dev/null +++ b/changelog/fix_error_for_minitest_assert_operator_and_refute_operator.md @@ -0,0 +1 @@ +* [#275](https://github.com/rubocop/rubocop-minitest/pull/275): Make `Minitest/AssertMatch` aware of `assert_operator` when running with Ruby 2.7. ([@koic][]) diff --git a/lib/rubocop/cop/minitest/assert_operator.rb b/lib/rubocop/cop/minitest/assert_operator.rb index 241adca2..15b2935a 100644 --- a/lib/rubocop/cop/minitest/assert_operator.rb +++ b/lib/rubocop/cop/minitest/assert_operator.rb @@ -40,7 +40,7 @@ def on_send(node) def build_new_arguments(node) lhs, op, rhs = *node.first_argument - new_arguments = "#{lhs.source}, :#{op}, #{rhs.source}" + new_arguments = +"#{lhs.source}, :#{op}, #{rhs.source}" if node.arguments.count == 2 new_arguments << ", #{node.last_argument.source}" diff --git a/lib/rubocop/cop/minitest/refute_operator.rb b/lib/rubocop/cop/minitest/refute_operator.rb index 213ebeeb..be58bd8c 100644 --- a/lib/rubocop/cop/minitest/refute_operator.rb +++ b/lib/rubocop/cop/minitest/refute_operator.rb @@ -40,7 +40,7 @@ def on_send(node) def build_new_arguments(node) lhs, op, rhs = *node.first_argument - new_arguments = "#{lhs.source}, :#{op}, #{rhs.source}" + new_arguments = +"#{lhs.source}, :#{op}, #{rhs.source}" if node.arguments.count == 2 new_arguments << ", #{node.last_argument.source}"