spec/enumerable_spec.rb in visionmedia-rext-0.1.0 vs spec/enumerable_spec.rb in visionmedia-rext-0.2.1
- old
+ new
@@ -1,25 +1,21 @@
require 'rext/enumerable'
describe Enumerable do
-
- describe "#every" do
- it "should map a method call" do
- list = %w( cookies icecream sugar )
- list.every.length.should == [7, 8 ,5]
+ describe "helpers" do
+ describe "#includes_all?" do
+ it "should return true when all arguments are present" do
+ [1,2,3].includes_all?(1,2).should be_true
+ end
+
+ it "should return true when not all arguments are present" do
+ [1,1,3,3,4].includes_all?(1,3,6).should be_false
+ [1,1,3,3,4].includes_all?(6,3,1).should be_false
+ end
end
- it "should allow mapping shortcuts using a block" do
- people = []
- people << mock('Person', :name => 'TJ')
- people << mock('Person', :name => 'Scott')
- people.every { name.length }.should == [2, 5]
- end
- end
-
- describe "helpers" do
describe "#group_by" do
before :each do
@enum = 'foo', :bar, 1, 2, 3
@results = {
String => ['foo'],
@@ -38,8 +34,21 @@
it "should group by method call" do
@enum.group_by.class.should == @results
end
end
+
+ describe "#every" do
+ it "should map a method call" do
+ list = %w( cookies icecream sugar )
+ list.every.length.should == [7, 8 ,5]
+ end
+
+ it "should allow mapping shortcuts using a block" do
+ people = []
+ people << mock('Person', :name => 'TJ')
+ people << mock('Person', :name => 'Scott')
+ people.every { name.length }.should == [2, 5]
+ end
+ end
end
-
end
\ No newline at end of file