spec/mongomodel/support/scope_spec.rb in mongomodel-0.4.2 vs spec/mongomodel/support/scope_spec.rb in mongomodel-0.4.3
- old
+ new
@@ -240,10 +240,17 @@
where_scope = subject.where({ :author => "Sam" }, { :published => false })
where_scope.where_values.should == subject.where_values + [{ :author => "Sam" }, { :published => false }]
end
end
+ describe "#where!" do
+ it "should overwrite where values" do
+ where_scope = subject.where!(:author => "Sam")
+ where_scope.where_values.should == [{ :author => "Sam" }]
+ end
+ end
+
describe "#order" do
it "should return a new scope" do
subject.order(:author.asc).should be_an_instance_of(Scope)
end
@@ -261,10 +268,17 @@
order_scope = subject.order(:author.asc, :published.desc)
order_scope.order_values.should == subject.order_values + [:author.asc, :published.desc]
end
end
+ describe "#order!" do
+ it "should overwrite order values" do
+ order_scope = subject.order!(:author.asc)
+ order_scope.order_values.should == [:author.asc]
+ end
+ end
+
describe "#select" do
it "should return a new scope" do
subject.select(:author).should be_an_instance_of(Scope)
end
@@ -279,9 +293,16 @@
end
it "should add multiple select values" do
select_scope = subject.select(:author, :published)
select_scope.select_values.should == subject.select_values + [:author, :published]
+ end
+ end
+
+ describe "#select!" do
+ it "should overwrite select values" do
+ select_scope = subject.select!(:author)
+ select_scope.select_values.should == [:author]
end
end
describe "#limit" do
it "should return a new scope" do