-
-
Notifications
You must be signed in to change notification settings - Fork 389
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
adds IO#set_encoding_by_bom spec #813
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the new specs!
not_binary_io = new_io(@name, 'r') | ||
|
||
-> { not_binary_io.set_encoding_by_bom }.should raise_error(ArgumentError, 'ASCII incompatible encoding needs binmode') | ||
not_binary_io.close |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you move this in a begin/ensure/end? So even if the assertion fails, the IO is still closed.
|
||
@io.set_encoding_by_bom.should == Encoding::UTF_8 | ||
@io.external_encoding.should == Encoding::UTF_8 | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add examples for UTF-16LE and UTF16-BE BOM?
core/io/set_encoding_by_bom_spec.rb
Outdated
|
||
ruby_version_is "2.7" do | ||
it "returns the result encoding if found BOM UTF-8 sequence" do | ||
File.write(@name, "\u{FEFF}abc") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File.binwrite
seems better here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, looks great.
@eregon thanks for review! |
Solving #745