Skip to content
This repository was archived by the owner on Apr 17, 2018. It is now read-only.

Commit 7207804

Browse files
committed
Changed usage of be_true and be_false to be(true) and be(false) in specs
* This is due to a somewhat recent change in rspec, where be_true now passes if the value is anything other than nil or false. Previously it would only pass if the value was a TrueClass instance; but now it's based on whether the object would return true in boolean context. Likewise be_false now passes if the value is nil or false, and previously it would only pass if the value was a FalseClass instance. I'm not a big fan of methods that are expected to return boolean returning anything other than those values. It's not enough that it return something that evaluates to true or false in boolean context.
1 parent b182171 commit 7207804

File tree

6 files changed

+53
-53
lines changed

6 files changed

+53
-53
lines changed

spec/hash_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,12 @@
141141

142142
it "should typecast a true boolean" do
143143
xml = "<tag type='boolean'>true</tag>"
144-
Hash.from_xml(xml)['tag'].should be_true
144+
Hash.from_xml(xml)['tag'].should be(true)
145145
end
146146

147147
it "should typecast a false boolean" do
148148
["false"].each do |w|
149-
Hash.from_xml("<tag type='boolean'>#{w}</tag>")['tag'].should be_false
149+
Hash.from_xml("<tag type='boolean'>#{w}</tag>")['tag'].should be(false)
150150
end
151151
end
152152

spec/lazy_array_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ def should_return_copy
5454

5555
def should_return_true
5656
it 'should return true' do
57-
action.should be_true
57+
action.should be(true)
5858
end
5959
end
6060

6161
def should_return_false
6262
it 'should return false' do
63-
action.should be_false
63+
action.should be(false)
6464
end
6565
end
6666

@@ -151,7 +151,7 @@ def action
151151
subject { @lazy_array }
152152

153153
it 'should be an Enumerable' do
154-
(Enumerable === subject).should be_true
154+
(Enumerable === subject).should be(true)
155155
end
156156

157157
describe 'when frozen', state do
@@ -1948,7 +1948,7 @@ def lazy_spec
19481948
end
19491949

19501950
it 'should delegate to the Array' do
1951-
subject.lazy_spec.should be_true
1951+
subject.lazy_spec.should be(true)
19521952
end
19531953
end
19541954

spec/mash_spec.rb

+27-27
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class AwesomeHash < Hash
1414
it 'converts all keys into strings when param is a Hash' do
1515
mash = Mash.new(@hash)
1616

17-
mash.keys.any? { |key| key.is_a?(Symbol) }.should be_false
17+
mash.keys.any? { |key| key.is_a?(Symbol) }.should be(false)
1818
end
1919

2020
it 'converts all pure Hash values into Mashes if param is a Hash' do
@@ -53,7 +53,7 @@ class AwesomeHash < Hash
5353
mash = Mash.new(@hash)
5454
mash.update("starry" => "night")
5555

56-
mash.keys.any? { |key| key.is_a?(Symbol) }.should be_false
56+
mash.keys.any? { |key| key.is_a?(Symbol) }.should be(false)
5757
end
5858

5959
it 'converts all Hash values into Mashes if param is a Hash' do
@@ -71,7 +71,7 @@ class AwesomeHash < Hash
7171
mash = Mash.new(@hash)
7272
mash[:hash] = { "starry" => "night" }
7373

74-
mash.keys.any? { |key| key.is_a?(Symbol) }.should be_false
74+
mash.keys.any? { |key| key.is_a?(Symbol) }.should be(false)
7575
end
7676

7777
it 'converts all Hash value into Mash' do
@@ -90,36 +90,36 @@ class AwesomeHash < Hash
9090
end
9191

9292
it 'converts key before lookup' do
93-
@mash.key?("mash").should be_true
94-
@mash.key?(:mash).should be_true
93+
@mash.key?("mash").should be(true)
94+
@mash.key?(:mash).should be(true)
9595

