Sha256: bc3ffd048fc4f1bed601494226f939d1aad8070c1bd9d7dfc0ac4a484656ce9e

Contents?: true

Size: 743 Bytes

Versions: 4

Compression:

Stored size: 743 Bytes

Contents

require 'spec_helper'
require 'dentaku/ast/functions/round'
require 'dentaku'

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

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

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

  it 'returns the rounded down value to the given precision, also with nil' do
    result = Dentaku('ROUND(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/round_spec.rb
dentaku-3.3.3 spec/ast/round_spec.rb
dentaku-3.3.2 spec/ast/round_spec.rb
dentaku-3.3.1 spec/ast/round_spec.rb