Permalink
Browse files

added 'minutely' format for tracking by the minute

  • Loading branch information...
1 parent 8e174a5 commit bbc3ae4166b60de6607ea3c998d8308550187f96 @thegrubbsian thegrubbsian committed Jan 29, 2013
Showing with 16 additions and 1 deletion.
  1. +16 −1 test/counter_test.rb
View
@@ -4,7 +4,7 @@
Counter = Von::Counter
before :each do
- Timecop.freeze(Time.local(2013, 01))
+ Timecop.freeze(Time.local(2013, 01, 01, 01, 01))
Von.config.init!
mock_connection!
end
@@ -47,6 +47,21 @@
@store['von:lists:foo:monthly'].size.must_equal 1
end
+ it 'increments a minute counter' do
+ Von.configure do |config|
+ config.counter 'foo', :minutely => 60
+ end
+
+ Counter.increment('foo')
+ Counter.increment('foo')
+
+ @store.has_key?('von:counters:foo').must_equal true
+ @store.has_key?('von:counters:foo:minutely').must_equal true
+ @store['von:counters:foo']['total'].must_equal 2
+ @store['von:counters:foo:minutely']['2013-01-01 01:01'].must_equal 2
+ @store['von:lists:foo:minutely'].size.must_equal 1
+ end
+
it "expires counters past the limit" do
Von.configure do |config|
config.counter 'foo', :monthly => 1

0 comments on commit bbc3ae4

Please sign in to comment.