Sha256: 8c7cf64468443ee53fd83c0a2c1e07a67bb75a7a8b016e15409b8bb5046c57e5

Contents?: true

Size: 1.41 KB

Versions: 27

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

require "spec_helper"

describe Mongoid::Extensions::Symbol do

  describe ".demongoize" do

    context "when the object is not a symbol" do

      it "returns the symbol" do
        expect(Symbol.demongoize("test")).to eq(:test)
      end
    end

    context "when the object is nil" do

      it "returns nil" do
        expect(Symbol.demongoize(nil)).to be_nil
      end
    end
  end

  describe "#mongoid_id?" do

    context "when the string is id" do

      it "returns true" do
        expect(:id).to be_mongoid_id
      end
    end

    context "when the string is _id" do

      it "returns true" do
        expect(:_id).to be_mongoid_id
      end
    end

    context "when the string contains id" do

      it "returns false" do
        expect(:identity).to_not be_mongoid_id
      end
    end

    context "when the string contains _id" do

      it "returns false" do
        expect(:something_id).to_not be_mongoid_id
      end
    end
  end

  describe ".mongoize" do

    context "when the object is not a symbol" do

      it "returns the symbol" do
        expect(Symbol.mongoize("test")).to eq(:test)
      end
    end

    context "when the object is nil" do

      it "returns nil" do
        expect(Symbol.mongoize(nil)).to be_nil
      end
    end
  end

  describe "#mongoize" do

    it "returns self" do
      expect(:test.mongoize).to eq(:test)
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
mongoid-7.3.5 spec/mongoid/extensions/symbol_spec.rb
mongoid-7.3.4 spec/mongoid/extensions/symbol_spec.rb
mongoid-7.1.11 spec/mongoid/extensions/symbol_spec.rb
mongoid-7.2.6 spec/mongoid/extensions/symbol_spec.rb
mongoid-7.3.3 spec/mongoid/extensions/symbol_spec.rb
mongoid-7.3.2 spec/mongoid/extensions/symbol_spec.rb
mongoid-7.2.5 spec/mongoid/extensions/symbol_spec.rb
mongoid-7.1.10 spec/mongoid/extensions/symbol_spec.rb
mongoid-7.1.9 spec/mongoid/extensions/symbol_spec.rb
mongoid-7.2.4 spec/mongoid/extensions/symbol_spec.rb
mongoid-7.3.1 spec/mongoid/extensions/symbol_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongoid-7.1.7/spec/mongoid/extensions/symbol_spec.rb
mongoid-7.3.0 spec/mongoid/extensions/symbol_spec.rb
mongoid-7.2.3 spec/mongoid/extensions/symbol_spec.rb
mongoid-7.1.8 spec/mongoid/extensions/symbol_spec.rb
mongoid-7.2.2 spec/mongoid/extensions/symbol_spec.rb
mongoid-7.2.1 spec/mongoid/extensions/symbol_spec.rb
mongoid-7.1.7 spec/mongoid/extensions/symbol_spec.rb
mongoid-7.2.0 spec/mongoid/extensions/symbol_spec.rb
mongoid-7.1.6 spec/mongoid/extensions/symbol_spec.rb