Sha256: 4a96c2d13f3266390ba404a90dc0c40bfc7946ca44ac17ee2fad4d4140597f62

Contents?: true

Size: 939 Bytes

Versions: 24

Compression:

Stored size: 939 Bytes

Contents

require 'spec_helper'

module MongoModel
  describe MongoOperator do
    subject { MongoOperator.new(:age, :gt) }
  
    it "should convert to mongo selector" do
      subject.to_mongo_selector(14).should == { '$gt' => 14 }
    end
  
    it "should be equal to a MongoOperator with the same field and operator" do
      subject.should == MongoOperator.new(:age, :gt)
    end
  
    it "should not be equal to a MongoOperator with a different field/operator" do
      subject.should_not == MongoOperator.new(:age, :lte)
      subject.should_not == MongoOperator.new(:date, :gt)
    end
  
    it "should be created from symbol methods" do
      :age.gt.should == MongoOperator.new(:age, :gt)
      :date.lte.should == MongoOperator.new(:date, :lte)
      :position.near.should == MongoOperator.new(:position, :near)
    end
  
    it "should be equal within a hash" do
      { :age.gt => 10 }.should == { :age.gt => 10 }
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
mongomodel-0.4.6 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.4.5 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.4.4 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.4.3 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.4.2 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.4.1 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.4.0 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.3.6 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.3.5 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.3.4 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.3.3 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.3.2 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.3.1 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.3.0 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.2.20 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.2.19 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.2.18 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.2.17 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.2.16 spec/mongomodel/support/mongo_operator_spec.rb
mongomodel-0.2.15 spec/mongomodel/support/mongo_operator_spec.rb