Skip to content

Commit

Permalink
Merge pull request #194 from justfalter/fix_source_encoding_error
Browse files Browse the repository at this point in the history
Compatability with BINARY internal encoding
  • Loading branch information
colszowka committed Feb 12, 2013
2 parents ae49b30 + b9d689f commit 31a4ef4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/simplecov/source_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def status

def initialize(filename, coverage)
@filename, @coverage = filename, coverage
File.open(filename, "r:UTF-8") {|f| @src = f.readlines }
File.open(filename, "r:UTF-8:UTF-8") {|f| @src = f.readlines }
end

# Returns all source lines for this file as instances of SimpleCov::SourceFile::Line,
Expand Down
14 changes: 14 additions & 0 deletions test/test_source_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ class TestSourceFile < Test::Unit::TestCase
assert_nothing_raised do
source_file.process_skipped_lines!
end

should "handle utf-8 encoded source files when the default_internal encoding is binary" do
original_internal_encoding = Encoding.default_internal
Encoding.default_internal = "BINARY"
begin
source_file = SimpleCov::SourceFile.new(source_fixture('utf-8.rb'), [nil, nil, 1])
ensure
Encoding.default_internal = original_internal_encoding
end

assert_nothing_raised do
source_file.process_skipped_lines!
end
end
end
end
end if SimpleCov.usable?
Expand Down

0 comments on commit 31a4ef4

Please sign in to comment.