Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip pattern matching tests when running on older versions of Rubocop #297

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,3 @@ jobs:
bundler-cache: true
- name: test
run: bundle exec rake test
env:
ERROR_ON_TEST_FAILURE: "false"
10 changes: 10 additions & 0 deletions test/rubocop/cop/minitest/multiple_assertions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,8 @@ class FooTest < ActiveSupport::TestCase
end

def test_registers_offense_when_multiple_expectations_inside_pattern_matching
skip_unless_rubocop_supports_pattern_matching!

assert_offense(<<~RUBY)
class FooTest < ActiveSupport::TestCase
test 'something' do
Expand All @@ -447,6 +449,8 @@ class FooTest < ActiveSupport::TestCase
end

def test_registers_offense_when_multiple_expectations_inside_assigned_pattern_matching
skip_unless_rubocop_supports_pattern_matching!

assert_offense(<<~RUBY)
class FooTest < ActiveSupport::TestCase
test 'something' do
Expand All @@ -468,6 +472,8 @@ class FooTest < ActiveSupport::TestCase
end

def test_does_not_register_offense_when_single_assertion_inside_pattern_matching
skip_unless_rubocop_supports_pattern_matching!

assert_no_offenses(<<~RUBY)
class FooTest < ActiveSupport::TestCase
test 'something' do
Expand Down Expand Up @@ -688,4 +694,8 @@ def configure_max_assertions(max)
cop_config = RuboCop::Config.new('Minitest/MultipleAssertions' => { 'Max' => max })
@cop = RuboCop::Cop::Minitest::MultipleAssertions.new(cop_config)
end

def skip_unless_rubocop_supports_pattern_matching!
skip if RuboCop::TargetRuby::DEFAULT_VERSION < 2.7
end
end