Sha256: e6e2c3881f995578bd20aea810cbaf3ca63ad8b05dd30a41862723bc84bfd056
Contents?: true
Size: 1.85 KB
Versions: 13
Compression:
Stored size: 1.85 KB
Contents
# frozen_string_literal: true # encoding: utf-8 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
13 entries across 13 versions & 1 rubygems