Skip to content

Commit

Permalink
test: exclude lines from test coverage due to JRuby false positives
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouball committed Oct 30, 2024
1 parent 03692ad commit ab907b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/bundler/gem_bytes/gemspec/upsert_dependency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ def dependency_method_to_type(method)
# @return [String] The error message
# @api private
def dependency_type_conflict_error(node)
# :nocov: JRuby give false positive for this line being uncovered by tests
<<~MESSAGE.chomp.gsub("\n", ' ')
Trying to add a
#{dependency_method_to_type(dependency_type_method).upcase}
Expand All @@ -203,6 +204,7 @@ def dependency_type_conflict_error(node)
Pass force: true to update dependencies where the
dependency type is different.
MESSAGE
# :nocov:
end

# Checks if the given dependency type conflicts with the existing dependency type
Expand Down Expand Up @@ -253,10 +255,8 @@ def update_dependency
# @api private
def dependency_type=(dependency_type)
unless %i[runtime development].include?(dependency_type)
raise(
ArgumentError,
"Invalid dependency type: #{dependency_type.inspect}"
)
message = "Invalid dependency type: #{dependency_type.inspect}"
raise(ArgumentError, message)
end
@dependency_type = dependency_type
end
Expand Down Expand Up @@ -292,6 +292,7 @@ def dependency_type_method
# @return [RuboCop::AST::NodePattern] The dependency pattern
# @api private
def dependency_pattern
# :nocov: JRuby give false positive for this line being uncovered by tests
@dependency_pattern ||=
RuboCop::AST::NodePattern.new(<<~PATTERN)
(send
Expand All @@ -301,6 +302,7 @@ def dependency_pattern
<(str $_version_constraint) ...>
)
PATTERN
# :nocov:
end

# The pattern to match the Gem::Specification block in the AST
Expand Down
2 changes: 2 additions & 0 deletions spec/lib/bundler/gem_bytes/gemspec/upsert_dependency_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@

context 'with valid arguments' do
let(:expected_attributes) do
# :nocov: JRuby give false positive for this line being uncovered by tests
{
dependency_type: :development,
gem_name: 'test_tool',
version_constraint: '~> 2.1',
force: false,
found_dependencies: []
}
# :nocov:
end

it { is_expected.to have_attributes(expected_attributes) }
Expand Down

0 comments on commit ab907b4

Please sign in to comment.