From 8c5b60eb22d6d661e87992a65d54e3a5bc0aeed4 Mon Sep 17 00:00:00 2001 From: eregon Date: Sat, 28 Oct 2017 15:15:48 +0000 Subject: Update to ruby/spec@a6b8805 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- spec/ruby/library/stringio/each_line_spec.rb | 6 ++++++ spec/ruby/library/stringio/each_spec.rb | 6 ++++++ spec/ruby/library/stringio/getc_spec.rb | 2 +- spec/ruby/library/stringio/getch_spec.rb | 2 +- spec/ruby/library/stringio/gets_spec.rb | 13 +++++++++++-- spec/ruby/library/stringio/lines_spec.rb | 6 ++++++ spec/ruby/library/stringio/readline_spec.rb | 13 +++++++++++-- spec/ruby/library/stringio/readlines_spec.rb | 9 +++++++++ spec/ruby/library/stringio/shared/each.rb | 9 +++++++++ 9 files changed, 60 insertions(+), 6 deletions(-) (limited to 'spec/ruby/library/stringio') diff --git a/spec/ruby/library/stringio/each_line_spec.rb b/spec/ruby/library/stringio/each_line_spec.rb index e4deb9b3e9..d770c18e67 100644 --- a/spec/ruby/library/stringio/each_line_spec.rb +++ b/spec/ruby/library/stringio/each_line_spec.rb @@ -13,3 +13,9 @@ end describe "StringIO#each_line when self is not readable" do it_behaves_like :stringio_each_not_readable, :each_line end + +ruby_version_is "2.4" do + describe "StringIO#each_line when passed chomp" do + it_behaves_like :stringio_each_chomp, :each_line + end +end diff --git a/spec/ruby/library/stringio/each_spec.rb b/spec/ruby/library/stringio/each_spec.rb index 07ad070192..cebaa345d8 100644 --- a/spec/ruby/library/stringio/each_spec.rb +++ b/spec/ruby/library/stringio/each_spec.rb @@ -13,3 +13,9 @@ end describe "StringIO#each when self is not readable" do it_behaves_like :stringio_each_not_readable, :each end + +ruby_version_is "2.4" do + describe "StringIO#each when passed chomp" do + it_behaves_like :stringio_each_chomp, :each + end +end diff --git a/spec/ruby/library/stringio/getc_spec.rb b/spec/ruby/library/stringio/getc_spec.rb index f7e98d2a33..804502d8ba 100644 --- a/spec/ruby/library/stringio/getc_spec.rb +++ b/spec/ruby/library/stringio/getc_spec.rb @@ -5,7 +5,7 @@ require File.expand_path('../shared/getc', __FILE__) describe "StringIO#getc" do it_behaves_like :stringio_getc, :getc - it "returns the charactor at the current position" do + it "returns the character at the current position" do io = StringIO.new("example") io.send(@method).should == ?e diff --git a/spec/ruby/library/stringio/getch_spec.rb b/spec/ruby/library/stringio/getch_spec.rb index c7fdfe9080..d6f652424e 100644 --- a/spec/ruby/library/stringio/getch_spec.rb +++ b/spec/ruby/library/stringio/getch_spec.rb @@ -9,7 +9,7 @@ describe "StringIO#getch" do it_behaves_like :stringio_getc, :getch - it "returns the charactor at the current position" do + it "returns the character at the current position" do io = StringIO.new("example") io.send(@method).should == ?e diff --git a/spec/ruby/library/stringio/gets_spec.rb b/spec/ruby/library/stringio/gets_spec.rb index 307f564a6e..f94448688b 100644 --- a/spec/ruby/library/stringio/gets_spec.rb +++ b/spec/ruby/library/stringio/gets_spec.rb @@ -6,7 +6,7 @@ describe "StringIO#gets when passed [separator]" do @io = StringIO.new("this>is>an>example") end - it "returns the data read till the next occurence of the passed separator" do + it "returns the data read till the next occurrence of the passed separator" do @io.gets(">").should == "this>" @io.gets(">").should == "is>" @io.gets(">").should == "an>" @@ -72,7 +72,7 @@ describe "StringIO#gets when passed no argument" do @io = StringIO.new("this is\nan example\nfor StringIO#gets") end - it "returns the data read till the next occurence of $/ or till eof" do + it "returns the data read till the next occurrence of $/ or till eof" do @io.gets.should == "this is\n" begin @@ -236,3 +236,12 @@ describe "StringIO#gets when in write-only mode" do lambda { io.gets }.should raise_error(IOError) end end + +ruby_version_is "2.4" do + describe "StringIO#gets when passed [chomp]" do + it "returns the data read without a trailing newline character" do + io = StringIO.new("this>is>an>example\n") + io.gets(chomp: true).should == "this>is>an>example" + end + end +end \ No newline at end of file diff --git a/spec/ruby/library/stringio/lines_spec.rb b/spec/ruby/library/stringio/lines_spec.rb index 550b25549e..c3af802073 100644 --- a/spec/ruby/library/stringio/lines_spec.rb +++ b/spec/ruby/library/stringio/lines_spec.rb @@ -13,3 +13,9 @@ end describe "StringIO#lines when self is not readable" do it_behaves_like :stringio_each_not_readable, :lines end + +ruby_version_is "2.4" do + describe "StringIO#lines when passed chomp" do + it_behaves_like :stringio_each_chomp, :lines + end +end diff --git a/spec/ruby/library/stringio/readline_spec.rb b/spec/ruby/library/stringio/readline_spec.rb index 90890e3ad1..1deb52c492 100644 --- a/spec/ruby/library/stringio/readline_spec.rb +++ b/spec/ruby/library/stringio/readline_spec.rb @@ -7,7 +7,7 @@ describe "StringIO#readline when passed [separator]" do @io = StringIO.new("this>is>an>example") end - it "returns the data read till the next occurence of the passed separator" do + it "returns the data read till the next occurrence of the passed separator" do @io.readline(">").should == "this>" @io.readline(">").should == "is>" @io.readline(">").should == "an>" @@ -60,7 +60,7 @@ describe "StringIO#readline when passed no argument" do @io = StringIO.new("this is\nan example\nfor StringIO#readline") end - it "returns the data read till the next occurence of $/ or till eof" do + it "returns the data read till the next occurrence of $/ or till eof" do @io.readline.should == "this is\n" begin @@ -120,3 +120,12 @@ describe "StringIO#readline when in write-only mode" do lambda { io.readline }.should raise_error(IOError) end end + +ruby_version_is "2.4" do + describe "StringIO#readline when passed [chomp]" do + it "returns the data read without a trailing newline character" do + io = StringIO.new("this>is>an>example\n") + io.readline(chomp: true).should == "this>is>an>example" + end + end +end diff --git a/spec/ruby/library/stringio/readlines_spec.rb b/spec/ruby/library/stringio/readlines_spec.rb index 215a6cbb2a..11217d1e59 100644 --- a/spec/ruby/library/stringio/readlines_spec.rb +++ b/spec/ruby/library/stringio/readlines_spec.rb @@ -90,3 +90,12 @@ describe "StringIO#readlines when in write-only mode" do lambda { io.readlines }.should raise_error(IOError) end end + +ruby_version_is "2.4" do + describe "StringIO#readlines when passed [chomp]" do + it "returns the data read without a trailing newline character" do + io = StringIO.new("this>is\nan>example\r\n") + io.readlines(chomp: true).should == ["this>is", "an>example"] + end + end +end diff --git a/spec/ruby/library/stringio/shared/each.rb b/spec/ruby/library/stringio/shared/each.rb index 0fde23634e..55ed27c1c7 100644 --- a/spec/ruby/library/stringio/shared/each.rb +++ b/spec/ruby/library/stringio/shared/each.rb @@ -103,3 +103,12 @@ describe :stringio_each_not_readable, shared: true do lambda { io.send(@method) { |b| b } }.should raise_error(IOError) end end + +describe :stringio_each_chomp, shared: true do + it "yields each line with removed newline characters to the passed block" do + seen = [] + io = StringIO.new("a b \rc d e\n1 2 3 4 5\r\nthe end") + io.send(@method, chomp: true) {|s| seen << s } + seen.should == ["a b \rc d e", "1 2 3 4 5", "the end"] + end +end -- cgit v1.2.3