Sha256: e2010af010f26ddc4a8c3c613cd6a20f246bf60be0ad7b2a6efde37276aaff21
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
require "spec_helper" describe HitList::Counter do let(:real_connection) { Redis.new } let(:name) { 'article' } let(:days_of_interest) { 7 } subject { described_class.new(real_connection, name, days_of_interest) } before(:each) do real_connection.flushall end describe "#total_hits" do it "works as expected" do Timecop.travel(Date.parse('2013-01-21')) subject.hit!(22) subject.hit!(22) subject.hit!(7) subject.hit!(44) subject.hit!(44) subject.hit!(44) subject.total_hits(22).should eq(2) subject.total_hits(7).should eq(1) subject.total_hits(44).should eq(3) Timecop.return end end describe "#top_records" do it 'top records should work' do Timecop.travel(Date.parse('2013-01-21')) subject.hit!(22) subject.hit!(22) subject.hit!(22) subject.hit!(7) Timecop.travel(Date.parse('2013-01-22')) subject.hit!(22) subject.hit!(22) Timecop.travel(Date.parse('2013-01-23')) subject.hit!(22) subject.hit!(7) subject.hit!(7) subject.hit!(7) subject.hit!(7) subject.top_records(2).should eq(["22", "7"]) Timecop.travel(Date.parse('2013-01-25')) subject.top_records(2).should eq(["22", "7"]) Timecop.travel(Date.parse('2013-01-28')) subject.top_records(2).should eq(["7", "22"]) Timecop.return end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hit_list-1.1.1 | spec/counter_end_to_end_spec.rb |