Skip to content

Commit a3c52de

Browse files
committed
Use the new should.predicate style for #start_with specs
1 parent e69a14c commit a3c52de

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

core/string/start_with_spec.rb

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@
55
describe "String#start_with?" do
66
it "returns true only if beginning match" do
77
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')
1111
end
1212

1313
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')
1515
end
1616

1717
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?("")
2020
end
2121

2222
it "converts its argument using :to_str" do
2323
s = "hello"
2424
find = mock('h')
2525
find.should_receive(:to_str).and_return("h")
26-
s.start_with?(find).should be_true
26+
s.should.start_with?(find)
2727
end
2828

2929
it "ignores arguments not convertible to string" do
30-
"hello".start_with?().should be_false
30+
"hello".should_not.start_with?()
3131
-> { "hello".start_with?(1) }.should raise_error(TypeError)
3232
-> { "hello".start_with?(["h"]) }.should raise_error(TypeError)
3333
-> { "hello".start_with?(1, nil, "h") }.should raise_error(TypeError)
@@ -36,29 +36,29 @@
3636
it "uses only the needed arguments" do
3737
find = mock('h')
3838
find.should_not_receive(:to_str)
39-
"hello".start_with?("h",find).should be_true
39+
"hello".should.start_with?("h",find)
4040
end
4141

4242
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")
4444
end
4545

4646
ruby_version_is "2.5" do
4747
it "supports regexps" do
4848
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/)
5353
end
5454

5555
it "supports regexps with ^ and $ modifiers" do
5656
regexp1 = /^\d{2}/
5757
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)
6262
end
6363

6464
it "sets Regexp.last_match if it returns true" do

library/tmpdir/dir/mktmpdir_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
Dir.mktmpdir do |path|
4040
@tmpdir = path
4141
called = true
42-
path.start_with?(@real_tmp_root).should be_true
42+
path.should.start_with?(@real_tmp_root)
4343
end
4444
called.should be_true
4545
end

0 commit comments

Comments
 (0)