From 70db8e4f498ee3f3af4e23e5022717b4fa2d28e7 Mon Sep 17 00:00:00 2001 From: Felix Wolfsteller Date: Thu, 30 May 2024 08:14:28 +0200 Subject: [PATCH] sketch spec approach Example how the whole spec suite could be run three times for the different implementations. Alternatively, a very restricted set (2 or 3 examples) could be used for the sister implementations, with the trust coming from the correct well-speced implementation of link_to . --- spec/rubocop/cop/rails/link_to_blank_spec.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/spec/rubocop/cop/rails/link_to_blank_spec.rb b/spec/rubocop/cop/rails/link_to_blank_spec.rb index 83e71c8f59..3ffacc924a 100644 --- a/spec/rubocop/cop/rails/link_to_blank_spec.rb +++ b/spec/rubocop/cop/rails/link_to_blank_spec.rb @@ -1,6 +1,18 @@ # frozen_string_literal: true RSpec.describe RuboCop::Cop::Rails::LinkToBlank, :config do + ['link_to', 'link_to_if condition?, ', 'link_to_unless condition?, '].each do |link_helper_method| + context "with '#{link_helper_method}'" do + context 'when not using target _blank' do + it 'does not register an offense' do + expect_no_offenses(<<~RUBY) + #{link_helper_method} 'Click here', 'https://www.example.com' + RUBY + end + end + end + end + context 'when not using target _blank' do it 'does not register an offense' do expect_no_offenses(<<~RUBY)