Skip to content

Commit

Permalink
fixes according review
Browse files Browse the repository at this point in the history
  • Loading branch information
moofkit authored and eregon committed Nov 3, 2020
1 parent 632db74 commit f975ca6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion core/io/set_encoding_by_bom_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,26 @@

ruby_version_is "2.7" do
it "returns the result encoding if found BOM UTF-8 sequence" do
File.write(@name, "\u{FEFF}abc")
File.binwrite(@name, "\u{FEFF}abc")

@io.set_encoding_by_bom.should == Encoding::UTF_8
@io.external_encoding.should == Encoding::UTF_8
end

it "returns the result encoding if found BOM UTF_16LE sequence" do
File.binwrite(@name, "\xFF\xFEabc")

@io.set_encoding_by_bom.should == Encoding::UTF_16LE
@io.external_encoding.should == Encoding::UTF_16LE
end

it "returns the result encoding if found BOM UTF_16BE sequence" do
File.binwrite(@name, "\xFE\xFFabc")

@io.set_encoding_by_bom.should == Encoding::UTF_16BE
@io.external_encoding.should == Encoding::UTF_16BE
end

it "returns nil if found BOM sequence not provided" do
File.write(@name, "abc")

Expand All @@ -30,6 +44,7 @@
not_binary_io = new_io(@name, 'r')

-> { not_binary_io.set_encoding_by_bom }.should raise_error(ArgumentError, 'ASCII incompatible encoding needs binmode')
ensure
not_binary_io.close
end

Expand Down

0 comments on commit f975ca6

Please sign in to comment.