diff options
Diffstat (limited to 'spec/ruby/core/io/puts_spec.rb')
| -rw-r--r-- | spec/ruby/core/io/puts_spec.rb | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/spec/ruby/core/io/puts_spec.rb b/spec/ruby/core/io/puts_spec.rb index 51240eed73..df526ea56a 100644 --- a/spec/ruby/core/io/puts_spec.rb +++ b/spec/ruby/core/io/puts_spec.rb @@ -1,12 +1,12 @@ -require File.expand_path('../../../spec_helper', __FILE__) -require File.expand_path('../fixtures/classes', __FILE__) +require_relative '../../spec_helper' +require_relative 'fixtures/classes' describe "IO#puts" do before :each do @before_separator = $/ @name = tmp("io_puts.txt") @io = new_io @name - ScratchPad.record "" + ScratchPad.record(+"") def @io.write(str) ScratchPad << str end @@ -16,7 +16,7 @@ describe "IO#puts" do ScratchPad.clear @io.close if @io rm_r @name - $/ = @before_separator + suppress_warning {$/ = @before_separator} end it "writes just a newline when given no args" do @@ -25,7 +25,7 @@ describe "IO#puts" do end it "writes just a newline when given just a newline" do - lambda { $stdout.puts "\n" }.should output_to_fd("\n", STDOUT) + -> { $stdout.puts "\n" }.should output_to_fd("\n", $stdout) end it "writes empty string with a newline when given nil as an arg" do @@ -33,7 +33,7 @@ describe "IO#puts" do ScratchPad.recorded.should == "\n" end - it "writes empty string with a newline when when given nil as multiple args" do + it "writes empty string with a newline when given nil as multiple args" do @io.puts(nil, nil).should == nil ScratchPad.recorded.should == "\n\n" end @@ -105,37 +105,35 @@ describe "IO#puts" do end it "ignores the $/ separator global" do - $/ = ":" + suppress_warning {$/ = ":"} @io.puts(5).should == nil ScratchPad.recorded.should == "5\n" end it "raises IOError on closed stream" do - lambda { IOSpecs.closed_io.puts("stuff") }.should raise_error(IOError) + -> { IOSpecs.closed_io.puts("stuff") }.should.raise(IOError) end - with_feature :encoding do - it "writes crlf when IO is opened with newline: :crlf" do - File.open(@name, 'wt', newline: :crlf) do |file| - file.puts - end - File.binread(@name).should == "\r\n" + it "writes crlf when IO is opened with newline: :crlf" do + File.open(@name, 'wt', newline: :crlf) do |file| + file.puts end + File.binread(@name).should == "\r\n" + end - it "writes cr when IO is opened with newline: :cr" do - File.open(@name, 'wt', newline: :cr) do |file| - file.puts - end - File.binread(@name).should == "\r" + it "writes cr when IO is opened with newline: :cr" do + File.open(@name, 'wt', newline: :cr) do |file| + file.puts end + File.binread(@name).should == "\r" + end - platform_is_not :windows do # https://bugs.ruby-lang.org/issues/12436 - it "writes lf when IO is opened with newline: :lf" do - File.open(@name, 'wt', newline: :lf) do |file| - file.puts - end - File.binread(@name).should == "\n" + platform_is_not :windows do # https://bugs.ruby-lang.org/issues/12436 + it "writes lf when IO is opened with newline: :lf" do + File.open(@name, 'wt', newline: :lf) do |file| + file.puts end + File.binread(@name).should == "\n" end end end |
