Updated RubySpec submodule to 9f66d0b1.
[rbx.git] / spec / core / enumerable / count_spec.rb
blob560ecbd71681836fd487b609d5f6289551cf3665
1 require File.dirname(__FILE__) + '/../../spec_helper'
3 describe "Enumerable#count" do
4   # Assuming array doesn't override count.  If this changes, use
5   # EachDefiner from core/enumerable/fixtures/classes.rb
7   it "requires an argument or a block" do
8     lambda { [1, 2, 3, 4].count }.should raise_error
9   end
11   it "counts nils if given nil as an argument" do
12     [nil, nil, nil, false].count(nil).should == 3
13   end
15   it "accepts an argument for comparison using ==" do
16     ary = [1, 2, 4, 2]
17     ary.count(2).should == 2
18   end
20   it "uses a block for comparison" do
21     ary = [1, 2, 4, 2]
22     ary.count{|x|x%2==0}.should == 3
23   end
24 end