File: sum_spec.rb

package info (click to toggle)
ruby-powerpack 0.0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 320 kB
  • ctags: 53
  • sloc: ruby: 727; makefile: 2
file content (15 lines) | stat: -rw-r--r-- 337 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require 'spec_helper'

describe 'Enumerable#sum' do
  it 'sums up the numbers of an enum' do
    expect((1..3).sum).to eq(6)
  end

  it 'returns nil when invoked on an empty collection' do
    expect([].sum).to be_nil
  end

  it 'returns default value when invoked on an empty collection' do
    expect([].sum(0)).to be_zero
  end
end