Sha256: 3a3369bf1da8aa7abe32590141ca8f9985046072a44f142307a38c0e36c36436
Contents?: true
Size: 1.69 KB
Versions: 4
Compression:
Stored size: 1.69 KB
Contents
require "spec_helper" describe Mongoid::Indexable::Specification do describe "#==" do context "when the keys are different" do let(:spec_one) do described_class.new(Band, { name: 1 }) end let(:spec_two) do described_class.new(Band, { title: 1 }) end it "returns false" do expect(spec_one).to_not eq(spec_two) end end context "when the keys are the same" do let(:spec_one) do described_class.new(Band, { name: 1 }) end let(:spec_two) do described_class.new(Band, { name: 1 }) end it "returns true" do expect(spec_one).to eq(spec_two) end end context "when the keys are in different order" do let(:spec_one) do described_class.new(Band, { name: 1, title: -1 }) end let(:spec_two) do described_class.new(Band, { title: -1, name: 1 }) end it "returns false" do expect(spec_one).to_not eq(spec_two) end end end describe "#fields" do let(:spec) do described_class.new(Band, { name: 1, title: 1 }) end it "returns the key fields in order" do expect(spec.fields).to eq([ :name, :title ]) end end describe "#initialize" do let(:spec) do described_class.new( Band, { name: 1, title: 1, years: -1 }, background: true, drop_dups: true ) end it "sets the class" do expect(spec.klass).to eq(Band) end it "normalizes the key" do expect(spec.key).to eq(name: 1, title: 1, y: -1) end it "normalizes the options" do expect(spec.options).to eq(background: true, dropDups: true) end end end
Version data entries
4 entries across 4 versions & 3 rubygems