Skip to content

Commit

Permalink
Merge pull request #1149 from okuramasafumi/coverage-with-begin
Browse files Browse the repository at this point in the history
Add spec to the result of Coverage lib for `begin`
  • Loading branch information
andrykonchin authored Jun 26, 2024
2 parents 9fbc6ed + 7e50f24 commit a62556b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions library/coverage/fixtures/code_with_begin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
begin
'coverage with begin'
end
14 changes: 14 additions & 0 deletions library/coverage/result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@class_file = fixture __FILE__, 'some_class.rb'
@config_file = fixture __FILE__, 'start_coverage.rb'
@eval_code_file = fixture __FILE__, 'eval_code.rb'
@with_begin_file = fixture __FILE__, 'code_with_begin.rb'
end

before :each do
Expand All @@ -16,6 +17,7 @@
$LOADED_FEATURES.delete(@class_file)
$LOADED_FEATURES.delete(@config_file)
$LOADED_FEATURES.delete(@eval_code_file)
$LOADED_FEATURES.delete(@with_begin_file)

Coverage.result if Coverage.running?
end
Expand Down Expand Up @@ -354,4 +356,16 @@

Coverage.peek_result.should == result
end

it 'covers 100% lines with begin' do
Coverage.start
require @with_begin_file.chomp('.rb')
result = Coverage.result

result.should == {
@with_begin_file => [
nil, 1, nil
]
}
end
end

0 comments on commit a62556b

Please sign in to comment.