-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
Complete branch coverage for more files #1990
Merged
bquorning
merged 1 commit into
rubocop:master
from
corsonknowles:continue_branch_coverage_quest
Nov 2, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
# This configuration was generated by | ||
# `rubocop --auto-gen-config --no-offense-counts --no-auto-gen-timestamp` | ||
# using RuboCop version 1.63.4. | ||
# using RuboCop version 1.68.0. | ||
# The point is for the user to remove these configuration records | ||
# one by one as the offenses are removed from the code base. | ||
# Note that changes in the inspected code, or installation of new | ||
# versions of RuboCop, may require this file to be generated again. | ||
|
||
Lint/ToEnumArguments: | ||
Exclude: | ||
- 'lib/rubocop/cop/rspec/multiple_expectations.rb' | ||
|
||
Rake/MethodDefinitionInTask: | ||
Exclude: | ||
- 'tasks/cut_release.rake' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,16 @@ | |
end | ||
RUBY | ||
end | ||
|
||
it 'ignores instance_double when expect is called on another variable' do | ||
expect_no_offenses(<<~RUBY) | ||
it do | ||
foo = instance_double(Foo).as_null_object | ||
bar = instance_spy(Bar).as_null_object | ||
expect(bar).to have_received(:baz) | ||
end | ||
RUBY | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test case is good 👍🏼 I actually found again that the lib/ code can be diff --git a/lib/rubocop/cop/rspec/instance_spy.rb b/lib/rubocop/cop/rspec/instance_spy.rb
index cca5a1e6..43298d35 100644
--- a/lib/rubocop/cop/rspec/instance_spy.rb
+++ b/lib/rubocop/cop/rspec/instance_spy.rb
@@ -36,7 +36,7 @@ module RuboCop
def_node_search :have_received_usage, <<~PATTERN
(send
(send nil? :expect
- (lvar $_)) :to
+ (lvar %1)) :to
(send nil? :have_received
...)
...)
@@ -46,9 +46,7 @@ module RuboCop
return unless example?(node)
null_double(node) do |var, receiver|
- have_received_usage(node) do |expected|
- next if expected != var
-
+ have_received_usage(node, var) do
add_offense(receiver) do |corrector|
autocorrect(corrector, receiver)
end It would be nice to find a way to calculate test coverage of the node patterns… |
||
end | ||
|
||
context 'when not used with `have_received`' do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe RuboCop::RSpec::Inject do | ||
describe '.defaults!' do | ||
let(:config_loader) { class_double(RuboCop::ConfigLoader).as_stubbed_const } | ||
|
||
before do | ||
rubocop_config = instance_double(RuboCop::Config) | ||
allow(config_loader).to receive(:send) | ||
.with(:load_yaml_configuration, any_args) | ||
.and_return({}) | ||
allow(RuboCop::Config).to receive(:new).and_return(rubocop_config) | ||
allow(config_loader).to receive(:merge_with_default) | ||
.and_return(rubocop_config) | ||
allow(config_loader).to receive(:instance_variable_set) | ||
end | ||
|
||
context 'when ConfigLoader.debug? is true' do | ||
before do | ||
allow(config_loader).to receive(:debug?).and_return(true) | ||
end | ||
|
||
it 'puts the configuration path' do | ||
expect { described_class.defaults! }.to output( | ||
%r{configuration from .*rubocop-rspec/config/default.yml} | ||
).to_stdout | ||
end | ||
end | ||
|
||
context 'when ConfigLoader.debug? is false' do | ||
before do | ||
allow(config_loader).to receive(:debug?).and_return(false) | ||
end | ||
|
||
it 'does not put the configuration path' do | ||
expect { described_class.defaults! }.not_to output.to_stdout | ||
end | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