Sha256: dd0d8bcad317eff890af6c46720a4d51b28fc3d0b14780f4224f0f48fbdfe6e0

Contents?: true

Size: 640 Bytes

Versions: 9

Compression:

Stored size: 640 Bytes

Contents

require "spec_helper"
require "cascade/complex_fields/currency"

describe Cascade::ComplexFields::Currency do
  def described_class
    Cascade::ComplexFields::Currency
  end

  subject { described_class.new }

  describe "parse" do
    it "return nil if input string isn't number" do
      assert_nil subject.call("0o")
    end

    it "prepare string to use it as bignum" do
      assert_kind_of BigDecimal, subject.call("1 123 123 45")
      assert_kind_of BigDecimal, subject.call("1 123, 123 45")
    end

    it "return zero if field is empty" do
      assert_nil subject.call("")
      assert_nil subject.call(nil)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cascade-rb-0.2.3 spec/lib/complex_fields/currency_spec.rb
cascade-rb-0.2.2 spec/lib/complex_fields/currency_spec.rb
cascade-rb-0.2.1 spec/lib/complex_fields/currency_spec.rb
cascade-rb-0.2.0 spec/lib/complex_fields/currency_spec.rb
cascade-rb-0.1.5 spec/lib/complex_fields/currency_spec.rb
cascade-rb-0.1.4 spec/lib/complex_fields/currency_spec.rb
cascade-rb-0.1.2 spec/lib/complex_fields/currency_spec.rb
cascade-rb-0.1.1 spec/lib/complex_fields/currency_spec.rb
cascade-rb-0.1.0 spec/lib/complex_fields/currency_spec.rb