test/test_veil.rb in veils-0.0.1 vs test/test_veil.rb in veils-0.1.0
- old
+ new
@@ -43,12 +43,23 @@
foo.to_s
foo.touch
assert_equal(5, foo.read(5))
end
- def test_behaves_like_array
+ def test_behaves_like_array_with_json
origin = [1, 2, 3]
foo = Veil.new(origin)
assert(foo.respond_to?(:to_json))
assert_equal(JSON.pretty_generate(origin), JSON.pretty_generate(foo))
+ end
+
+ def test_iterates_array
+ origin = [1, 2, 3]
+ foo = Veil.new(origin, count: 1)
+ assert_equal(1, foo.count)
+ assert(!foo.empty?)
+ assert_equal(3, foo.count)
+ observed = 0
+ foo.each { |_| observed += 1 }
+ assert_equal(3, observed)
end
end