96-
@mash.key?("hash").should be_true
97-
@mash.key?(:hash).should be_true
96+
@mash.key?("hash").should be(true)
97+
@mash.key?(:hash).should be(true)
9898

99-
@mash.key?(:rainclouds).should be_false
100-
@mash.key?("rainclouds").should be_false
99+
@mash.key?(:rainclouds).should be(false)
100+
@mash.key?("rainclouds").should be(false)
101101
end
102102

103103
it 'is aliased as include?' do
104-
@mash.include?("mash").should be_true
105-
@mash.include?(:mash).should be_true
104+
@mash.include?("mash").should be(true)
105+
@mash.include?(:mash).should be(true)
106106

107-
@mash.include?("hash").should be_true
108-
@mash.include?(:hash).should be_true
107+
@mash.include?("hash").should be(true)
108+
@mash.include?(:hash).should be(true)
109109

110-
@mash.include?(:rainclouds).should be_false
111-
@mash.include?("rainclouds").should be_false
110+
@mash.include?(:rainclouds).should be(false)
111+
@mash.include?("rainclouds").should be(false)
112112
end
113113

114114
it 'is aliased as member?' do
115-
@mash.member?("mash").should be_true
116-
@mash.member?(:mash).should be_true
115+
@mash.member?("mash").should be(true)
116+
@mash.member?(:mash).should be(true)
117117

118-
@mash.member?("hash").should be_true
119-
@mash.member?(:hash).should be_true
118+
@mash.member?("hash").should be(true)
119+
@mash.member?(:hash).should be(true)
120120

121-
@mash.member?(:rainclouds).should be_false
122-
@mash.member?("rainclouds").should be_false
121+
@mash.member?(:rainclouds).should be(false)
122+
@mash.member?("rainclouds").should be(false)
123123
end
124124
end # describe "#key?"
125125

@@ -198,14 +198,14 @@ class AwesomeHash < Hash
198198
mash = Mash.new(@hash)
199199

200200
mash.delete(:hash)
201-
mash.key?("hash").should be_false
201+
mash.key?("hash").should be(false)
202202
end
203203

204204
it 'works with String keys as well' do
205205
mash = Mash.new(@hash)
206206

207207
mash.delete("mash")
208-
mash.key?("mash").should be_false
208+
mash.key?("mash").should be(false)
209209
end
210210
end
211211

@@ -216,22 +216,22 @@ class AwesomeHash < Hash
216216
mash = Mash.new(@hash)
217217

218218
hashless_mash = mash.except(:hash)
219-
hashless_mash.key?("hash").should be_false
219+
hashless_mash.key?("hash").should be(false)
220220
end
221221

222222
it "works with String keys as well" do
223223
mash = Mash.new(@hash)
224224

225225
mashless_mash = mash.except("mash")
226-
mashless_mash.key?("mash").should be_false
226+
mashless_mash.key?("mash").should be(false)
227227
end
228228

229229
it "works with multiple keys" do
230230
mash = Mash.new(@hash)
231231

232232
mashless = mash.except("hash", :mash)
233-
mashless.key?(:hash).should be_false
234-
mashless.key?("mash").should be_false
233+
mashless.key?(:hash).should be(false)
234+
mashless.key?("mash").should be(false)
235235
end
236236

237237
it "should return a mash" do

spec/object_spec.rb

+15-15
Original file line numberDiff line numberDiff line change
@@ -62,35 +62,35 @@ class Oi
6262

6363
describe "#quacks_like?" do
6464
it 'returns true if duck is a Symbol and receiver responds to it' do
65-
SymbolicDuck.new.quacks_like?(:quack).should be_true
65+
SymbolicDuck.new.quacks_like?(:quack).should be(true)
6666
end
6767

