Skip to content
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

Add tests for combination of {bin,text}mode and external_encoding in ... #1076

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions core/io/shared/new.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,26 @@
@io.internal_encoding.to_s.should == 'IBM866'
end

it "does not use binmode argument when mode encoding is specified" do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion:

Suggested change
it "does not use binmode argument when mode encoding is specified" do
it "does not use binary encoding when mode encoding is specified along with binmode: true option" do

Actually it uses the binmode argument and #binmode? will return a specified value. But it doesn't affect io encoding.

There is a test for "b" mode and internal_encoding. Shouldn't we have a similar case with binmode/textmode options as well?

@io = IO.send(@method, @fd, 'w:iso-8859-1', binmode: true)
@io.external_encoding.to_s.should == 'ISO-8859-1'
end

it "does not use textmode argument when mode encoding is specified" do
@io = IO.send(@method, @fd, 'w:ascii-8bit', textmode: true)
@io.external_encoding.to_s.should == 'ASCII-8BIT'
end

it "does not use binmode argument when external encoding is specified via the :external_encoding option" do
@io = IO.send(@method, @fd, 'w', binmode: true, external_encoding: 'iso-8859-1')
@io.external_encoding.to_s.should == 'ISO-8859-1'
end

it "does not use textmode argument when external encoding is specified via the :external_encoding option" do
@io = IO.send(@method, @fd, 'w', textmode: true, external_encoding: 'ascii-8bit')
@io.external_encoding.to_s.should == 'ASCII-8BIT'
end

it "raises ArgumentError for nil options" do
-> {
IO.send(@method, @fd, 'w', nil)
Expand Down