Sha256: 5ebf3230e6be7678a0a72b45357571f3ec2b7d1c39a0db7b807ee9a749eeec01

Contents?: true

Size: 717 Bytes

Versions: 5

Compression:

Stored size: 717 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Granite::Form::Types::BigDecimal do
  describe 'typecasting' do
    include_context 'type setup', 'BigDecimal'

    specify { expect(typecast('hello')).to be_nil }
    specify { expect(typecast('123hello')).to be_nil }
    specify { expect(typecast('123')).to eq(BigDecimal('123.0')) }
    specify { expect(typecast('123.')).to be_nil }
    specify { expect(typecast('123.5')).to eq(BigDecimal('123.5')) }
    specify { expect(typecast(123)).to eq(BigDecimal('123.0')) }
    specify { expect(typecast(123.5)).to eq(BigDecimal('123.5')) }
    specify { expect(typecast(nil)).to be_nil }
    specify { expect(typecast([123.5])).to be_nil }
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
granite-form-0.6.0 spec/granite/form/types/big_decimal_spec.rb
granite-form-0.5.0 spec/granite/form/types/big_decimal_spec.rb
granite-form-0.4.0 spec/granite/form/types/big_decimal_spec.rb
granite-form-0.3.0 spec/granite/form/types/big_decimal_spec.rb
granite-form-0.2.0 spec/granite/form/types/big_decimal_spec.rb