Sha256: 1ca87bfc791675c664a4654efd905b88c7521ac4ec6ebdfcd14309761c62728f
Contents?: true
Size: 928 Bytes
Versions: 3
Compression:
Stored size: 928 Bytes
Contents
require 'spec_helper' require 'dentaku/ast/functions/avg' require 'dentaku' describe 'Dentaku::AST::Function::Avg' do it 'returns the average of an array of Numeric values' do result = Dentaku('AVG(1, x, 1.8)', x: 2.3) expect(result).to eq 1.7 end it 'returns the average of a single entry array of a Numeric value' do result = Dentaku('AVG(x)', x: 2.3) expect(result).to eq 2.3 end it 'returns the average even if a String is passed' do result = Dentaku('AVG(1, x, 1.8)', x: '2.3') expect(result).to eq 1.7 end it 'returns the average even if an array is passed' do result = Dentaku('AVG(1, x, 2.3)', x: [4, 5]) expect(result).to eq 3.075 end context 'checking errors' do let(:calculator) { Dentaku::Calculator.new } it 'raises an error if no arguments are passed' do expect { calculator.evaluate!('AVG()') }.to raise_error(ArgumentError) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dentaku-3.3.0 | spec/ast/avg_spec.rb |
dentaku-3.2.1 | spec/ast/avg_spec.rb |
dentaku-3.2.0 | spec/ast/avg_spec.rb |