Sha256: b06bd5b9cd1d6c9388a20fa60113051dc6eb79476de378183eacdb12ccda9549
Contents?: true
Size: 1.83 KB
Versions: 27
Compression:
Stored size: 1.83 KB
Contents
# frozen_string_literal: true require "spec_helper" describe Mongoid::StringifiedSymbol do describe ".demongoize" do context "when the object is not a symbol" do it "returns the symbol" do expect(Mongoid::StringifiedSymbol.demongoize("test")).to eq(:test) end end context "when the object is a symbol" do it "returns the symbol" do expect(Mongoid::StringifiedSymbol.demongoize(:test)).to eq(:test) end end context "when the object is a BSON Symbol" do it "returns a symbol" do expect(Mongoid::StringifiedSymbol.demongoize(BSON::Symbol::Raw.new(:test))).to eq(:test) end end context "when the object is an integer" do it "returns a symbol" do expect(Mongoid::StringifiedSymbol.demongoize(14)).to eq(:"14") end end context "when the object is nil" do it "returns nil" do expect(Mongoid::StringifiedSymbol.demongoize(nil)).to be_nil end end end describe ".mongoize" do context "when the object is not a symbol" do it "returns the object" do expect(Mongoid::StringifiedSymbol.mongoize("test")).to eq("test") end it "returns the string" do expect(Mongoid::StringifiedSymbol.mongoize([0,1,2])).to eq("[0, 1, 2]") end it "returns the string" do expect(Mongoid::StringifiedSymbol.mongoize(2)).to eq("2") end end context "when the object is a symbol" do it "returns a string" do expect(Mongoid::StringifiedSymbol.mongoize(:test)).to eq("test") end end context "when the object is nil" do it "returns nil" do expect(Mongoid::StringifiedSymbol.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 & 1 rubygems