Skip to content
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

Add spec to the result of Coverage lib for begin #1149

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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