Skip to content

Commit

Permalink
Merge pull request #21 from grosser/grosser/cov
Browse files Browse the repository at this point in the history
remove redundancy of saying the same line twice for branch gaps
  • Loading branch information
grosser committed Apr 18, 2019
2 parents ca39b76 + dcde980 commit c10c210
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ rvm:
- 2.4
- 2.5
- 2.6
before_install: ruby -e "File.write('Gemfile.lock', File.read('Gemfile.lock').split('BUNDLED WITH').first)"
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ rspec spec/foobar_spec.rb
lib/foobar.rb new uncovered lines introduced (2 current vs 0 configured)",
Uncovered lines:
lib/foobar.rb:22
lib/foobar.rb:23
lib/foobar.rb:23:6-19
```
- Missing coverage on every 💚 test run
Expand Down
10 changes: 9 additions & 1 deletion lib/single_cov.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,15 @@ def all_covered?(result)
end

uncovered.map! do |line_start, char_start, line_end, char_end|
char_start ? "#{file}:#{line_start}:#{char_start}-#{line_end}:#{char_end}" : "#{file}:#{line_start}"
if char_start # branch coverage
if line_start == line_end
"#{file}:#{line_start}:#{char_start}-#{char_end}"
else # possibly unreachable since branches always seem to be on the same line
"#{file}:#{line_start}:#{char_start}-#{line_end}:#{char_end}"
end
else
"#{file}:#{line_start}"
end
end

warn_about_bad_coverage(file, expected_uncovered, uncovered)
Expand Down
6 changes: 3 additions & 3 deletions specs/single_cov_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def self.it_does_not_complain_when_everything_is_covered
change_file("lib/a.rb", "i == 0", "i != i") do
result = sh "ruby test/a_test.rb", fail: true
expect(result).to include ".lib/a.rb new uncovered lines introduced (1 current vs 0 configured)"
expect(result).to include "lib/a.rb:3:19-3:23"
expect(result).to include "lib/a.rb:3:19-23"
end
end

Expand All @@ -215,7 +215,7 @@ def self.it_does_not_complain_when_everything_is_covered
change_file("lib/a.rb", "i == 0", "i != i") do
result = sh "ruby test/a_test.rb 2>&1", fail: true
expect(result).to include "lib/a.rb new uncovered lines introduced (2 current vs 0 configured)"
expect(result).to include "lib/a.rb:3\nlib/a.rb:6:19-6:23"
expect(result).to include "lib/a.rb:3\nlib/a.rb:6:19-23"
end
end
end
Expand All @@ -232,7 +232,7 @@ def self.it_does_not_complain_when_everything_is_covered
change_file("lib/a.rb", "i == 0", "i == 0 if i if 0 if false") do
result = sh "ruby test/a_test.rb", fail: true
expect(result).to include ".lib/a.rb new uncovered lines introduced (3 current vs 0 configured)"
expect(result).to include "lib/a.rb:3:19-3:23\nlib/a.rb:3:19-3:33\nlib/a.rb:3:19-3:38"
expect(result).to include "lib/a.rb:3:19-23\nlib/a.rb:3:19-33\nlib/a.rb:3:19-38"
end
end

Expand Down

0 comments on commit c10c210

Please sign in to comment.