diff options
Diffstat (limited to 'spec/ruby/core/string')
-rw-r--r-- | spec/ruby/core/string/chomp_spec.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/string/shared/each_line.rb | 13 |
2 files changed, 17 insertions, 0 deletions
diff --git a/spec/ruby/core/string/chomp_spec.rb b/spec/ruby/core/string/chomp_spec.rb index 6fa8d7c6c5..3c20141ee7 100644 --- a/spec/ruby/core/string/chomp_spec.rb +++ b/spec/ruby/core/string/chomp_spec.rb @@ -158,6 +158,10 @@ describe "String#chomp" do it "does not taint the result when the argument is tainted" do "abc".chomp("abc".taint).tainted?.should be_false end + + it "returns an empty String when the argument equals self" do + "abc".chomp("abc").should == "" + end end end diff --git a/spec/ruby/core/string/shared/each_line.rb b/spec/ruby/core/string/shared/each_line.rb index 19cf5e6d78..066b0c1040 100644 --- a/spec/ruby/core/string/shared/each_line.rb +++ b/spec/ruby/core/string/shared/each_line.rb @@ -27,6 +27,19 @@ describe :string_each_line, shared: true do c.should == ["hello\n", "\n", "\n", "world"] end + it "splits strings containing multibyte characters" do + s = <<~EOS + foo + 🤡🤡🤡🤡🤡🤡🤡 + bar + baz + EOS + + b = [] + s.send(@method) { |part| b << part } + b.should == ["foo\n", "🤡🤡🤡🤡🤡🤡🤡\n", "bar\n", "baz\n"] + end + it "taints substrings that are passed to the block if self is tainted" do "one\ntwo\r\nthree".taint.send(@method) { |s| s.tainted?.should == true } |