Skip to content

Commit

Permalink
reproduce toplevel method issue
Browse files Browse the repository at this point in the history
  • Loading branch information
grodowski committed Feb 23, 2025
1 parent 18e34e6 commit 69d28e0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion lib/undercover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def load_and_parse_file(filepath)
return if root_ast.children.empty?

loaded_files[key] = []
# TODO: children[0] ignores the lonely_method (see spec fixtures)!
root_ast.children[0].find_all(->(_) { true }).each do |imagen_node|
loaded_files[key] << Result.new(imagen_node, coverage, filepath)
end
Expand Down
4 changes: 4 additions & 0 deletions spec/fixtures/sinatra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
get '/dummy_path' do
"This line is not covered"
end

def foobar
puts "bar"
end
Binary file modified spec/fixtures/test.git/index
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x%��
�0 ;�+^<����Ů�ƐX�,��1d����j���&�^L[��-E��#>�o��ٓ/���R�R�U_=ĄIe"��jN6�{C~� �T#;
4 changes: 2 additions & 2 deletions spec/report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
module_results = report.results['module.rb']
# only includes changed methods
expect(module_results.map(&:name))
.to eq(%w[BaconModule bar baz branch_missed branch_hit foobar])
.to eq(%w[BaconModule bar baz branch_missed branch_hit foobar]) # TODO: misses top-level methods

# includes flagged blocks
module_flagged = module_results.select(&:flagged?)
Expand All @@ -57,7 +57,7 @@

# includes blocks at top-level (reproduce https://github.com/grodowski/undercover/issues/135)
top_level_results = report.results['sinatra.rb'].to_a
expect(top_level_results.size).to eq(1)
expect(top_level_results.size).to eq(1) # TODO: misses top-level methods
expect(top_level_results[0].name).to eq('block')
expect(top_level_results[0].coverage_f).to eq(0.0)
expect(top_level_results[0].flagged?).to eq(true)
Expand Down

0 comments on commit 69d28e0

Please sign in to comment.