Skip to content

Commit

Permalink
more collection tests
Browse files Browse the repository at this point in the history
  • Loading branch information
telent committed Apr 23, 2012
1 parent 27ee8ff commit 35a5924
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions test/unit/collection_test.rb
Expand Up @@ -5,12 +5,23 @@
require 'lizard/collection' require 'lizard/collection'


describe Lizard::Collection do 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 it "rejects elements which are too old" do
c=Lizard::Collection.new 60 @c.add(1,Time.now)
c.add(1,Time.now) @c.add(2,Time.now-80)
c.add(2,Time.now-30) assert_equal 1,@c.length
c.add(2,Time.now-40)
c.add(2,Time.now-80)
assert_equal 3,c.length
end end
end end

0 comments on commit 35a5924

Please sign in to comment.