Sha256: 2cd4a4f146ddc9a07f597e0b357cb24fc8e6179d58d389504f24c5dfda991b09

Contents?: true

Size: 545 Bytes

Versions: 1

Compression:

Stored size: 545 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe Addy do
  before(:all) do
    class ::Object
      include ::Addy
    end
  end
  
  describe "#sum" do
    context "when no block is given" do
      it "should calculate the sum of the values in the range" do
        sum(1..5).should == 15
      end
    end
    
    context "when a block is given" do
      it "should calculate the sum of the results of the block for each value in the range" do
        sum(1..3) {|i| i**i }.should == 32
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
addy-1.0.0 spec/addy_spec.rb