Sha256: 70ba7d03e216746c1c4a95fdc3a120dc4fb05ea177e270b38ebf4996c006fecb
Contents?: true
Size: 822 Bytes
Versions: 3
Compression:
Stored size: 822 Bytes
Contents
require 'spec_helper' describe Math do describe '.average' do context 'when passing an array of values' do let(:values) { [0, 1, 2, 3, 4] } it 'returns the average' do expect(described_class.average(values)).to eq(2) end context 'when average is not a round number' do let(:values) { [0, 1, 2, 3] } it 'returns the average' do expect(described_class.average(values)).to eq(1.5) end end end context 'when passing a hash' do let(:values) do { 0 => 1, 1 => 2, 2 => 3, 3 => 4, 4 => 5 } end it 'uses the keys as values and the values as weights (frequency)' do expect(described_class.average(values)).to eq(8 / 3.0) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
darthjee-core_ext-1.5.6 | spec/lib/math_spec.rb |
darthjee-core_ext-1.5.5 | spec/lib/math_spec.rb |
darthjee-core_ext-1.5.4 | spec/lib/math_spec.rb |