Sha256: 71183278d78eea1b84eece5fd3274952aed1494990a1fc507929738cd07097eb

Contents?: true

Size: 578 Bytes

Versions: 2

Compression:

Stored size: 578 Bytes

Contents

require File.expand_path('../spec_helper', File.dirname(__FILE__))
require 'gorillib/array/average'

describe Array do
  describe '#average' do
    context 'on non-float array element' do
      it 'raises error' do
        expect { [0.0, :b, 1.0].average }.should raise_error(ArgumentError)
      end
    end

    context 'with empty' do
      it 'returns nil' do
        [].average.should be_nil
      end
    end

    context 'given a numerical array' do
      it 'returns the average of the elements' do
        (1..10).to_a.average.should == 5.5
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gorillib-0.4.1pre spec/array/average_spec.rb
gorillib-0.1.11 spec/array/average_spec.rb