finder and it's specs work!

This commit is contained in:
2010-10-15 01:47:16 +01:00
parent f2b0bd7f47
commit b6aa9c65ac
2 changed files with 80 additions and 4 deletions

View File

@@ -1,6 +1,11 @@
require "spec_helper"
describe Redistat::Finder do
include Redistat::Database
before(:each) do
db.flushdb
end
it "should initialize properly" do
two_hours_ago = 2.hours.ago
@@ -33,4 +38,26 @@ describe Redistat::Finder do
end
it "should fetch stats properly" do
# pending "needs reimplementation"
@scope = "PageViews"
@label = "about_us"
@date = Time.now
@key = Redistat::Key.new(@scope, @label, @date, {:depth => :day})
@stats = {"views" => 3, "visitors" => 2}
key = Redistat::Key.new(@scope, @label, 2.hours.ago)
Redistat::Summary.update(key, @stats, :hour)
key = Redistat::Key.new(@scope, @label, 1.hours.ago)
Redistat::Summary.update(key, @stats, :hour)
key = Redistat::Key.new(@scope, @label, 24.minutes.ago)
Redistat::Summary.update(key, @stats, :hour)
# stats = Redistat::Summary.find(key, 3.hours.ago, 2.hour.from_now, :hour)
stats = Redistat::Finder.find({:from => 3.hours.ago, :till => 2.hours.from_now, :scope => @scope, :label => @label, :depth => :hour})
stats.should == { "views" => 9, "visitors" => 6 }
end
end