6868
it 'returns false if duck is a Symbol and receiver DOES NOT respond to it' do
69-
SymbolicDuck.new.quacks_like?(:wtf).should be_false
69+
SymbolicDuck.new.quacks_like?(:wtf).should be(false)
7070
end
7171

7272
it 'returns true if duck is a class and receiver is its instance' do
7373
receiver = ClassyDuck.new
74-
receiver.quacks_like?(ClassyDuck).should be_true
74+
receiver.quacks_like?(ClassyDuck).should be(true)
7575
end
7676

7777
it 'returns false if duck is a class and receiver IS NOT its instance' do
7878
receiver = ClassyDuck.new
79-
receiver.quacks_like?(SymbolicDuck).should be_false
79+
receiver.quacks_like?(SymbolicDuck).should be(false)
8080
end
8181

8282
it 'returns true if duck is an array and at least one of its members quacks like this duck' do
8383
receiver = ClassyDuck.new
8484
ary = [ClassyDuck, SymbolicDuck]
8585

86-
receiver.quacks_like?(ary).should be_true
86+
receiver.quacks_like?(ary).should be(true)
8787
end
8888

8989
it 'returns false if duck is an array and none of its members quacks like this duck' do
9090
receiver = ClassyDuck.new
9191
ary = [SymbolicDuck.new, SymbolicDuck]
9292

93-
receiver.quacks_like?(ary).should be_false
93+
receiver.quacks_like?(ary).should be(false)
9494
end
9595
end
9696

@@ -99,16 +99,16 @@ class Oi
9999
@ary = [1, 2, 3]
100100
@set = Set.new([2, 3, 5])
101101

102-
1.in?(@ary).should be_true
103-
2.in?(@ary).should be_true
104-
3.in?(@ary).should be_true
105-
4.in?(@ary).should be_false
102+
1.in?(@ary).should be(true)
103+
2.in?(@ary).should be(true)
104+
3.in?(@ary).should be(true)
105+
4.in?(@ary).should be(false)
106106

107-
1.in?(@set).should be_false
108-
2.in?(@set).should be_true
109-
3.in?(@set).should be_true
110-
4.in?(@set).should be_false
111-
5.in?(@set).should be_true
107+
1.in?(@set).should be(false)
108+
2.in?(@set).should be(true)
109+
3.in?(@set).should be(true)
110+
4.in?(@set).should be(false)
111+
5.in?(@set).should be(true)
112112
end
113113
end
114114
end

spec/pooling_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def dispose
156156
bob.release
157157
Extlib.exiting = true
158158
sleep(0.1)
159-
Extlib::Pooling.scavenger?.should be_false
159+
Extlib::Pooling.scavenger?.should be(false)
160160
end
161161

162162
it "should be able to detach an instance from the pool" do
@@ -431,7 +431,7 @@ def dispose
431431
# it "acquires new instances from pool" do
432432
# @instance_one = DisposableResource.new
433433
#
434-
# DisposableResource.pool.acquired?(@instance_one).should be_true
434+
# DisposableResource.pool.acquired?(@instance_one).should be(true)
435435
# end
436436
#
437437
# it "flushed existing pool on re-initialization" do
@@ -483,10 +483,10 @@ def dispose
483483
#
484484
# it "returns true when object's last aquisition time is greater than limit" do
485485
# @t1 = DisposableResource.new
486-
# DisposableResource.pool.time_to_release?(@t1).should be_false
486+
# DisposableResource.pool.time_to_release?(@t1).should be(false)
487487
#
488488
# sleep 3
489-
# DisposableResource.pool.time_to_release?(@t1).should be_true
489+
# DisposableResource.pool.time_to_release?(@t1).should be(true)
490490
# end
491491
# end
492492
#

spec/simple_set_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
it 'sets true mark on the key' do
2727
@s << "Fun"
28-
@s["Fun"].should be_true
28+
@s["Fun"].should be(true)
2929
end
3030
end
3131

0 commit comments

Comments
 (0)