diff --git a/lib/simplecov/source_file.rb b/lib/simplecov/source_file.rb index 8a2818e4..73715802 100644 --- a/lib/simplecov/source_file.rb +++ b/lib/simplecov/source_file.rb @@ -252,7 +252,6 @@ def ensure_remove_undefs(file_lines) end def build_lines - coverage_exceeding_source_warn if coverage_data["lines"].size > src.size lines = src.map.with_index(1) do |src, i| SimpleCov::SourceFile::Line.new(src, i, coverage_data["lines"][i - 1]) end @@ -272,11 +271,6 @@ def lines_strength lines.sum { |line| line.coverage.to_i } end - # Warning to identify condition from Issue #56 - def coverage_exceeding_source_warn - warn "Warning: coverage data provided by Coverage [#{coverage_data['lines'].size}] exceeds number of lines in #{filename} [#{src.size}]" - end - # # Build full branches report # Root branches represent the wrapper of all condition state that diff --git a/spec/helper.rb b/spec/helper.rb index 5ff8f497..1fd64a7d 100644 --- a/spec/helper.rb +++ b/spec/helper.rb @@ -16,17 +16,3 @@ def source_fixture(filename) def source_fixture_base_directory @source_fixture_base_directory ||= File.dirname(__FILE__) end - -# Taken from http://stackoverflow.com/questions/4459330/how-do-i-temporarily-redirect-stderr-in-ruby -def capture_stderr - # The output stream must be an IO-like object. In this case we capture it in - # an in-memory IO object so we can return the string value. You can assign any - # IO object here. - previous_stderr = $stderr - $stderr = StringIO.new - yield - $stderr.string -ensure - # Restore the previous value of stderr (typically equal to STDERR). - $stderr = previous_stderr -end diff --git a/spec/source_file_spec.rb b/spec/source_file_spec.rb index 30aefcfc..b50992f2 100644 --- a/spec/source_file_spec.rb +++ b/spec/source_file_spec.rb @@ -356,22 +356,17 @@ end end - context "simulating potential Ruby 1.9 defect -- see Issue #56" do + context "when coverage data contains more entries than the source has lines" do subject do SimpleCov::SourceFile.new(source_fixture("sample.rb"), COVERAGE_FOR_SAMPLE_RB_WITH_MORE_LINES) end it "has 16 source lines regardless of extra data in coverage array" do - # Do not litter test output with known warning - capture_stderr { expect(subject.lines.count).to eq(16) } + expect(subject.lines.count).to eq(16) end - it "prints a warning to stderr if coverage array contains more data than lines in the file" do - captured_output = capture_stderr do - subject.lines - end - - expect(captured_output).to match(/^Warning: coverage data provided/) + it "does not output to stderr" do + expect { subject.lines }.not_to output.to_stderr end end