|
5 | 5 | describe "String#start_with?" do |
6 | 6 | it "returns true only if beginning match" do |
7 | 7 | s = "hello" |
8 | | - s.start_with?('h').should be_true |
9 | | - s.start_with?('hel').should be_true |
10 | | - s.start_with?('el').should be_false |
| 8 | + s.should.start_with?('h') |
| 9 | + s.should.start_with?('hel') |
| 10 | + s.should_not.start_with?('el') |
11 | 11 | end |
12 | 12 |
|
13 | 13 | it "returns true only if any beginning match" do |
14 | | - "hello".start_with?('x', 'y', 'he', 'z').should be_true |
| 14 | + "hello".should.start_with?('x', 'y', 'he', 'z') |
15 | 15 | end |
16 | 16 |
|
17 | 17 | it "returns true if the search string is empty" do |
18 | | - "hello".start_with?("").should be_true |
19 | | - "".start_with?("").should be_true |
| 18 | + "hello".should.start_with?("") |
| 19 | + "".should.start_with?("") |
20 | 20 | end |
21 | 21 |
|
22 | 22 | it "converts its argument using :to_str" do |
23 | 23 | s = "hello" |
24 | 24 | find = mock('h') |
25 | 25 | find.should_receive(:to_str).and_return("h") |
26 | | - s.start_with?(find).should be_true |
| 26 | + s.should.start_with?(find) |
27 | 27 | end |
28 | 28 |
|
29 | 29 | it "ignores arguments not convertible to string" do |
30 | | - "hello".start_with?().should be_false |
| 30 | + "hello".should_not.start_with?() |
31 | 31 | -> { "hello".start_with?(1) }.should raise_error(TypeError) |
32 | 32 | -> { "hello".start_with?(["h"]) }.should raise_error(TypeError) |
33 | 33 | -> { "hello".start_with?(1, nil, "h") }.should raise_error(TypeError) |
|
36 | 36 | it "uses only the needed arguments" do |
37 | 37 | find = mock('h') |
38 | 38 | find.should_not_receive(:to_str) |
39 | | - "hello".start_with?("h",find).should be_true |
| 39 | + "hello".should.start_with?("h",find) |
40 | 40 | end |
41 | 41 |
|
42 | 42 | it "works for multibyte strings" do |
43 | | - "céréale".start_with?("cér").should be_true |
| 43 | + "céréale".should.start_with?("cér") |
44 | 44 | end |
45 | 45 |
|
46 | 46 | ruby_version_is "2.5" do |
47 | 47 | it "supports regexps" do |
48 | 48 | regexp = /[h1]/ |
49 | | - "hello".start_with?(regexp).should be_true |
50 | | - "1337".start_with?(regexp).should be_true |
51 | | - "foxes are 1337".start_with?(regexp).should be_false |
52 | | - "chunky\n12bacon".start_with?(/12/).should be_false |
| 49 | + "hello".should.start_with?(regexp) |
| 50 | + "1337".should.start_with?(regexp) |
| 51 | + "foxes are 1337".should_not.start_with?(regexp) |
| 52 | + "chunky\n12bacon".should_not.start_with?(/12/) |
53 | 53 | end |
54 | 54 |
|
55 | 55 | it "supports regexps with ^ and $ modifiers" do |
56 | 56 | regexp1 = /^\d{2}/ |
57 | 57 | regexp2 = /\d{2}$/ |
58 | | - "12test".start_with?(regexp1).should be_true |
59 | | - "test12".start_with?(regexp1).should be_false |
60 | | - "12test".start_with?(regexp2).should be_false |
61 | | - "test12".start_with?(regexp2).should be_false |
| 58 | + "12test".should.start_with?(regexp1) |
| 59 | + "test12".should_not.start_with?(regexp1) |
| 60 | + "12test".should_not.start_with?(regexp2) |
| 61 | + "test12".should_not.start_with?(regexp2) |
62 | 62 | end |
63 | 63 |
|
64 | 64 | it "sets Regexp.last_match if it returns true" do |
|
0 commit comments