Sha256: 923f8ed15e3a9eaf60fe4b1c1085c90efdd20d56cc7bf3d320ebe2518e62caeb

Contents?: true

Size: 733 Bytes

Versions: 4

Compression:

Stored size: 733 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

4 entries across 4 versions & 1 rubygems

Version Path
dentaku-3.3.4 spec/ast/roundup_spec.rb
dentaku-3.3.3 spec/ast/roundup_spec.rb
dentaku-3.3.2 spec/ast/roundup_spec.rb
dentaku-3.3.1 spec/ast/roundup_spec.rb