Sha256: c1b1487141df0b6e3498edc8e32504ce8ffd70198f957f69ee7f05cfc76dde95

Contents?: true

Size: 788 Bytes

Versions: 1

Compression:

Stored size: 788 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Aggregate::Mean, '.call' do
  subject do
    values.reduce(default) do |accumulator, value|
      object.call(accumulator, value)
    end
  end

  let(:default) { object.default  }
  let(:object)  { described_class }

  context 'when the value is 0' do
    let(:values) { [0] }

    it 'returns the expected count and mean of the values' do
      should == [1, 0.0]
    end
  end

  context 'when the values are not nil' do
    let(:values) { [-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6] }

    it 'returns the expected count and mean of the values' do
      should == [13, 0.0]
    end
  end

  context 'when the values are nil' do
    let(:values) { [nil] }

    it 'returns the default' do
      should be(default)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axiom-0.1.1 spec/unit/axiom/aggregate/mean/class_methods/call_spec.rb