Skip to content

Commit cc58bde

Browse files
authored
Merge pull request #58 from rubocop/improve-test-coverage
Improve test coverage
2 parents 2ffe982 + 7ae719f commit cc58bde

File tree

6 files changed

+51
-5
lines changed

6 files changed

+51
-5
lines changed

.simplecov

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
SimpleCov.start do
44
enable_coverage :branch
5-
minimum_coverage line: 95.17, branch: 85.13
5+
minimum_coverage line: 100, branch: 100
66
add_filter '/spec/'
77
add_filter '/vendor/bundle/'
88
end

lib/rubocop/cop/rspec_rails/http_status.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ def checker_class
102102
NumericStyleChecker
103103
when :be_status
104104
BeStatusStyleChecker
105+
else
106+
# :nocov:
107+
:noop
108+
# :nocov:
105109
end
106110
end
107111

@@ -126,10 +130,6 @@ def message
126130
end
127131
end
128132

129-
def autocorrectable?
130-
true
131-
end
132-
133133
def current
134134
offense_range.source
135135
end

lib/rubocop/cop/rspec_rails/inferred_spec_type.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def autocorrect(corrector, node)
9393

9494
# @param [RuboCop::AST::Node] node
9595
# @return [Parser::Source::Range]
96+
# rubocop:disable Metrics/MethodLength
9697
def remove_range(node)
9798
if node.left_sibling
9899
node.source_range.with(
@@ -102,8 +103,13 @@ def remove_range(node)
102103
node.source_range.with(
103104
end_pos: node.right_sibling.source_range.begin_pos
104105
)
106+
else
107+
# :nocov:
108+
:noop
109+
# :nocov:
105110
end
106111
end
112+
# rubocop:enable Metrics/MethodLength
107113

108114
# @param [RuboCop::AST::PairNode] node
109115
# @return [RuboCop::AST::Node]

lib/rubocop/cop/rspec_rails/minitest_assertions.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ class BasicAssertion
3939
attr_reader :expected, :actual, :failure_message
4040

4141
def self.minitest_assertion
42+
# :nocov:
4243
raise NotImplementedError
44+
# :nocov:
4345
end
4446

4547
def initialize(expected, actual, failure_message)
@@ -62,7 +64,9 @@ def negated?(node)
6264
end
6365

6466
def assertion
67+
# :nocov:
6568
raise NotImplementedError
69+
# :nocov:
6670
end
6771
end
6872

lib/rubocop/cop/rspec_rails/negation_be_valid.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ def offense?(node)
6464
be_invalid?(node)
6565
when :be_invalid
6666
not_to?(node)
67+
else
68+
# :nocov:
69+
:noop
70+
# :nocov:
6771
end
6872
end
6973

@@ -81,6 +85,10 @@ def replaced_runner
8185
'not_to'
8286
when :be_invalid
8387
'to'
88+
else
89+
# :nocov:
90+
:noop
91+
# :nocov:
8492
end
8593
end
8694

@@ -90,6 +98,10 @@ def replaced_matcher
9098
'be_valid'
9199
when :be_invalid
92100
'be_invalid'
101+
else
102+
# :nocov:
103+
:noop
104+
# :nocov:
93105
end
94106
end
95107
end

spec/rubocop/cop/rspec_rails/http_status_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@
8989

9090
expect_no_corrections
9191
end
92+
93+
it 'registers no offense when Rack is not loaded' do
94+
hide_const('Rack')
95+
96+
expect_no_offenses(<<~RUBY)
97+
it { is_expected.to have_http_status(404) }
98+
RUBY
99+
end
92100
end
93101

94102
context 'when EnforcedStyle is `numeric`' do
@@ -163,6 +171,14 @@
163171
RUBY
164172
end
165173
end
174+
175+
it 'registers no offense when Rack is not loaded' do
176+
hide_const('Rack')
177+
178+
expect_no_offenses(<<~RUBY)
179+
it { is_expected.to have_http_status(:not_found) }
180+
RUBY
181+
end
166182
end
167183

168184
context 'when EnforcedStyle is `be_status`' do
@@ -287,5 +303,13 @@
287303
RUBY
288304
end
289305
end
306+
307+
it 'registers no offense when Rack is not loaded' do
308+
hide_const('Rack')
309+
310+
expect_no_offenses(<<~RUBY)
311+
it { is_expected.to have_http_status(:not_found) }
312+
RUBY
313+
end
290314
end
291315
end

0 commit comments

Comments
 (0)