diff --git a/library/coverage/fixtures/code_with_begin.rb b/library/coverage/fixtures/code_with_begin.rb new file mode 100644 index 0000000000..9a6384e337 --- /dev/null +++ b/library/coverage/fixtures/code_with_begin.rb @@ -0,0 +1,3 @@ +begin + 'coverage with begin' +end diff --git a/library/coverage/result_spec.rb b/library/coverage/result_spec.rb index 33276778e8..54a3249e45 100644 --- a/library/coverage/result_spec.rb +++ b/library/coverage/result_spec.rb @@ -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 @@ -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 @@ -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