spec
spec copied to clipboard
Add extra test for IO.new with internal_encoding keyword
When providing a single encoding in the mode argument, the external encoding of the IO object is set to that encoding, the internal encoding is left blank. The ArgumentError in this case is a rather specific behaviour.
I'm marking this one as Draft for now, I'm not exactly sure if this is the intended behaviour.
Snippet of the observed behaviour (Ruby 3.1)
irb(main):001:0> io = IO.new(1, 'w:ISO-8859-1')
=> #<IO:fd 1>
irb(main):002:0> io.internal_encoding
=> nil
irb(main):003:0> io.external_encoding
=> #<Encoding:ISO-8859-1>
irb(main):004:0> io = IO.new(1, 'w:ISO-8859-1', internal_encoding: 'ISO-8859-1')
(irb):4:in `initialize': encoding specified twice (ArgumentError)