Sha256: 25cf0e2ae7cf6f4474eebf28598e0b271e197e98b835ccd714a5368f2456c9cb

Contents?: true

Size: 1.37 KB

Versions: 38

Compression:

Stored size: 1.37 KB

Contents

require "spec_helper"

describe Float do

  describe ".evolve" do

    context "when provided a string" do

      context "when the string is a number" do

        context "when the string is an integer" do

          it "returns a float" do
            expect(described_class.evolve("1")).to eq(1.0)
          end
        end

        context "when the string is a float" do

          it "converts it to a float" do
            expect(described_class.evolve("2.23")).to eq(2.23)
          end
        end
      end

      context "when the string is not a number" do

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

    context "when provided an array of strings" do

      it "returns the array of floats" do
        expect(described_class.evolve([ "2.23" ])).to eq([ 2.23 ])
      end
    end

    context "when provided a number" do

      context "when the number is an integer" do

        it "returns a float" do
          expect(described_class.evolve(1)).to eq(1.0)
        end
      end

      context "when the number is a float" do

        it "returns the float" do
          expect(described_class.evolve(2.23)).to eq(2.23)
        end
      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

38 entries across 36 versions & 2 rubygems

Version Path
mongoid-7.0.13 spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-7.0.12 spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-6.4.8 spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-7.0.11 spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-7.0.10 spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-6.4.7 spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-6.4.5 spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-7.0.8 spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-7.0.7 spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-7.0.6 spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-7.0.5 spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-7.0.4 spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-6.4.4 spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-7.0.3 spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-6.4.2 spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-7.0.2 spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-7.0.1 spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-6.4.1 spec/mongoid/criteria/queryable/extensions/float_spec.rb
tdiary-5.0.8 vendor/bundle/gems/mongoid-6.4.0/spec/mongoid/criteria/queryable/extensions/float_spec.rb
mongoid-7.0.0 spec/mongoid/criteria/queryable/extensions/float_spec.rb