Browse files

Check exact source instead of object equality

Ran into issue previously where object was initializing with wrong
source. This makes sure that source is what we expect and that object
initialization isn't screwing anything up and hiding it.
  • Loading branch information...
1 parent f3b4d2d commit 6c6ae55219f6f42182e8e5015aa4e9123c231154 @jnunemaker jnunemaker committed Oct 11, 2012
Showing with 7 additions and 7 deletions.
  1. +7 −7 spec/plucky/query_spec.rb
View
14 spec/plucky/query_spec.rb
@@ -547,7 +547,7 @@
described_class.new(@collection).
amend(:foo => 'bar').
amend(:baz => 'wick').
- criteria.should == Plucky::CriteriaHash.new(:foo => 'bar', :baz => 'wick')
+ criteria.source.should eq(:foo => 'bar', :baz => 'wick')
end
end
@@ -567,21 +567,21 @@
subject.
where(:moo => 'cow').
where(:foo => 'bar').
- criteria.should == Plucky::CriteriaHash.new(:foo => 'bar', :moo => 'cow')
+ criteria.source.should eq(:foo => 'bar', :moo => 'cow')
end
it "gets normalized" do
subject.
where(:moo => 'cow').
where(:foo.in => ['bar']).
- criteria.should == Plucky::CriteriaHash.new(:moo => 'cow', :foo => {:$in => ['bar']})
+ criteria.source.should eq(:moo => 'cow', :foo => {:$in => ['bar']})
end
it "normalizes merged criteria" do
subject.
where(:foo => 'bar').
where(:foo => 'baz').
- criteria.should == Plucky::CriteriaHash.new(:foo => {:$in => %w[bar baz]})
+ criteria.source.should eq(:foo => {:$in => %w[bar baz]})
end
it "returns new instance of query" do
@@ -729,7 +729,7 @@
context "Criteria/option auto-detection" do
it "knows :conditions are criteria" do
query = described_class.new(@collection, :conditions => {:foo => 'bar'})
- query.criteria.should == Plucky::CriteriaHash.new(:foo => 'bar')
+ query.criteria.source.should eq(:foo => 'bar')
query.options.keys.should_not include(:conditions)
end
@@ -779,8 +779,8 @@
:limit => 10,
:skip => 10,
})
- query.criteria.should == Plucky::CriteriaHash.new(:foo => 'bar', :baz => true)
- query.options.should == Plucky::OptionsHash.new({
+ query.criteria.source.should eq(:foo => 'bar', :baz => true)
+ query.options.source.should eq({
:sort => [['foo', 1]],
:fields => ['foo', 'baz'],
:limit => 10,

0 comments on commit 6c6ae55

Please sign in to comment.