summaryrefslogtreecommitdiff
path: root/spec/ruby/core/string/shared/each_line.rb
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-28 19:50:06 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-28 19:50:06 +0000
commit4fbb9aa3cb6c31ec128bfb31f59efa66d66adba4 (patch)
tree84a654b260261fe172f2584f60b3ba93e59f841d /spec/ruby/core/string/shared/each_line.rb
parentb864bd05bff2a61d55b08deb92e969f9fa55e07c (diff)
Update to ruby/spec@6f38a82
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63293 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/string/shared/each_line.rb')
-rw-r--r--spec/ruby/core/string/shared/each_line.rb23
1 files changed, 19 insertions, 4 deletions
diff --git a/spec/ruby/core/string/shared/each_line.rb b/spec/ruby/core/string/shared/each_line.rb
index dee741e270..19cf5e6d78 100644
--- a/spec/ruby/core/string/shared/each_line.rb
+++ b/spec/ruby/core/string/shared/each_line.rb
@@ -51,9 +51,8 @@ describe :string_each_line, shared: true do
end
end
-quarantine! do # Currently fails on Travis
ruby_version_is '2.5' do
- it "yields paragraphs (broken by 2 or more successive newlines) when passed ''" do
+ it "yields paragraphs (broken by 2 or more successive newlines) when passed '' and replaces multiple newlines with only two ones" do
a = []
"hello\nworld\n\n\nand\nuniverse\n\n\n\n\n".send(@method, '') { |s| a << s }
a.should == ["hello\nworld\n\n", "and\nuniverse\n\n"]
@@ -63,7 +62,6 @@ quarantine! do # Currently fails on Travis
a.should == ["hello\nworld\n\n", "and\nuniverse\n\n", "dog"]
end
end
-end
describe "uses $/" do
before :each do
@@ -136,7 +134,7 @@ end
ruby_version_is '2.4' do
context "when `chomp` keyword argument is passed" do
- it "removes new line characters" do
+ it "removes new line characters when separator is not specified" do
a = []
"hello \nworld\n".send(@method, chomp: true) { |s| a << s }
a.should == ["hello ", "world"]
@@ -145,6 +143,23 @@ end
"hello \r\nworld\r\n".send(@method, chomp: true) { |s| a << s }
a.should == ["hello ", "world"]
end
+
+ it "removes only specified separator" do
+ a = []
+ "hello world".send(@method, ' ', chomp: true) { |s| a << s }
+ a.should == ["hello", "world"]
+ end
+
+ # https://bugs.ruby-lang.org/issues/14257
+ it "ignores new line characters when separator is specified" do
+ a = []
+ "hello\n world\n".send(@method, ' ', chomp: true) { |s| a << s }
+ a.should == ["hello\n", "world\n"]
+
+ a = []
+ "hello\r\n world\r\n".send(@method, ' ', chomp: true) { |s| a << s }
+ a.should == ["hello\r\n", "world\r\n"]
+ end
end
end
end