diff --git a/.simplecov b/.simplecov index a1e3bd9..2b29bd2 100644 --- a/.simplecov +++ b/.simplecov @@ -2,7 +2,7 @@ SimpleCov.start do enable_coverage :branch - minimum_coverage line: 95.17, branch: 85.13 + minimum_coverage line: 100, branch: 100 add_filter '/spec/' add_filter '/vendor/bundle/' end diff --git a/lib/rubocop/cop/rspec_rails/http_status.rb b/lib/rubocop/cop/rspec_rails/http_status.rb index 4a7766a..148f7be 100644 --- a/lib/rubocop/cop/rspec_rails/http_status.rb +++ b/lib/rubocop/cop/rspec_rails/http_status.rb @@ -102,6 +102,10 @@ def checker_class NumericStyleChecker when :be_status BeStatusStyleChecker + else + # :nocov: + :noop + # :nocov: end end @@ -126,10 +130,6 @@ def message end end - def autocorrectable? - true - end - def current offense_range.source end diff --git a/lib/rubocop/cop/rspec_rails/inferred_spec_type.rb b/lib/rubocop/cop/rspec_rails/inferred_spec_type.rb index 6eff7f0..d21f9e1 100644 --- a/lib/rubocop/cop/rspec_rails/inferred_spec_type.rb +++ b/lib/rubocop/cop/rspec_rails/inferred_spec_type.rb @@ -93,6 +93,7 @@ def autocorrect(corrector, node) # @param [RuboCop::AST::Node] node # @return [Parser::Source::Range] + # rubocop:disable Metrics/MethodLength def remove_range(node) if node.left_sibling node.source_range.with( @@ -102,8 +103,13 @@ def remove_range(node) node.source_range.with( end_pos: node.right_sibling.source_range.begin_pos ) + else + # :nocov: + :noop + # :nocov: end end + # rubocop:enable Metrics/MethodLength # @param [RuboCop::AST::PairNode] node # @return [RuboCop::AST::Node] diff --git a/lib/rubocop/cop/rspec_rails/minitest_assertions.rb b/lib/rubocop/cop/rspec_rails/minitest_assertions.rb index 7bdb220..05a5522 100644 --- a/lib/rubocop/cop/rspec_rails/minitest_assertions.rb +++ b/lib/rubocop/cop/rspec_rails/minitest_assertions.rb @@ -39,7 +39,9 @@ class BasicAssertion attr_reader :expected, :actual, :failure_message def self.minitest_assertion + # :nocov: raise NotImplementedError + # :nocov: end def initialize(expected, actual, failure_message) @@ -62,7 +64,9 @@ def negated?(node) end def assertion + # :nocov: raise NotImplementedError + # :nocov: end end diff --git a/lib/rubocop/cop/rspec_rails/negation_be_valid.rb b/lib/rubocop/cop/rspec_rails/negation_be_valid.rb index 37dba08..c57b228 100644 --- a/lib/rubocop/cop/rspec_rails/negation_be_valid.rb +++ b/lib/rubocop/cop/rspec_rails/negation_be_valid.rb @@ -64,6 +64,10 @@ def offense?(node) be_invalid?(node) when :be_invalid not_to?(node) + else + # :nocov: + :noop + # :nocov: end end @@ -81,6 +85,10 @@ def replaced_runner 'not_to' when :be_invalid 'to' + else + # :nocov: + :noop + # :nocov: end end @@ -90,6 +98,10 @@ def replaced_matcher 'be_valid' when :be_invalid 'be_invalid' + else + # :nocov: + :noop + # :nocov: end end end diff --git a/spec/rubocop/cop/rspec_rails/http_status_spec.rb b/spec/rubocop/cop/rspec_rails/http_status_spec.rb index 2b8b988..0aabde8 100644 --- a/spec/rubocop/cop/rspec_rails/http_status_spec.rb +++ b/spec/rubocop/cop/rspec_rails/http_status_spec.rb @@ -89,6 +89,14 @@ expect_no_corrections end + + it 'registers no offense when Rack is not loaded' do + hide_const('Rack') + + expect_no_offenses(<<~RUBY) + it { is_expected.to have_http_status(404) } + RUBY + end end context 'when EnforcedStyle is `numeric`' do @@ -163,6 +171,14 @@ RUBY end end + + it 'registers no offense when Rack is not loaded' do + hide_const('Rack') + + expect_no_offenses(<<~RUBY) + it { is_expected.to have_http_status(:not_found) } + RUBY + end end context 'when EnforcedStyle is `be_status`' do @@ -287,5 +303,13 @@ RUBY end end + + it 'registers no offense when Rack is not loaded' do + hide_const('Rack') + + expect_no_offenses(<<~RUBY) + it { is_expected.to have_http_status(:not_found) } + RUBY + end end end