diff options
Diffstat (limited to 'spec/ruby/library')
55 files changed, 211 insertions, 204 deletions
diff --git a/spec/ruby/library/cgi/escapeURIComponent_spec.rb b/spec/ruby/library/cgi/escapeURIComponent_spec.rb index 2cf283c778..f05795a2f5 100644 --- a/spec/ruby/library/cgi/escapeURIComponent_spec.rb +++ b/spec/ruby/library/cgi/escapeURIComponent_spec.rb @@ -14,7 +14,7 @@ ruby_version_is "3.2" do end it "supports String with invalid encoding" do - string = "\xC0\<\<".force_encoding("UTF-8") + string = "\xC0\<\<".dup.force_encoding("UTF-8") CGI.escapeURIComponent(string).should == "%C0%3C%3C" end diff --git a/spec/ruby/library/csv/generate_spec.rb b/spec/ruby/library/csv/generate_spec.rb index 0a1e3d9604..b45e2eb95b 100644 --- a/spec/ruby/library/csv/generate_spec.rb +++ b/spec/ruby/library/csv/generate_spec.rb @@ -21,7 +21,7 @@ describe "CSV.generate" do end it "appends and returns the argument itself" do - str = "" + str = +"" csv_str = CSV.generate(str) do |csv| csv.add_row [1, 2, 3] csv << [4, 5, 6] diff --git a/spec/ruby/library/erb/run_spec.rb b/spec/ruby/library/erb/run_spec.rb index 8c07442d8f..602e53ab38 100644 --- a/spec/ruby/library/erb/run_spec.rb +++ b/spec/ruby/library/erb/run_spec.rb @@ -6,7 +6,7 @@ describe "ERB#run" do # lambda { ... }.should output def _steal_stdout orig = $stdout - s = '' + s = +'' def s.write(arg); self << arg.to_s; end $stdout = s begin diff --git a/spec/ruby/library/net-http/http/post_spec.rb b/spec/ruby/library/net-http/http/post_spec.rb index 9e7574015c..d7d94fec4a 100644 --- a/spec/ruby/library/net-http/http/post_spec.rb +++ b/spec/ruby/library/net-http/http/post_spec.rb @@ -60,7 +60,7 @@ describe "Net::HTTP#post" do describe "when passed a block" do it "yields fragments of the response body to the passed block" do - str = "" + str = +"" @http.post("/request", "test=test") do |res| str << res end diff --git a/spec/ruby/library/net-http/httpgenericrequest/exec_spec.rb b/spec/ruby/library/net-http/httpgenericrequest/exec_spec.rb index cf13e9dfd6..7de03d7da0 100644 --- a/spec/ruby/library/net-http/httpgenericrequest/exec_spec.rb +++ b/spec/ruby/library/net-http/httpgenericrequest/exec_spec.rb @@ -4,7 +4,7 @@ require "stringio" describe "Net::HTTPGenericRequest#exec when passed socket, version, path" do before :each do - @socket = StringIO.new("") + @socket = StringIO.new(+"") @buffered_socket = Net::BufferedIO.new(@socket) end diff --git a/spec/ruby/library/net-http/httpresponse/inspect_spec.rb b/spec/ruby/library/net-http/httpresponse/inspect_spec.rb index 43071ec8cd..23b6bff581 100644 --- a/spec/ruby/library/net-http/httpresponse/inspect_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/inspect_spec.rb @@ -8,7 +8,7 @@ describe "Net::HTTPResponse#inspect" do res.inspect.should == "#<Net::HTTPUnknownResponse ??? test response readbody=false>" res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - socket = Net::BufferedIO.new(StringIO.new("test body")) + socket = Net::BufferedIO.new(StringIO.new(+"test body")) res.reading_body(socket, true) {} res.inspect.should == "#<Net::HTTPUnknownResponse ??? test response readbody=true>" end diff --git a/spec/ruby/library/net-http/httpresponse/read_body_spec.rb b/spec/ruby/library/net-http/httpresponse/read_body_spec.rb index 380d17d3b9..61a576d812 100644 --- a/spec/ruby/library/net-http/httpresponse/read_body_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/read_body_spec.rb @@ -5,7 +5,7 @@ require 'stringio' describe "Net::HTTPResponse#read_body" do before :each do @res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - @socket = Net::BufferedIO.new(StringIO.new("test body")) + @socket = Net::BufferedIO.new(StringIO.new(+"test body")) end describe "when passed no arguments" do @@ -25,7 +25,7 @@ describe "Net::HTTPResponse#read_body" do describe "when passed a buffer" do it "reads the body to the passed buffer" do @res.reading_body(@socket, true) do - buffer = "" + buffer = +"" @res.read_body(buffer) buffer.should == "test body" end @@ -33,15 +33,15 @@ describe "Net::HTTPResponse#read_body" do it "returns the passed buffer" do @res.reading_body(@socket, true) do - buffer = "" + buffer = +"" @res.read_body(buffer).should equal(buffer) end end it "raises an IOError if called a second time" do @res.reading_body(@socket, true) do - @res.read_body("") - -> { @res.read_body("") }.should raise_error(IOError) + @res.read_body(+"") + -> { @res.read_body(+"") }.should raise_error(IOError) end end end @@ -51,7 +51,7 @@ describe "Net::HTTPResponse#read_body" do @res.reading_body(@socket, true) do yielded = false - buffer = "" + buffer = +"" @res.read_body do |body| yielded = true buffer << body @@ -79,7 +79,7 @@ describe "Net::HTTPResponse#read_body" do describe "when passed buffer and block" do it "raises an ArgumentError" do @res.reading_body(@socket, true) do - -> { @res.read_body("") {} }.should raise_error(ArgumentError) + -> { @res.read_body(+"") {} }.should raise_error(ArgumentError) end end end diff --git a/spec/ruby/library/net-http/httpresponse/reading_body_spec.rb b/spec/ruby/library/net-http/httpresponse/reading_body_spec.rb index 637a2806f8..b9ab112c96 100644 --- a/spec/ruby/library/net-http/httpresponse/reading_body_spec.rb +++ b/spec/ruby/library/net-http/httpresponse/reading_body_spec.rb @@ -5,7 +5,7 @@ require "stringio" describe "Net::HTTPResponse#reading_body" do before :each do @res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - @socket = Net::BufferedIO.new(StringIO.new("test body")) + @socket = Net::BufferedIO.new(StringIO.new(+"test body")) end describe "when body_allowed is true" do diff --git a/spec/ruby/library/net-http/httpresponse/shared/body.rb b/spec/ruby/library/net-http/httpresponse/shared/body.rb index 618e3936fb..f35ca3200c 100644 --- a/spec/ruby/library/net-http/httpresponse/shared/body.rb +++ b/spec/ruby/library/net-http/httpresponse/shared/body.rb @@ -3,7 +3,7 @@ require 'stringio' describe :net_httpresponse_body, shared: true do before :each do @res = Net::HTTPUnknownResponse.new("1.0", "???", "test response") - @socket = Net::BufferedIO.new(StringIO.new("test body")) + @socket = Net::BufferedIO.new(StringIO.new(+"test body")) end it "returns the read body" do diff --git a/spec/ruby/library/objectspace/fixtures/trace.rb b/spec/ruby/library/objectspace/fixtures/trace.rb index fd4524b0ba..e53a7a0cac 100644 --- a/spec/ruby/library/objectspace/fixtures/trace.rb +++ b/spec/ruby/library/objectspace/fixtures/trace.rb @@ -1,3 +1,4 @@ +# frozen_string_literal: false require "objspace/trace" a = "foo" b = "b" + "a" + "r" diff --git a/spec/ruby/library/objectspace/trace_spec.rb b/spec/ruby/library/objectspace/trace_spec.rb index 59952a006c..532c282ce4 100644 --- a/spec/ruby/library/objectspace/trace_spec.rb +++ b/spec/ruby/library/objectspace/trace_spec.rb @@ -6,8 +6,8 @@ ruby_version_is "3.1" do file = fixture(__FILE__ , "trace.rb") ruby_exe(file, args: "2>&1").lines(chomp: true).should == [ "objspace/trace is enabled", - "\"foo\" @ #{file}:2", - "\"bar\" @ #{file}:3", + "\"foo\" @ #{file}:3", + "\"bar\" @ #{file}:4", "42" ] end diff --git a/spec/ruby/library/set/compare_by_identity_spec.rb b/spec/ruby/library/set/compare_by_identity_spec.rb index 9ed1602189..602d1e758e 100644 --- a/spec/ruby/library/set/compare_by_identity_spec.rb +++ b/spec/ruby/library/set/compare_by_identity_spec.rb @@ -5,7 +5,7 @@ describe "Set#compare_by_identity" do it "compares its members by identity" do a = "a" b1 = "b" - b2 = "b" + b2 = b1.dup set = Set.new set.compare_by_identity diff --git a/spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb b/spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb index b6ab8a9cea..17c846054d 100644 --- a/spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb +++ b/spec/ruby/library/socket/basicsocket/recv_nonblock_spec.rb @@ -52,7 +52,7 @@ describe "Socket::BasicSocket#recv_nonblock" do @s2.send("data", 0, @s1.getsockname) IO.select([@s1], nil, nil, 2) - buf = "foo" + buf = +"foo" @s1.recv_nonblock(5, 0, buf) buf.should == "data" end diff --git a/spec/ruby/library/socket/basicsocket/recv_spec.rb b/spec/ruby/library/socket/basicsocket/recv_spec.rb index a56114f4ab..9fe8c52f9a 100644 --- a/spec/ruby/library/socket/basicsocket/recv_spec.rb +++ b/spec/ruby/library/socket/basicsocket/recv_spec.rb @@ -100,7 +100,7 @@ describe "BasicSocket#recv" do socket.write("data") client = @server.accept - buf = "foo" + buf = +"foo" begin client.recv(4, 0, buf) ensure diff --git a/spec/ruby/library/socket/basicsocket/send_spec.rb b/spec/ruby/library/socket/basicsocket/send_spec.rb index 041ce03d72..86b5567026 100644 --- a/spec/ruby/library/socket/basicsocket/send_spec.rb +++ b/spec/ruby/library/socket/basicsocket/send_spec.rb @@ -17,7 +17,7 @@ describe "BasicSocket#send" do end it "sends a message to another socket and returns the number of bytes sent" do - data = "" + data = +"" t = Thread.new do client = @server.accept loop do @@ -62,7 +62,7 @@ describe "BasicSocket#send" do end it "accepts a sockaddr as recipient address" do - data = "" + data = +"" t = Thread.new do client = @server.accept loop do diff --git a/spec/ruby/library/stringio/append_spec.rb b/spec/ruby/library/stringio/append_spec.rb index 5383e3e795..cb50d73d1b 100644 --- a/spec/ruby/library/stringio/append_spec.rb +++ b/spec/ruby/library/stringio/append_spec.rb @@ -3,7 +3,7 @@ require_relative 'fixtures/classes' describe "StringIO#<< when passed [Object]" do before :each do - @io = StringIO.new("example") + @io = StringIO.new(+"example") end it "returns self" do @@ -44,10 +44,10 @@ end describe "StringIO#<< when self is not writable" do it "raises an IOError" do - io = StringIO.new("test", "r") + io = StringIO.new(+"test", "r") -> { io << "test" }.should raise_error(IOError) - io = StringIO.new("test") + io = StringIO.new(+"test") io.close_write -> { io << "test" }.should raise_error(IOError) end @@ -55,7 +55,7 @@ end describe "StringIO#<< when in append mode" do before :each do - @io = StringIO.new("example", "a") + @io = StringIO.new(+"example", "a") end it "appends the passed argument to the end of self, ignoring current position" do diff --git a/spec/ruby/library/stringio/close_read_spec.rb b/spec/ruby/library/stringio/close_read_spec.rb index 80bd547e85..0f08e1ff2e 100644 --- a/spec/ruby/library/stringio/close_read_spec.rb +++ b/spec/ruby/library/stringio/close_read_spec.rb @@ -3,7 +3,7 @@ require_relative 'fixtures/classes' describe "StringIO#close_read" do before :each do - @io = StringIO.new("example") + @io = StringIO.new(+"example") end it "returns nil" do @@ -21,7 +21,7 @@ describe "StringIO#close_read" do end it "raises an IOError when in write-only mode" do - io = StringIO.new("example", "w") + io = StringIO.new(+"example", "w") -> { io.close_read }.should raise_error(IOError) io = StringIO.new("example") diff --git a/spec/ruby/library/stringio/close_write_spec.rb b/spec/ruby/library/stringio/close_write_spec.rb index 1a4cfa113e..c86c3f9826 100644 --- a/spec/ruby/library/stringio/close_write_spec.rb +++ b/spec/ruby/library/stringio/close_write_spec.rb @@ -3,7 +3,7 @@ require_relative 'fixtures/classes' describe "StringIO#close_write" do before :each do - @io = StringIO.new("example") + @io = StringIO.new(+"example") end it "returns nil" do @@ -21,10 +21,10 @@ describe "StringIO#close_write" do end it "raises an IOError when in read-only mode" do - io = StringIO.new("example", "r") + io = StringIO.new(+"example", "r") -> { io.close_write }.should raise_error(IOError) - io = StringIO.new("example") + io = StringIO.new(+"example") io.close_write io.close_write.should == nil end diff --git a/spec/ruby/library/stringio/closed_read_spec.rb b/spec/ruby/library/stringio/closed_read_spec.rb index cb4267ac98..b4dcadc3a4 100644 --- a/spec/ruby/library/stringio/closed_read_spec.rb +++ b/spec/ruby/library/stringio/closed_read_spec.rb @@ -3,7 +3,7 @@ require_relative 'fixtures/classes' describe "StringIO#closed_read?" do it "returns true if self is not readable" do - io = StringIO.new("example", "r+") + io = StringIO.new(+"example", "r+") io.close_write io.closed_read?.should be_false io.close_read diff --git a/spec/ruby/library/stringio/closed_spec.rb b/spec/ruby/library/stringio/closed_spec.rb index ca8a2232a8..bf7ba63184 100644 --- a/spec/ruby/library/stringio/closed_spec.rb +++ b/spec/ruby/library/stringio/closed_spec.rb @@ -3,13 +3,13 @@ require_relative 'fixtures/classes' describe "StringIO#closed?" do it "returns true if self is completely closed" do - io = StringIO.new("example", "r+") + io = StringIO.new(+"example", "r+") io.close_read io.closed?.should be_false io.close_write io.closed?.should be_true - io = StringIO.new("example", "r+") + io = StringIO.new(+"example", "r+") io.close io.closed?.should be_true end diff --git a/spec/ruby/library/stringio/closed_write_spec.rb b/spec/ruby/library/stringio/closed_write_spec.rb index 5c111affd8..2bd3e6fa8b 100644 --- a/spec/ruby/library/stringio/closed_write_spec.rb +++ b/spec/ruby/library/stringio/closed_write_spec.rb @@ -3,7 +3,7 @@ require_relative 'fixtures/classes' describe "StringIO#closed_write?" do it "returns true if self is not writable" do - io = StringIO.new("example", "r+") + io = StringIO.new(+"example", "r+") io.close_read io.closed_write?.should be_false io.close_write diff --git a/spec/ruby/library/stringio/fcntl_spec.rb b/spec/ruby/library/stringio/fcntl_spec.rb index a78004d868..f252d5e738 100644 --- a/spec/ruby/library/stringio/fcntl_spec.rb +++ b/spec/ruby/library/stringio/fcntl_spec.rb @@ -3,6 +3,6 @@ require_relative 'fixtures/classes' describe "StringIO#fcntl" do it "raises a NotImplementedError" do - -> { StringIO.new("boom").fcntl }.should raise_error(NotImplementedError) + -> { StringIO.new(+"boom").fcntl }.should raise_error(NotImplementedError) end end diff --git a/spec/ruby/library/stringio/flush_spec.rb b/spec/ruby/library/stringio/flush_spec.rb index 17a16dfdd5..4dc58b1d48 100644 --- a/spec/ruby/library/stringio/flush_spec.rb +++ b/spec/ruby/library/stringio/flush_spec.rb @@ -3,7 +3,7 @@ require_relative 'fixtures/classes' describe "StringIO#flush" do it "returns self" do - io = StringIO.new("flush") + io = StringIO.new(+"flush") io.flush.should equal(io) end end diff --git a/spec/ruby/library/stringio/fsync_spec.rb b/spec/ruby/library/stringio/fsync_spec.rb index 8fb2b59a24..85053cb2e5 100644 --- a/spec/ruby/library/stringio/fsync_spec.rb +++ b/spec/ruby/library/stringio/fsync_spec.rb @@ -3,7 +3,7 @@ require_relative 'fixtures/classes' describe "StringIO#fsync" do it "returns zero" do - io = StringIO.new("fsync") + io = StringIO.new(+"fsync") io.fsync.should eql(0) end end diff --git a/spec/ruby/library/stringio/gets_spec.rb b/spec/ruby/library/stringio/gets_spec.rb index d597ec0e45..4af7704a41 100644 --- a/spec/ruby/library/stringio/gets_spec.rb +++ b/spec/ruby/library/stringio/gets_spec.rb @@ -233,7 +233,7 @@ end describe "StringIO#gets when in write-only mode" do it "raises an IOError" do - io = StringIO.new("xyz", "w") + io = StringIO.new(+"xyz", "w") -> { io.gets }.should raise_error(IOError) io = StringIO.new("xyz") diff --git a/spec/ruby/library/stringio/initialize_spec.rb b/spec/ruby/library/stringio/initialize_spec.rb index 158c08488b..d1dff590bb 100644 --- a/spec/ruby/library/stringio/initialize_spec.rb +++ b/spec/ruby/library/stringio/initialize_spec.rb @@ -13,99 +13,99 @@ describe "StringIO#initialize when passed [Object, mode]" do it "sets the mode based on the passed mode" do io = StringIO.allocate - io.send(:initialize, "example", "r") + io.send(:initialize, +"example", "r") io.closed_read?.should be_false io.closed_write?.should be_true io = StringIO.allocate - io.send(:initialize, "example", "rb") + io.send(:initialize, +"example", "rb") io.closed_read?.should be_false io.closed_write?.should be_true io = StringIO.allocate - io.send(:initialize, "example", "r+") + io.send(:initialize, +"example", "r+") io.closed_read?.should be_false io.closed_write?.should be_false io = StringIO.allocate - io.send(:initialize, "example", "rb+") + io.send(:initialize, +"example", "rb+") io.closed_read?.should be_false io.closed_write?.should be_false io = StringIO.allocate - io.send(:initialize, "example", "w") + io.send(:initialize, +"example", "w") io.closed_read?.should be_true io.closed_write?.should be_false io = StringIO.allocate - io.send(:initialize, "example", "wb") + io.send(:initialize, +"example", "wb") io.closed_read?.should be_true io.closed_write?.should be_false io = StringIO.allocate - io.send(:initialize, "example", "w+") + io.send(:initialize, +"example", "w+") io.closed_read?.should be_false io.closed_write?.should be_false io = StringIO.allocate - io.send(:initialize, "example", "wb+") + io.send(:initialize, +"example", "wb+") io.closed_read?.should be_false io.closed_write?.should be_false io = StringIO.allocate - io.send(:initialize, "example", "a") + io.send(:initialize, +"example", "a") io.closed_read?.should be_true io.closed_write?.should be_false io = StringIO.allocate - io.send(:initialize, "example", "ab") + io.send(:initialize, +"example", "ab") io.closed_read?.should be_true io.closed_write?.should be_false io = StringIO.allocate - io.send(:initialize, "example", "a+") + io.send(:initialize, +"example", "a+") io.closed_read?.should be_false io.closed_write?.should be_false io = StringIO.allocate - io.send(:initialize, "example", "ab+") + io.send(:initialize, +"example", "ab+") io.closed_read?.should be_false io.closed_write?.should be_false end it "allows passing the mode as an Integer" do io = StringIO.allocate - io.send(:initialize, "example", IO::RDONLY) + io.send(:initialize, +"example", IO::RDONLY) io.closed_read?.should be_false io.closed_write?.should be_true io = StringIO.allocate - io.send(:initialize, "example", IO::RDWR) + io.send(:initialize, +"example", IO::RDWR) io.closed_read?.should be_false io.closed_write?.should be_false io = StringIO.allocate - io.send(:initialize, "example", IO::WRONLY) + io.send(:initialize, +"example", IO::WRONLY) io.closed_read?.should be_true io.closed_write?.should be_false io = StringIO.allocate - io.send(:initialize, "example", IO::WRONLY | IO::TRUNC) + io.send(:initialize, +"example", IO::WRONLY | IO::TRUNC) io.closed_read?.should be_true io.closed_write?.should be_false io = StringIO.allocate - io.send(:initialize, "example", IO::RDWR | IO::TRUNC) + io.send(:initialize, +"example", IO::RDWR | IO::TRUNC) io.closed_read?.should be_false io.closed_write?.should be_false io = StringIO.allocate - io.send(:initialize, "example", IO::WRONLY | IO::APPEND) + io.send(:initialize, +"example", IO::WRONLY | IO::APPEND) io.closed_read?.should be_true io.closed_write?.should be_false io = StringIO.allocate - io.send(:initialize, "example", IO::RDWR | IO::APPEND) + io.send(:initialize, +"example", IO::RDWR | IO::APPEND) io.closed_read?.should be_false io.closed_write?.should be_false end @@ -118,7 +118,7 @@ describe "StringIO#initialize when passed [Object, mode]" do it "tries to convert the passed mode to a String using #to_str" do obj = mock('to_str') obj.should_receive(:to_str).and_return("r") - @io.send(:initialize, "example", obj) + @io.send(:initialize, +"example", obj) @io.closed_read?.should be_false @io.closed_write?.should be_true @@ -142,12 +142,18 @@ describe "StringIO#initialize when passed [Object]" do @io.string.should equal(str) end - it "sets the mode to read-write" do - @io.send(:initialize, "example") + it "sets the mode to read-write if the string is mutable" do + @io.send(:initialize, +"example") @io.closed_read?.should be_false @io.closed_write?.should be_false end + it "sets the mode to read if the string is frozen" do + @io.send(:initialize, -"example") + @io.closed_read?.should be_false + @io.closed_write?.should be_true + end + it "tries to convert the passed Object to a String using #to_str" do obj = mock('to_str') obj.should_receive(:to_str).and_return("example") @@ -166,28 +172,28 @@ end # NOTE: Synchronise with core/io/new_spec.rb (core/io/shared/new.rb) describe "StringIO#initialize when passed keyword arguments" do it "sets the mode based on the passed :mode option" do - io = StringIO.new("example", "r") + io = StringIO.new(+"example", "r") io.closed_read?.should be_false io.closed_write?.should be_true end it "accepts a mode argument set to nil with a valid :mode option" do - @io = StringIO.new('', nil, mode: "w") + @io = StringIO.new(+'', nil, mode: "w") @io.write("foo").should == 3 end it "accepts a mode argument with a :mode option set to nil" do - @io = StringIO.new('', "w", mode: nil) + @io = StringIO.new(+'', "w", mode: nil) @io.write("foo").should == 3 end it "sets binmode from :binmode option" do - @io = StringIO.new('', 'w', binmode: true) + @io = StringIO.new(+'', 'w', binmode: true) @io.external_encoding.to_s.should == "ASCII-8BIT" # #binmode? isn't implemented in StringIO end it "does not set binmode from false :binmode" do - @io = StringIO.new('', 'w', binmode: false) + @io = StringIO.new(+'', 'w', binmode: false) @io.external_encoding.to_s.should == "UTF-8" # #binmode? isn't implemented in StringIO end end @@ -196,54 +202,54 @@ end describe "StringIO#initialize when passed keyword arguments and error happens" do it "raises an error if passed encodings two ways" do -> { - @io = StringIO.new('', 'w:ISO-8859-1', encoding: 'ISO-8859-1') + @io = StringIO.new(+'', 'w:ISO-8859-1', encoding: 'ISO-8859-1') }.should raise_error(ArgumentError) -> { - @io = StringIO.new('', 'w:ISO-8859-1', external_encoding: 'ISO-8859-1') + @io = StringIO.new(+'', 'w:ISO-8859-1', external_encoding: 'ISO-8859-1') }.should raise_error(ArgumentError) -> { - @io = StringIO.new('', 'w:ISO-8859-1:UTF-8', internal_encoding: 'ISO-8859-1') + @io = StringIO.new(+'', 'w:ISO-8859-1:UTF-8', internal_encoding: 'ISO-8859-1') }.should raise_error(ArgumentError) end it "raises an error if passed matching binary/text mode two ways" do -> { - @io = StringIO.new('', "wb", binmode: true) + @io = StringIO.new(+'', "wb", binmode: true) }.should raise_error(ArgumentError) -> { - @io = StringIO.new('', "wt", textmode: true) + @io = StringIO.new(+'', "wt", textmode: true) }.should raise_error(ArgumentError) -> { - @io = StringIO.new('', "wb", textmode: false) + @io = StringIO.new(+'', "wb", textmode: false) }.should raise_error(ArgumentError) -> { - @io = StringIO.new('', "wt", binmode: false) + @io = StringIO.new(+'', "wt", binmode: false) }.should raise_error(ArgumentError) end it "raises an error if passed conflicting binary/text mode two ways" do -> { - @io = StringIO.new('', "wb", binmode: false) + @io = StringIO.new(+'', "wb", binmode: false) }.should raise_error(ArgumentError) -> { - @io = StringIO.new('', "wt", textmode: false) + @io = StringIO.new(+'', "wt", textmode: false) }.should raise_error(ArgumentError) -> { - @io = StringIO.new('', "wb", textmode: true) + @io = StringIO.new(+'', "wb", textmode: true) }.should raise_error(ArgumentError) -> { - @io = StringIO.new('', "wt", binmode: true) + @io = StringIO.new(+'', "wt", binmode: true) }.should raise_error(ArgumentError) end it "raises an error when trying to set both binmode and textmode" do -> { - @io = StringIO.new('', "w", textmode: true, binmode: true) + @io = StringIO.new(+'', "w", textmode: true, binmode: true) }.should raise_error(ArgumentError) -> { - @io = StringIO.new('', File::Constants::WRONLY, textmode: true, binmode: true) + @io = StringIO.new(+'', File::Constants::WRONLY, textmode: true, binmode: true) }.should raise_error(ArgumentError) end end @@ -258,7 +264,7 @@ describe "StringIO#initialize when passed no arguments" do end it "sets the mode to read-write" do - @io.send(:initialize, "example") + @io.send(:initialize) @io.closed_read?.should be_false @io.closed_write?.should be_false end @@ -289,13 +295,13 @@ describe "StringIO#initialize sets" do end it "the encoding to the encoding of the String when passed a String" do - s = ''.force_encoding(Encoding::EUC_JP) + s = ''.dup.force_encoding(Encoding::EUC_JP) io = StringIO.new(s) io.string.encoding.should == Encoding::EUC_JP end it "the #external_encoding to the encoding of the String when passed a String" do - s = ''.force_encoding(Encoding::EUC_JP) + s = ''.dup.force_encoding(Encoding::EUC_JP) io = StringIO.new(s) io.external_encoding.should == Encoding::EUC_JP end diff --git a/spec/ruby/library/stringio/open_spec.rb b/spec/ruby/library/stringio/open_spec.rb index 3068e19435..b7c90661f9 100644 --- a/spec/ruby/library/stringio/open_spec.rb +++ b/spec/ruby/library/stringio/open_spec.rb @@ -8,26 +8,26 @@ describe "StringIO.open when passed [Object, mode]" do end it "returns the blocks return value when yielding" do - ret = StringIO.open("example", "r") { :test } + ret = StringIO.open(+"example", "r") { :test } ret.should equal(:test) end it "yields self to the passed block" do io = nil - StringIO.open("example", "r") { |strio| io = strio } + StringIO.open(+"example", "r") { |strio| io = strio } io.should be_kind_of(StringIO) end it "closes self after yielding" do io = nil - StringIO.open("example", "r") { |strio| io = strio } + StringIO.open(+"example", "r") { |strio| io = strio } io.closed?.should be_true end it "even closes self when an exception is raised while yielding" do io = nil begin - StringIO.open("example", "r") do |strio| + StringIO.open(+"example", "r") do |strio| io = strio raise "Error" end @@ -38,14 +38,14 @@ describe "StringIO.open when passed [Object, mode]" do it "sets self's string to nil after yielding" do io = nil - StringIO.open("example", "r") { |strio| io = strio } + StringIO.open(+"example", "r") { |strio| io = strio } io.string.should be_nil end it "even sets self's string to nil when an exception is raised while yielding" do io = nil begin - StringIO.open("example", "r") do |strio| + StringIO.open(+"example", "r") do |strio| io = strio raise "Error" end @@ -55,81 +55,81 @@ describe "StringIO.open when passed [Object, mode]" do end it "sets the mode based on the passed mode" do - io = StringIO.open("example", "r") + io = StringIO.open(+"example", "r") io.closed_read?.should be_false io.closed_write?.should be_true - io = StringIO.open("example", "rb") + io = StringIO.open(+"example", "rb") io.closed_read?.should be_false io.closed_write?.should be_true - io = StringIO.open("example", "r+") + io = StringIO.open(+"example", "r+") io.closed_read?.should be_false io.closed_write?.should be_false - io = StringIO.open("example", "rb+") + io = StringIO.open(+"example", "rb+") io.closed_read?.should be_false io.closed_write?.should be_false - io = StringIO.open("example", "w") + io = StringIO.open(+"example", "w") io.closed_read?.should be_true io.closed_write?.should be_false - io = StringIO.open("example", "wb") + io = StringIO.open(+"example", "wb") io.closed_read?.should be_true io.closed_write?.should be_false - io = StringIO.open("example", "w+") + io = StringIO.open(+"example", "w+") io.closed_read?.should be_false io.closed_write?.should be_false - io = StringIO.open("example", "wb+") + io = StringIO.open(+"example", "wb+") io.closed_read?.should be_false io.closed_write?.should be_false - io = StringIO.open("example", "a") + io = StringIO.open(+"example", "a") io.closed_read?.should be_true io.closed_write?.should be_false - io = StringIO.open("example", "ab") + io = StringIO.open(+"example", "ab") io.closed_read?.should be_true io.closed_write?.should be_false - io = StringIO.open("example", "a+") + io = StringIO.open(+"example", "a+") io.closed_read?.should be_false io.closed_write?.should be_false - io = StringIO.open("example", "ab+") + io = StringIO.open(+"example", "ab+") io.closed_read?.should be_false io.closed_write?.should be_false end it "allows passing the mode as an Integer" do - io = StringIO.open("example", IO::RDONLY) + io = StringIO.open(+"example", IO::RDONLY) io.closed_read?.should be_false io.closed_write?.should be_true - io = StringIO.open("example", IO::RDWR) + io = StringIO.open(+"example", IO::RDWR) io.closed_read?.should be_false io.closed_write?.should be_false - io = StringIO.open("example", IO::WRONLY) + io = StringIO.open(+"example", IO::WRONLY) io.closed_read?.should be_true io.closed_write?.should be_false - io = StringIO.open("example", IO::WRONLY | IO::TRUNC) + io = StringIO.open(+"example", IO::WRONLY | IO::TRUNC) io.closed_read?.should be_true io.closed_write?.should be_false - io = StringIO.open("example", IO::RDWR | IO::TRUNC) + io = StringIO.open(+"example", IO::RDWR | IO::TRUNC) io.closed_read?.should be_false io.closed_write?.should be_false - io = StringIO.open("example", IO::WRONLY | IO::APPEND) + io = StringIO.open(+"example", IO::WRONLY | IO::APPEND) io.closed_read?.should be_true io.closed_write?.should be_false - io = StringIO.open("example", IO::RDWR | IO::APPEND) + io = StringIO.open(+"example", IO::RDWR | IO::APPEND) io.closed_read?.should be_false io.closed_write?.should be_false end @@ -141,7 +141,7 @@ describe "StringIO.open when passed [Object, mode]" do it "tries to convert the passed mode to a String using #to_str" do obj = mock('to_str') obj.should_receive(:to_str).and_return("r") - io = StringIO.open("example", obj) + io = StringIO.open(+"example", obj) io.closed_read?.should be_false io.closed_write?.should be_true @@ -163,16 +163,16 @@ describe "StringIO.open when passed [Object]" do it "yields self to the passed block" do io = nil - ret = StringIO.open("example") { |strio| io = strio } + ret = StringIO.open(+"example") { |strio| io = strio } io.should equal(ret) end it "sets the mode to read-write (r+)" do - io = StringIO.open("example") + io = StringIO.open(+"example") io.closed_read?.should be_false io.closed_write?.should be_false - io = StringIO.new("example") + io = StringIO.new(+"example") io.printf("%d", 123) io.string.should == "123mple" end @@ -204,7 +204,7 @@ describe "StringIO.open when passed no arguments" do io.closed_read?.should be_false io.closed_write?.should be_false - io = StringIO.new("example") + io = StringIO.new(+"example") io.printf("%d", 123) io.string.should == "123mple" end diff --git a/spec/ruby/library/stringio/print_spec.rb b/spec/ruby/library/stringio/print_spec.rb index 6ac6430900..00c33367dc 100644 --- a/spec/ruby/library/stringio/print_spec.rb +++ b/spec/ruby/library/stringio/print_spec.rb @@ -3,7 +3,7 @@ require_relative 'fixtures/classes' describe "StringIO#print" do before :each do - @io = StringIO.new('example') + @io = StringIO.new(+'example') end it "prints $_ when passed no arguments" do @@ -73,7 +73,7 @@ end describe "StringIO#print when in append mode" do before :each do - @io = StringIO.new("example", "a") + @io = StringIO.new(+"example", "a") end it "appends the passed argument to the end of self" do @@ -92,10 +92,10 @@ end describe "StringIO#print when self is not writable" do it "raises an IOError" do - io = StringIO.new("test", "r") + io = StringIO.new(+"test", "r") -> { io.print("test") }.should raise_error(IOError) - io = StringIO.new("test") + io = StringIO.new(+"test") io.close_write -> { io.print("test") }.should raise_error(IOError) end diff --git a/spec/ruby/library/stringio/printf_spec.rb b/spec/ruby/library/stringio/printf_spec.rb index f3f669a185..ca82e84757 100644 --- a/spec/ruby/library/stringio/printf_spec.rb +++ b/spec/ruby/library/stringio/printf_spec.rb @@ -41,7 +41,7 @@ end describe "StringIO#printf when in read-write mode" do before :each do - @io = StringIO.new("example", "r+") + @io = StringIO.new(+"example", "r+") end it "starts from the beginning" do @@ -62,7 +62,7 @@ end describe "StringIO#printf when in append mode" do before :each do - @io = StringIO.new("example", "a") + @io = StringIO.new(+"example", "a") end it "appends the passed argument to the end of self" do @@ -81,10 +81,10 @@ end describe "StringIO#printf when self is not writable" do it "raises an IOError" do - io = StringIO.new("test", "r") + io = StringIO.new(+"test", "r") -> { io.printf("test") }.should raise_error(IOError) - io = StringIO.new("test") + io = StringIO.new(+"test") io.close_write -> { io.printf("test") }.should raise_error(IOError) end diff --git a/spec/ruby/library/stringio/putc_spec.rb b/spec/ruby/library/stringio/putc_spec.rb index 1ce53b7ef2..9f1ac8ffb2 100644 --- a/spec/ruby/library/stringio/putc_spec.rb +++ b/spec/ruby/library/stringio/putc_spec.rb @@ -3,7 +3,7 @@ require_relative 'fixtures/classes' describe "StringIO#putc when passed [String]" do before :each do - @io = StringIO.new('example') + @io = StringIO.new(+'example') end it "overwrites the character at the current position" do @@ -54,7 +54,7 @@ end describe "StringIO#putc when passed [Object]" do before :each do - @io = StringIO.new('example') + @io = StringIO.new(+'example') end it "it writes the passed Integer % 256 to self" do @@ -85,7 +85,7 @@ end describe "StringIO#putc when in append mode" do it "appends to the end of self" do - io = StringIO.new("test", "a") + io = StringIO.new(+"test", "a") io.putc(?t) io.string.should == "testt" end @@ -93,10 +93,10 @@ end describe "StringIO#putc when self is not writable" do it "raises an IOError" do - io = StringIO.new("test", "r") + io = StringIO.new(+"test", "r") -> { io.putc(?a) }.should raise_error(IOError) - io = StringIO.new("test") + io = StringIO.new(+"test") io.close_write -> { io.putc("t") }.should raise_error(IOError) end diff --git a/spec/ruby/library/stringio/puts_spec.rb b/spec/ruby/library/stringio/puts_spec.rb index 9c890262dd..054ec8227f 100644 --- a/spec/ruby/library/stringio/puts_spec.rb +++ b/spec/ruby/library/stringio/puts_spec.rb @@ -145,7 +145,7 @@ end describe "StringIO#puts when in append mode" do before :each do - @io = StringIO.new("example", "a") + @io = StringIO.new(+"example", "a") end it "appends the passed argument to the end of self" do @@ -164,10 +164,10 @@ end describe "StringIO#puts when self is not writable" do it "raises an IOError" do - io = StringIO.new("test", "r") + io = StringIO.new(+"test", "r") -> { io.puts }.should raise_error(IOError) - io = StringIO.new("test") + io = StringIO.new(+"test") io.close_write -> { io.puts }.should raise_error(IOError) end @@ -175,7 +175,7 @@ end describe "StringIO#puts when passed an encoded string" do it "stores the bytes unmodified" do - io = StringIO.new("") + io = StringIO.new(+"") io.puts "\x00\x01\x02" io.puts "æåø" diff --git a/spec/ruby/library/stringio/read_nonblock_spec.rb b/spec/ruby/library/stringio/read_nonblock_spec.rb index d4ec56d9aa..8b78b1b0e4 100644 --- a/spec/ruby/library/stringio/read_nonblock_spec.rb +++ b/spec/ruby/library/stringio/read_nonblock_spec.rb @@ -8,7 +8,7 @@ describe "StringIO#read_nonblock when passed length, buffer" do it "accepts :exception option" do io = StringIO.new("example") - io.read_nonblock(3, buffer = "", exception: true) + io.read_nonblock(3, buffer = +"", exception: true) buffer.should == "exa" end end @@ -33,14 +33,14 @@ end describe "StringIO#read_nonblock" do it "accepts an exception option" do - stringio = StringIO.new('foo') + stringio = StringIO.new(+'foo') stringio.read_nonblock(3, exception: false).should == 'foo' end context "when exception option is set to false" do context "when the end is reached" do it "returns nil" do - stringio = StringIO.new('') + stringio = StringIO.new(+'') stringio << "hello" stringio.rewind diff --git a/spec/ruby/library/stringio/read_spec.rb b/spec/ruby/library/stringio/read_spec.rb index 52ab3dcf47..e49f262127 100644 --- a/spec/ruby/library/stringio/read_spec.rb +++ b/spec/ruby/library/stringio/read_spec.rb @@ -53,7 +53,7 @@ describe "StringIO#read when passed length and a buffer" do end it "reads [length] characters into the buffer" do - buf = "foo" + buf = +"foo" result = @io.read(10, buf) buf.should == "abcdefghij" diff --git a/spec/ruby/library/stringio/readline_spec.rb b/spec/ruby/library/stringio/readline_spec.rb index b794e5fade..b16a16e23f 100644 --- a/spec/ruby/library/stringio/readline_spec.rb +++ b/spec/ruby/library/stringio/readline_spec.rb @@ -113,7 +113,7 @@ end describe "StringIO#readline when in write-only mode" do it "raises an IOError" do - io = StringIO.new("xyz", "w") + io = StringIO.new(+"xyz", "w") -> { io.readline }.should raise_error(IOError) io = StringIO.new("xyz") diff --git a/spec/ruby/library/stringio/readlines_spec.rb b/spec/ruby/library/stringio/readlines_spec.rb index c471d0fd73..ed7cc22b3d 100644 --- a/spec/ruby/library/stringio/readlines_spec.rb +++ b/spec/ruby/library/stringio/readlines_spec.rb @@ -83,7 +83,7 @@ end describe "StringIO#readlines when in write-only mode" do it "raises an IOError" do - io = StringIO.new("xyz", "w") + io = StringIO.new(+"xyz", "w") -> { io.readlines }.should raise_error(IOError) io = StringIO.new("xyz") diff --git a/spec/ruby/library/stringio/readpartial_spec.rb b/spec/ruby/library/stringio/readpartial_spec.rb index 2601fe8c42..f25cef4014 100644 --- a/spec/ruby/library/stringio/readpartial_spec.rb +++ b/spec/ruby/library/stringio/readpartial_spec.rb @@ -3,7 +3,7 @@ require_relative 'fixtures/classes' describe "StringIO#readpartial" do before :each do - @string = StringIO.new('Stop, look, listen') + @string = StringIO.new(+'Stop, look, listen') end after :each do @@ -48,7 +48,7 @@ describe "StringIO#readpartial" do end it "discards the existing buffer content upon successful read" do - buffer = "existing" + buffer = +"existing" @string.readpartial(11, buffer) buffer.should == "Stop, look," end @@ -59,7 +59,7 @@ describe "StringIO#readpartial" do end it "discards the existing buffer content upon error" do - buffer = 'hello' + buffer = +'hello' @string.readpartial(100) -> { @string.readpartial(1, buffer) }.should raise_error(EOFError) buffer.should be_empty diff --git a/spec/ruby/library/stringio/reopen_spec.rb b/spec/ruby/library/stringio/reopen_spec.rb index 9851c5b706..151bb58c6f 100644 --- a/spec/ruby/library/stringio/reopen_spec.rb +++ b/spec/ruby/library/stringio/reopen_spec.rb @@ -3,21 +3,21 @@ require_relative 'fixtures/classes' describe "StringIO#reopen when passed [Object, Integer]" do before :each do - @io = StringIO.new("example") + @io = StringIO.new(+"example") end it "reopens self with the passed Object in the passed mode" do - @io.reopen("reopened", IO::RDONLY) + @io.reopen(+"reopened", IO::RDONLY) @io.closed_read?.should be_false @io.closed_write?.should be_true @io.string.should == "reopened" - @io.reopen("reopened, twice", IO::WRONLY) + @io.reopen(+"reopened, twice", IO::WRONLY) @io.closed_read?.should be_true @io.closed_write?.should be_false @io.string.should == "reopened, twice" - @io.reopen("reopened, another time", IO::RDWR) + @io.reopen(+"reopened, another time", IO::RDWR) @io.closed_read?.should be_false @io.closed_write?.should be_false @io.string.should == "reopened, another time" @@ -25,7 +25,7 @@ describe "StringIO#reopen when passed [Object, Integer]" do it "tries to convert the passed Object to a String using #to_str" do obj = mock("to_str") - obj.should_receive(:to_str).and_return("to_str") + obj.should_receive(:to_str).and_return(+"to_str") @io.reopen(obj, IO::RDWR) @io.string.should == "to_str" end @@ -51,39 +51,39 @@ end describe "StringIO#reopen when passed [Object, Object]" do before :each do - @io = StringIO.new("example") + @io = StringIO.new(+"example") end it "reopens self with the passed Object in the passed mode" do - @io.reopen("reopened", "r") + @io.reopen(+"reopened", "r") @io.closed_read?.should be_false @io.closed_write?.should be_true @io.string.should == "reopened" - @io.reopen("reopened, twice", "r+") + @io.reopen(+"reopened, twice", "r+") @io.closed_read?.should be_false @io.closed_write?.should be_false @io.string.should == "reopened, twice" - @io.reopen("reopened, another", "w+") + @io.reopen(+"reopened, another", "w+") @io.closed_read?.should be_false @io.closed_write?.should be_false @io.string.should == "" - @io.reopen("reopened, another time", "r+") + @io.reopen(+"reopened, another time", "r+") @io.closed_read?.should be_false @io.closed_write?.should be_false @io.string.should == "reopened, another time" end it "truncates the passed String when opened in truncate mode" do - @io.reopen(str = "reopened", "w") + @io.reopen(str = +"reopened", "w") str.should == "" end it "tries to convert the passed Object to a String using #to_str" do obj = mock("to_str") - obj.should_receive(:to_str).and_return("to_str") + obj.should_receive(:to_str).and_return(+"to_str") @io.reopen(obj, "r") @io.string.should == "to_str" end @@ -94,20 +94,20 @@ describe "StringIO#reopen when passed [Object, Object]" do it "resets self's position to 0" do @io.read(5) - @io.reopen("reopened") + @io.reopen(+"reopened") @io.pos.should eql(0) end it "resets self's line number to 0" do @io.gets - @io.reopen("reopened") + @io.reopen(+"reopened") @io.lineno.should eql(0) end it "tries to convert the passed mode Object to an Integer using #to_str" do obj = mock("to_str") obj.should_receive(:to_str).and_return("r") - @io.reopen("reopened", obj) + @io.reopen(+"reopened", obj) @io.closed_read?.should be_false @io.closed_write?.should be_true @io.string.should == "reopened" @@ -128,13 +128,13 @@ end describe "StringIO#reopen when passed [String]" do before :each do - @io = StringIO.new("example") + @io = StringIO.new(+"example") end it "reopens self with the passed String in read-write mode" do @io.close - @io.reopen("reopened") + @io.reopen(+"reopened") @io.closed_write?.should be_false @io.closed_read?.should be_false @@ -144,20 +144,20 @@ describe "StringIO#reopen when passed [String]" do it "resets self's position to 0" do @io.read(5) - @io.reopen("reopened") + @io.reopen(+"reopened") @io.pos.should eql(0) end it "resets self's line number to 0" do @io.gets - @io.reopen("reopened") + @io.reopen(+"reopened") @io.lineno.should eql(0) end end describe "StringIO#reopen when passed [Object]" do before :each do - @io = StringIO.new("example") + @io = StringIO.new(+"example") end it "raises a TypeError when passed an Object that can't be converted to a StringIO" do @@ -172,7 +172,7 @@ describe "StringIO#reopen when passed [Object]" do it "tries to convert the passed Object to a StringIO using #to_strio" do obj = mock("to_strio") - obj.should_receive(:to_strio).and_return(StringIO.new("to_strio")) + obj.should_receive(:to_strio).and_return(StringIO.new(+"to_strio")) @io.reopen(obj) @io.string.should == "to_strio" end @@ -180,7 +180,7 @@ end describe "StringIO#reopen when passed no arguments" do before :each do - @io = StringIO.new("example\nsecond line") + @io = StringIO.new(+"example\nsecond line") end it "resets self's mode to read-write" do @@ -208,40 +208,40 @@ end # for details. describe "StringIO#reopen" do before :each do - @io = StringIO.new('hello','a') + @io = StringIO.new(+'hello','a') end # TODO: find out if this is really a bug it "reopens a stream when given a String argument" do - @io.reopen('goodbye').should == @io + @io.reopen(+'goodbye').should == @io @io.string.should == 'goodbye' @io << 'x' @io.string.should == 'xoodbye' end it "reopens a stream in append mode when flagged as such" do - @io.reopen('goodbye', 'a').should == @io + @io.reopen(+'goodbye', 'a').should == @io @io.string.should == 'goodbye' @io << 'x' @io.string.should == 'goodbyex' end it "reopens and truncate when reopened in write mode" do - @io.reopen('goodbye', 'wb').should == @io + @io.reopen(+'goodbye', 'wb').should == @io @io.string.should == '' @io << 'x' @io.string.should == 'x' end it "truncates the given string, not a copy" do - str = 'goodbye' + str = +'goodbye' @io.reopen(str, 'w') @io.string.should == '' str.should == '' end it "does not truncate the content even when the StringIO argument is in the truncate mode" do - orig_io = StringIO.new("Original StringIO", IO::RDWR|IO::TRUNC) + orig_io = StringIO.new(+"Original StringIO", IO::RDWR|IO::TRUNC) orig_io.write("BLAH") # make sure the content is not empty @io.reopen(orig_io) diff --git a/spec/ruby/library/stringio/shared/codepoints.rb b/spec/ruby/library/stringio/shared/codepoints.rb index 9d84aa4919..25333bb0fd 100644 --- a/spec/ruby/library/stringio/shared/codepoints.rb +++ b/spec/ruby/library/stringio/shared/codepoints.rb @@ -27,7 +27,7 @@ describe :stringio_codepoints, shared: true do @io.close_read -> { @enum.to_a }.should raise_error(IOError) - io = StringIO.new("xyz", "w") + io = StringIO.new(+"xyz", "w") -> { io.send(@method).to_a }.should raise_error(IOError) end diff --git a/spec/ruby/library/stringio/shared/each.rb b/spec/ruby/library/stringio/shared/each.rb index acd8d22c14..e0dd3f9b8f 100644 --- a/spec/ruby/library/stringio/shared/each.rb +++ b/spec/ruby/library/stringio/shared/each.rb @@ -107,7 +107,7 @@ end describe :stringio_each_not_readable, shared: true do it "raises an IOError" do - io = StringIO.new("a b c d e", "w") + io = StringIO.new(+"a b c d e", "w") -> { io.send(@method) { |b| b } }.should raise_error(IOError) io = StringIO.new("a b c d e") diff --git a/spec/ruby/library/stringio/shared/each_byte.rb b/spec/ruby/library/stringio/shared/each_byte.rb index 56734ff99d..b51fa38f2f 100644 --- a/spec/ruby/library/stringio/shared/each_byte.rb +++ b/spec/ruby/library/stringio/shared/each_byte.rb @@ -38,7 +38,7 @@ end describe :stringio_each_byte_not_readable, shared: true do it "raises an IOError" do - io = StringIO.new("xyz", "w") + io = StringIO.new(+"xyz", "w") -> { io.send(@method) { |b| b } }.should raise_error(IOError) io = StringIO.new("xyz") diff --git a/spec/ruby/library/stringio/shared/each_char.rb b/spec/ruby/library/stringio/shared/each_char.rb index bcdac53282..197237c1c8 100644 --- a/spec/ruby/library/stringio/shared/each_char.rb +++ b/spec/ruby/library/stringio/shared/each_char.rb @@ -26,7 +26,7 @@ end describe :stringio_each_char_not_readable, shared: true do it "raises an IOError" do - io = StringIO.new("xyz", "w") + io = StringIO.new(+"xyz", "w") -> { io.send(@method) { |b| b } }.should raise_error(IOError) io = StringIO.new("xyz") diff --git a/spec/ruby/library/stringio/shared/getc.rb b/spec/ruby/library/stringio/shared/getc.rb index 6318bcc30f..ba65040bce 100644 --- a/spec/ruby/library/stringio/shared/getc.rb +++ b/spec/ruby/library/stringio/shared/getc.rb @@ -33,7 +33,7 @@ end describe :stringio_getc_not_readable, shared: true do it "raises an IOError" do - io = StringIO.new("xyz", "w") + io = StringIO.new(+"xyz", "w") -> { io.send(@method) }.should raise_error(IOError) io = StringIO.new("xyz") diff --git a/spec/ruby/library/stringio/shared/isatty.rb b/spec/ruby/library/stringio/shared/isatty.rb index 3da5999953..c9e7ee7321 100644 --- a/spec/ruby/library/stringio/shared/isatty.rb +++ b/spec/ruby/library/stringio/shared/isatty.rb @@ -1,5 +1,5 @@ describe :stringio_isatty, shared: true do it "returns false" do - StringIO.new('tty').send(@method).should be_false + StringIO.new("tty").send(@method).should be_false end end diff --git a/spec/ruby/library/stringio/shared/read.rb b/spec/ruby/library/stringio/shared/read.rb index 252a85d89d..e3840786d9 100644 --- a/spec/ruby/library/stringio/shared/read.rb +++ b/spec/ruby/library/stringio/shared/read.rb @@ -5,19 +5,19 @@ describe :stringio_read, shared: true do it "returns the passed buffer String" do # Note: Rubinius bug: - # @io.send(@method, 7, buffer = "").should equal(buffer) - ret = @io.send(@method, 7, buffer = "") + # @io.send(@method, 7, buffer = +"").should equal(buffer) + ret = @io.send(@method, 7, buffer = +"") ret.should equal(buffer) end it "reads length bytes and writes them to the buffer String" do - @io.send(@method, 7, buffer = "") + @io.send(@method, 7, buffer = +"") buffer.should == "example" end it "tries to convert the passed buffer Object to a String using #to_str" do obj = mock("to_str") - obj.should_receive(:to_str).and_return(buffer = "") + obj.should_receive(:to_str).and_return(buffer = +"") @io.send(@method, 7, obj) buffer.should == "example" @@ -75,7 +75,7 @@ end describe :stringio_read_no_arguments, shared: true do before :each do - @io = StringIO.new("example") + @io = StringIO.new(+"example") end it "reads the whole content starting from the current position" do @@ -117,7 +117,7 @@ end describe :stringio_read_not_readable, shared: true do it "raises an IOError" do - io = StringIO.new("test", "w") + io = StringIO.new(+"test", "w") -> { io.send(@method) }.should raise_error(IOError) io = StringIO.new("test") diff --git a/spec/ruby/library/stringio/shared/readchar.rb b/spec/ruby/library/stringio/shared/readchar.rb index 4248e75420..72d7446c36 100644 --- a/spec/ruby/library/stringio/shared/readchar.rb +++ b/spec/ruby/library/stringio/shared/readchar.rb @@ -19,7 +19,7 @@ end describe :stringio_readchar_not_readable, shared: true do it "raises an IOError" do - io = StringIO.new("a b c d e", "w") + io = StringIO.new(+"a b c d e", "w") -> { io.send(@method) }.should raise_error(IOError) io = StringIO.new("a b c d e") diff --git a/spec/ruby/library/stringio/shared/write.rb b/spec/ruby/library/stringio/shared/write.rb index aa67bb73c7..404e08b93d 100644 --- a/spec/ruby/library/stringio/shared/write.rb +++ b/spec/ruby/library/stringio/shared/write.rb @@ -1,6 +1,6 @@ describe :stringio_write, shared: true do before :each do - @io = StringIO.new('12345') + @io = StringIO.new(+'12345') end it "tries to convert the passed Object to a String using #to_s" do @@ -13,7 +13,7 @@ end describe :stringio_write_string, shared: true do before :each do - @io = StringIO.new('12345') + @io = StringIO.new(+'12345') end # TODO: RDoc says that #write appends at the current position. @@ -106,10 +106,10 @@ end describe :stringio_write_not_writable, shared: true do it "raises an IOError" do - io = StringIO.new("test", "r") + io = StringIO.new(+"test", "r") -> { io.send(@method, "test") }.should raise_error(IOError) - io = StringIO.new("test") + io = StringIO.new(+"test") io.close_write -> { io.send(@method, "test") }.should raise_error(IOError) end @@ -117,7 +117,7 @@ end describe :stringio_write_append, shared: true do before :each do - @io = StringIO.new("example", "a") + @io = StringIO.new(+"example", "a") end it "appends the passed argument to the end of self" do diff --git a/spec/ruby/library/stringio/truncate_spec.rb b/spec/ruby/library/stringio/truncate_spec.rb index e8d7f1a15d..592ca5a6e1 100644 --- a/spec/ruby/library/stringio/truncate_spec.rb +++ b/spec/ruby/library/stringio/truncate_spec.rb @@ -3,7 +3,7 @@ require "stringio" describe "StringIO#truncate when passed [length]" do before :each do - @io = StringIO.new('123456789') + @io = StringIO.new(+'123456789') end it "returns an Integer" do @@ -16,7 +16,7 @@ describe "StringIO#truncate when passed [length]" do end it "does not create a copy of the underlying string" do - io = StringIO.new(str = "123456789") + io = StringIO.new(str = +"123456789") io.truncate(4) io.string.should equal(str) end @@ -52,10 +52,10 @@ end describe "StringIO#truncate when self is not writable" do it "raises an IOError" do - io = StringIO.new("test", "r") + io = StringIO.new(+"test", "r") -> { io.truncate(2) }.should raise_error(IOError) - io = StringIO.new("test") + io = StringIO.new(+"test") io.close_write -> { io.truncate(2) }.should raise_error(IOError) end diff --git a/spec/ruby/library/stringio/ungetc_spec.rb b/spec/ruby/library/stringio/ungetc_spec.rb index 91ef2100a1..bceafa79ff 100644 --- a/spec/ruby/library/stringio/ungetc_spec.rb +++ b/spec/ruby/library/stringio/ungetc_spec.rb @@ -3,7 +3,7 @@ require_relative 'fixtures/classes' describe "StringIO#ungetc when passed [char]" do before :each do - @io = StringIO.new('1234') + @io = StringIO.new(+'1234') end it "writes the passed char before the current position" do @@ -45,11 +45,11 @@ end describe "StringIO#ungetc when self is not readable" do it "raises an IOError" do - io = StringIO.new("test", "w") + io = StringIO.new(+"test", "w") io.pos = 1 -> { io.ungetc(?A) }.should raise_error(IOError) - io = StringIO.new("test") + io = StringIO.new(+"test") io.pos = 1 io.close_read -> { io.ungetc(?A) }.should raise_error(IOError) @@ -60,11 +60,11 @@ end # # describe "StringIO#ungetc when self is not writable" do # it "raises an IOError" do -# io = StringIO.new("test", "r") +# io = StringIO.new(+"test", "r") # io.pos = 1 # lambda { io.ungetc(?A) }.should raise_error(IOError) # -# io = StringIO.new("test") +# io = StringIO.new(+"test") # io.pos = 1 # io.close_write # lambda { io.ungetc(?A) }.should raise_error(IOError) diff --git a/spec/ruby/library/stringio/write_nonblock_spec.rb b/spec/ruby/library/stringio/write_nonblock_spec.rb index a457b97667..b48ef6698a 100644 --- a/spec/ruby/library/stringio/write_nonblock_spec.rb +++ b/spec/ruby/library/stringio/write_nonblock_spec.rb @@ -10,7 +10,7 @@ describe "StringIO#write_nonblock when passed [String]" do it_behaves_like :stringio_write_string, :write_nonblock it "accepts :exception option" do - io = StringIO.new("12345", "a") + io = StringIO.new(+"12345", "a") io.write_nonblock("67890", exception: true) io.string.should == "1234567890" end diff --git a/spec/ruby/library/stringscanner/getch_spec.rb b/spec/ruby/library/stringscanner/getch_spec.rb index a6be0d4221..449c20ad3b 100644 --- a/spec/ruby/library/stringscanner/getch_spec.rb +++ b/spec/ruby/library/stringscanner/getch_spec.rb @@ -13,7 +13,7 @@ describe "StringScanner#getch" do it "is multi-byte character sensitive" do # Japanese hiragana "A" in EUC-JP - src = "\244\242".force_encoding("euc-jp") + src = "\244\242".dup.force_encoding("euc-jp") s = StringScanner.new(src) s.getch.should == src diff --git a/spec/ruby/library/stringscanner/shared/concat.rb b/spec/ruby/library/stringscanner/shared/concat.rb index cb884a5c01..1dbae11f7c 100644 --- a/spec/ruby/library/stringscanner/shared/concat.rb +++ b/spec/ruby/library/stringscanner/shared/concat.rb @@ -1,6 +1,6 @@ describe :strscan_concat, shared: true do it "concatenates the given argument to self and returns self" do - s = StringScanner.new("hello ") + s = StringScanner.new(+"hello ") s.send(@method, 'world').should == s s.string.should == "hello world" s.eos?.should be_false diff --git a/spec/ruby/library/stringscanner/string_spec.rb b/spec/ruby/library/stringscanner/string_spec.rb index 28e2f0ed37..cba6bd51dd 100644 --- a/spec/ruby/library/stringscanner/string_spec.rb +++ b/spec/ruby/library/stringscanner/string_spec.rb @@ -3,7 +3,7 @@ require 'strscan' describe "StringScanner#string" do before :each do - @string = "This is a test" + @string = +"This is a test" @s = StringScanner.new(@string) end diff --git a/spec/ruby/library/zlib/deflate/deflate_spec.rb b/spec/ruby/library/zlib/deflate/deflate_spec.rb index 50a563ef6f..e16e6ad0ef 100644 --- a/spec/ruby/library/zlib/deflate/deflate_spec.rb +++ b/spec/ruby/library/zlib/deflate/deflate_spec.rb @@ -23,7 +23,7 @@ describe "Zlib::Deflate.deflate" do it "deflates chunked data" do random_generator = Random.new(0) - deflated = '' + deflated = +'' Zlib::Deflate.deflate(random_generator.bytes(20000)) do |chunk| deflated << chunk @@ -70,7 +70,7 @@ describe "Zlib::Deflate#deflate" do before :each do @deflator = Zlib::Deflate.new @random_generator = Random.new(0) - @original = '' + @original = +'' @chunks = [] end diff --git a/spec/ruby/library/zlib/deflate/params_spec.rb b/spec/ruby/library/zlib/deflate/params_spec.rb index 0b1cca8c8a..0242653528 100644 --- a/spec/ruby/library/zlib/deflate/params_spec.rb +++ b/spec/ruby/library/zlib/deflate/params_spec.rb @@ -3,7 +3,7 @@ require 'zlib' describe "Zlib::Deflate#params" do it "changes the deflate parameters" do - data = 'abcdefghijklm' + data = +'abcdefghijklm' d = Zlib::Deflate.new Zlib::NO_COMPRESSION, Zlib::MAX_WBITS, Zlib::DEF_MEM_LEVEL, Zlib::DEFAULT_STRATEGY diff --git a/spec/ruby/library/zlib/inflate/inflate_spec.rb b/spec/ruby/library/zlib/inflate/inflate_spec.rb index 79b72bf91c..b308a4ba67 100644 --- a/spec/ruby/library/zlib/inflate/inflate_spec.rb +++ b/spec/ruby/library/zlib/inflate/inflate_spec.rb @@ -72,7 +72,7 @@ describe "Zlib::Inflate.inflate" do data = [120, 156, 75, 203, 207, 7, 0, 2, 130, 1, 69].pack('C*') z = Zlib::Inflate.new # add bytes, one by one - result = "" + result = +"" data.each_byte { |d| result << z.inflate(d.chr)} result << z.finish result.should == "foo" @@ -82,7 +82,7 @@ describe "Zlib::Inflate.inflate" do data = [120, 156, 75, 203, 207, 7, 0, 2, 130, 1, 69].pack('C*')[0,5] z = Zlib::Inflate.new # add bytes, one by one, but not all - result = "" + result = +"" data.each_byte { |d| result << z.inflate(d.chr)} -> { result << z.finish }.should raise_error(Zlib::BufError) end @@ -90,7 +90,7 @@ describe "Zlib::Inflate.inflate" do it "properly handles excessive data, byte-by-byte" do main_data = [120, 156, 75, 203, 207, 7, 0, 2, 130, 1, 69].pack('C*') data = main_data * 2 - result = "" + result = +"" z = Zlib::Inflate.new # add bytes, one by one @@ -105,7 +105,7 @@ describe "Zlib::Inflate.inflate" do it "properly handles excessive data, in one go" do main_data = [120, 156, 75, 203, 207, 7, 0, 2, 130, 1, 69].pack('C*') data = main_data * 2 - result = "" + result = +"" z = Zlib::Inflate.new result << z.inflate(data) |