forked from ruby/spec
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,29 @@ | ||
require File.expand_path('../../../spec_helper', __FILE__) | ||
|
||
describe "Enumerable#one?" do | ||
it "needs to be reviewed for spec completeness" | ||
ruby_version_is '1.8.7' do | ||
describe "when block is given" do | ||
it "returns true if block returns true once" do | ||
["ant", "bear", "cat"].one?{ |word| word.length == 4 }.should be_true | ||
end | ||
|
||
it "returns false if block evaluation are true more than once" do | ||
["ant", "bear"].one? { |word| word.length > 4 }.should be_false | ||
end | ||
end | ||
|
||
describe "when block isn't given" do | ||
it "returns true if only one element is true" do | ||
[false, nil, true].one?.should be_true | ||
end | ||
|
||
it "returns false if two elements are true" do | ||
[false, true, nil, true].one?.should be_false | ||
end | ||
|
||
it "returns false if two elements aren't false or nil" do | ||
[false, true, nil, 99].one?.should be_false | ||
end | ||
end | ||
end | ||
end |