Sha256: feb4b2f7b71ab920527d0c1831d78bb72e77e5a91ce16f01bb30c0e0636b036c

Contents?: true

Size: 1.19 KB

Versions: 16

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe Fixnum do

  describe ".evolve" do

    context "when provided a string" do

      context "when the string is a number" do

        context "when the string is an fixnum" do

          it "returns an fixnum" do
            expect(described_class.evolve("1")).to eq(1)
          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
  end

  context "when provided a number" do

    context "when the number is an fixnum" do

      it "returns an fixnum" do
        expect(described_class.evolve(1)).to eq(1)
      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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mongoid-8.0.8 spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb
mongoid-8.0.7 spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb
mongoid-8.0.6 spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb
mongoid-7.5.4 spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb
mongoid-8.0.5 spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb
mongoid-7.5.3 spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb
mongoid-8.0.4 spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb
mongoid-8.0.3 spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb
mongoid-7.5.2 spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb
mongoid-8.0.2 spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb
mongoid-7.5.1 spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb
mongoid-7.4.3 spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb
mongoid-8.0.1 spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb
mongoid-7.5.0 spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb
mongoid-7.4.1 spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb
mongoid-7.4.0 spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb