Sha256: 9feadfb574bf84f657648183ce016c246034603d2e8b591d5a56f68bfab6a2f1

Contents?: true

Size: 1.17 KB

Versions: 24

Compression:

Stored size: 1.17 KB

Contents

require "spec_helper"

describe BigDecimal do

  describe ".evolve" do

    context "when provided a big decimal" do

      let(:big_decimal) do
        BigDecimal.new("123456.789")
      end

      it "returns the decimal as a string" do
        expect(described_class.evolve(big_decimal)).to eq(big_decimal.to_s)
      end
    end

    context "when provided a non big decimal" do

      it "returns the object as a string" do
        expect(described_class.evolve("testing")).to eq("testing")
      end
    end

    context "when provided an array of big decimals" do

      let(:bd_one) do
        BigDecimal.new("123456.789")
      end

      let(:bd_two) do
        BigDecimal.new("123333.789")
      end

      let(:array) do
        [ bd_one, bd_two ]
      end

      let(:evolved) do
        described_class.evolve(array)
      end

      it "returns the array as strings" do
        expect(evolved).to eq([ bd_one.to_s, bd_two.to_s ])
      end

      it "does not evolve in place" do
        expect(evolved).to_not equal(array)
      end
    end

    context "when provided nil" do

      it "returns nil" do
        expect(described_class.evolve(nil)).to be_nil
      end
    end
  end
end

Version data entries

24 entries across 22 versions & 2 rubygems

Version Path
mongoid-6.4.2 spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
mongoid-7.0.2 spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
mongoid-7.0.1 spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
mongoid-6.4.1 spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
tdiary-5.0.8 vendor/bundle/gems/mongoid-6.4.0/spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
mongoid-7.0.0 spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
mongoid-6.4.0 spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
mongoid-6.3.0 spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
mongoid-6.2.1 spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
mongoid-7.0.0.beta spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/mongoid-6.1.0/spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
tdiary-5.0.5 vendor/bundle/gems/mongoid-6.2.0/spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
tdiary-5.0.5 vendor/bundle/gems/mongoid-6.1.0/spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
mongoid-6.2.0 spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
mongoid-6.1.1 spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
tdiary-5.0.4 vendor/bundle/gems/mongoid-6.1.0/spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
mongoid-6.1.0 spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
mongoid-6.1.0.rc0 spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
mongoid-6.0.3 spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb
mongoid-6.0.2 spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb