Sha256: a36933e37b25eb93515ebc7835967cbd9056afd4798e86d549bc13bae1ee4c1b

Contents?: true

Size: 739 Bytes

Versions: 5

Compression:

Stored size: 739 Bytes

Contents

require 'spec_helper'
require 'dentaku/ast/functions/rounddown'
require 'dentaku'

describe 'Dentaku::AST::Function::Round' do
  it 'returns the rounded value' do
    result = Dentaku('ROUNDDOWN(1.8)')
    expect(result).to eq 1
  end

  it 'returns the rounded value to the given precision' do
    result = Dentaku('ROUNDDOWN(x, y)', x: 1.8453, y: 3)
    expect(result).to eq 1.845
  end

  it 'returns the rounded value to the given precision, also with strings' do
    result = Dentaku('ROUNDDOWN(x, y)', x: '1.8453', y: '3')
    expect(result).to eq 1.845
  end

  it 'returns the rounded value to the given precision, also with nil' do
    result = Dentaku('ROUNDDOWN(x, y)', x: '1.8453', y: nil)
    expect(result).to eq 1
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dentaku-3.3.0 spec/ast/rounddown_spec.rb
dentaku-3.2.1 spec/ast/rounddown_spec.rb
dentaku-3.2.0 spec/ast/rounddown_spec.rb
dentaku-3.1.0 spec/ast/rounddown_spec.rb
dentaku-3.0.0 spec/ast/rounddown_spec.rb