diff options
Diffstat (limited to 'spec/ruby/core/string')
-rw-r--r-- | spec/ruby/core/string/dump_spec.rb | 4 | ||||
-rw-r--r-- | spec/ruby/core/string/end_with_spec.rb | 21 | ||||
-rw-r--r-- | spec/ruby/core/string/start_with_spec.rb | 36 |
3 files changed, 30 insertions, 31 deletions
diff --git a/spec/ruby/core/string/dump_spec.rb b/spec/ruby/core/string/dump_spec.rb index aa91114893..95eb9aa874 100644 --- a/spec/ruby/core/string/dump_spec.rb +++ b/spec/ruby/core/string/dump_spec.rb @@ -388,8 +388,8 @@ describe "String#dump" do end it "includes .force_encoding(name) if the encoding isn't ASCII compatible" do - "\u{876}".encode('utf-16be').dump.end_with?(".force_encoding(\"UTF-16BE\")").should be_true - "\u{876}".encode('utf-16le').dump.end_with?(".force_encoding(\"UTF-16LE\")").should be_true + "\u{876}".encode('utf-16be').dump.should.end_with?(".force_encoding(\"UTF-16BE\")") + "\u{876}".encode('utf-16le').dump.should.end_with?(".force_encoding(\"UTF-16LE\")") end it "keeps origin encoding" do diff --git a/spec/ruby/core/string/end_with_spec.rb b/spec/ruby/core/string/end_with_spec.rb index b7a04fdefe..9ced0ca3d2 100644 --- a/spec/ruby/core/string/end_with_spec.rb +++ b/spec/ruby/core/string/end_with_spec.rb @@ -5,33 +5,33 @@ require_relative 'fixtures/classes' describe "String#end_with?" do it "returns true only if ends match" do s = "hello" - s.end_with?('o').should be_true - s.end_with?('llo').should be_true + s.should.end_with?('o') + s.should.end_with?('llo') end it 'returns false if the end does not match' do s = 'hello' - s.end_with?('ll').should be_false + s.should_not.end_with?('ll') end it "returns true if the search string is empty" do - "hello".end_with?("").should be_true - "".end_with?("").should be_true + "hello".should.end_with?("") + "".should.end_with?("") end it "returns true only if any ending match" do - "hello".end_with?('x', 'y', 'llo', 'z').should be_true + "hello".should.end_with?('x', 'y', 'llo', 'z') end it "converts its argument using :to_str" do s = "hello" find = mock('o') find.should_receive(:to_str).and_return("o") - s.end_with?(find).should be_true + s.should.end_with?(find) end it "ignores arguments not convertible to string" do - "hello".end_with?().should be_false + "hello".should_not.end_with?() -> { "hello".end_with?(1) }.should raise_error(TypeError) -> { "hello".end_with?(["o"]) }.should raise_error(TypeError) -> { "hello".end_with?(1, nil, "o") }.should raise_error(TypeError) @@ -40,11 +40,11 @@ describe "String#end_with?" do it "uses only the needed arguments" do find = mock('h') find.should_not_receive(:to_str) - "hello".end_with?("o",find).should be_true + "hello".should.end_with?("o",find) end it "works for multibyte strings" do - "céréale".end_with?("réale").should be_true + "céréale".should.end_with?("réale") end it "raises an Encoding::CompatibilityError if the encodings are incompatible" do @@ -53,5 +53,4 @@ describe "String#end_with?" do "あれ".end_with?(pat) end.should raise_error(Encoding::CompatibilityError) end - end diff --git a/spec/ruby/core/string/start_with_spec.rb b/spec/ruby/core/string/start_with_spec.rb index f66ec55266..1000db180c 100644 --- a/spec/ruby/core/string/start_with_spec.rb +++ b/spec/ruby/core/string/start_with_spec.rb @@ -5,29 +5,29 @@ require_relative 'fixtures/classes' describe "String#start_with?" do it "returns true only if beginning match" do s = "hello" - s.start_with?('h').should be_true - s.start_with?('hel').should be_true - s.start_with?('el').should be_false + s.should.start_with?('h') + s.should.start_with?('hel') + s.should_not.start_with?('el') end it "returns true only if any beginning match" do - "hello".start_with?('x', 'y', 'he', 'z').should be_true + "hello".should.start_with?('x', 'y', 'he', 'z') end it "returns true if the search string is empty" do - "hello".start_with?("").should be_true - "".start_with?("").should be_true + "hello".should.start_with?("") + "".should.start_with?("") end it "converts its argument using :to_str" do s = "hello" find = mock('h') find.should_receive(:to_str).and_return("h") - s.start_with?(find).should be_true + s.should.start_with?(find) end it "ignores arguments not convertible to string" do - "hello".start_with?().should be_false + "hello".should_not.start_with?() -> { "hello".start_with?(1) }.should raise_error(TypeError) -> { "hello".start_with?(["h"]) }.should raise_error(TypeError) -> { "hello".start_with?(1, nil, "h") }.should raise_error(TypeError) @@ -36,29 +36,29 @@ describe "String#start_with?" do it "uses only the needed arguments" do find = mock('h') find.should_not_receive(:to_str) - "hello".start_with?("h",find).should be_true + "hello".should.start_with?("h",find) end it "works for multibyte strings" do - "céréale".start_with?("cér").should be_true + "céréale".should.start_with?("cér") end ruby_version_is "2.5" do it "supports regexps" do regexp = /[h1]/ - "hello".start_with?(regexp).should be_true - "1337".start_with?(regexp).should be_true - "foxes are 1337".start_with?(regexp).should be_false - "chunky\n12bacon".start_with?(/12/).should be_false + "hello".should.start_with?(regexp) + "1337".should.start_with?(regexp) + "foxes are 1337".should_not.start_with?(regexp) + "chunky\n12bacon".should_not.start_with?(/12/) end it "supports regexps with ^ and $ modifiers" do regexp1 = /^\d{2}/ regexp2 = /\d{2}$/ - "12test".start_with?(regexp1).should be_true - "test12".start_with?(regexp1).should be_false - "12test".start_with?(regexp2).should be_false - "test12".start_with?(regexp2).should be_false + "12test".should.start_with?(regexp1) + "test12".should_not.start_with?(regexp1) + "12test".should_not.start_with?(regexp2) + "test12".should_not.start_with?(regexp2) end it "sets Regexp.last_match if it returns true" do |