Permalink
Browse files

more collection tests

  • Loading branch information...
1 parent 27ee8ff commit 35a5924b7a021f2536a7199546450c75b4f4400d @telent committed Apr 23, 2012
Showing with 17 additions and 6 deletions.
  1. +17 −6 test/unit/collection_test.rb
@@ -5,12 +5,23 @@
require 'lizard/collection'
describe Lizard::Collection do
+ before do
+ @c=Lizard::Collection.new 60
+ end
+
+ it "logs values with timestamps" do
+ @c.add(1,Time.now)
+ assert_equal 1,@c.length
+ end
+ it "logs values without timestamps" do
+ @c << 2
+ val,time= @c.instance_eval do @data.first end
+ assert_equal 2,val
+ assert_in_delta Time.now,time
+ end
it "rejects elements which are too old" do
- c=Lizard::Collection.new 60
- c.add(1,Time.now)
- c.add(2,Time.now-30)
- c.add(2,Time.now-40)
- c.add(2,Time.now-80)
- assert_equal 3,c.length
+ @c.add(1,Time.now)
+ @c.add(2,Time.now-80)
+ assert_equal 1,@c.length
end
end

0 comments on commit 35a5924

Please sign in to comment.