Created
January 7, 2010 03:26
-
-
Save durran/270949 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "spec_helper" | |
describe Mongoid::Criteria do | |
describe "#max" do | |
before do | |
10.times do |n| | |
Person.create(:title => "Sir", :age => (n * 10), :aliases => ["D", "Durran"]) | |
end | |
end | |
after do | |
Person.delete_all | |
end | |
it "provides max for the field provided" do | |
Person.max(:age).should == 90.0 | |
end | |
end | |
describe "#min" do | |
before do | |
10.times do |n| | |
Person.create(:title => "Sir", :age => (n * 10), :aliases => ["D", "Durran"]) | |
end | |
end | |
after do | |
Person.delete_all | |
end | |
it "provides min for the field provided" do | |
Person.min(:age).should == 0.0 | |
end | |
end | |
describe "#sum" do | |
before do | |
10.times do |n| | |
Person.create(:title => "Sir", :age => 5, :aliases => ["D", "Durran"]) | |
end | |
end | |
after do | |
Person.delete_all | |
end | |
it "provides sum for the field provided" do | |
Person.where(:age.gt => 3).sum(:age).should == 50.0 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment