public
Description: Various quizes and tricks that we use in our WNYRuby.com group for mutual self-education
Homepage: http://wnyruby.com/
Clone URL: git://github.com/kcbaird/wnyruby.com-homework.git
100644 32 lines (24 sloc) 0.567 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env ruby
# looper_spec.rb
 
if (__FILE__ == $0)
  require %q[rubygems]
  require %q[spec]
  require %q[looper]
 
  describe Looper do
    before(:each) do
      @looper = Looper.new(1,2,3)
    end
  
    it "should detect" do
      @looper.detect {|i| i > 1 }.should == 2
    end
 
    it "should select" do
      @looper.select {|i| i % 2 == 1 }.should == [1,3]
    end
 
    it "should reject" do
      @looper.reject {|i| i % 2 == 1 }.should == [2]
    end
 
    it "should collect" do
      @looper.collect {|i| i * 2 }.should == [2,4,6]
    end
  end
 
end