test/deferrable_test.rb in deferrable-0.1.0 vs test/deferrable_test.rb in deferrable-0.2.0
- old
+ new
@@ -1,7 +1,47 @@
require File.dirname(__FILE__) + '/test_helper'
class DeferrableTest < Test::Unit::TestCase
- should "probably rename this file and start testing for real" do
- flunk "hey buddy, you should probably rename this file and start testing for real"
+ class Foo
+ include Deferrable
+
+ def later
+ complete_deferred
+ end
+
+ def nevermind
+ clear_deferred
+ end
end
-end
\ No newline at end of file
+
+ should "defer execution" do
+ foo = Foo.new
+
+ count = 0
+ foo.deferred do
+ count += 1
+ end
+
+ assert_equal 0, count
+
+ foo.later
+
+ assert_equal 1, count
+ end
+
+ should "now_and_later" do
+ foo = Foo.new
+
+ count = 0
+ foo.now_and_later do
+ count = 7
+ end
+
+ assert_equal 7, count
+
+ count = 0
+
+ foo.later
+
+ assert_equal 7, count
+ end
+end