Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed specs to ensure #truthy? returns only true or false.

The specs don't read as nicely now, but they're more correct. Priorities.
  • Loading branch information...
commit c53516cacb333be6d1f7f56d94177f9fdddccc26 1 parent 9599948
@ymendel authored
Showing with 17 additions and 17 deletions.
  1. +17 −17 spec/truthy_spec.rb
View
34 spec/truthy_spec.rb
@@ -3,71 +3,71 @@
describe 'truthiness' do
specify 'false should not be truthy' do
- false.should_not be_truthy
+ false.truthy?.should == false
end
specify 'nil should not be truthy' do
- nil.should_not be_truthy
+ nil.truthy?.should == false
end
specify 'true should be truthy' do
- true.should be_truthy
+ true.truthy?.should == true
end
specify 'a string should be truthy' do
- 'this is a string'.should be_truthy
+ 'this is a string'.truthy?.should == true
end
specify 'even an empty string should be truthy' do
- ''.should be_truthy
+ ''.truthy?.should == true
end
specify 'a string containing nothing but whitespace should still be truthy' do
- ' '.should be_truthy
+ ' '.truthy?.should == true
end
specify 'a number should be truthy' do
- 1.should be_truthy
+ 1.truthy?.should == true
end
specify 'zero is truthy' do
- 0.should be_truthy
+ 0.truthy?.should == true
end
specify 'infinity is totally truthy' do
- (1.0/0.0).should be_truthy
+ (1.0/0.0).truthy?.should == true
end
specify 'even a negative number is truthy' do
- -5.should be_truthy
+ -5.truthy?.should == true
end
specify 'an array should be truthy' do
- ['a', 1].should be_truthy
+ ['a', 1].truthy?.should == true
end
specify 'an empty array is truthy' do
- [].should be_truthy
+ [].truthy?.should == true
end
specify 'an array containing only non-truthy elements: still truthy' do
- [nil, false].should be_truthy
+ [nil, false].truthy?.should == true
end
specify 'a hash is truthy' do
- { 'a' => 1 }.should be_truthy
+ { 'a' => 1 }.truthy?.should == true
end
specify 'an empty hash is truthy' do
- {}.should be_truthy
+ {}.truthy?.should == true
end
specify 'an hash containing only non-truthy things: still truthy' do
- { nil => false }.should be_truthy
+ { nil => false }.truthy?.should == true
end
specify 'an object is truthy' do
- Object.new.should be_truthy
+ Object.new.truthy?.should == true
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.