Sha256: 7030e83dd3845dd6e1eaaaab0b438d7e52a9e51a0c92c87be6e4c4a02d802ff3

Contents?: true

Size: 729 Bytes

Versions: 5

Compression:

Stored size: 729 Bytes

Contents

require 'spec_helper'
require 'dentaku/ast/functions/roundup'
require 'dentaku'

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

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

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

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