test/backgrounded_test.rb in backgrounded-0.6.1 vs test/backgrounded_test.rb in backgrounded-0.6.2
- old
+ new
@@ -1,45 +1,57 @@
require File.join(File.dirname(__FILE__), 'test_helper')
-class User
- backgrounded :do_stuff
+class BackgroundedTest < Test::Unit::TestCase
+
+ class User
+ backgrounded :do_stuff
- def do_stuff
+ def do_stuff
+ end
end
-end
-class Person
- backgrounded :do_stuff
+ class Person
+ backgrounded :do_stuff
- def do_stuff(name, place, location)
+ def do_stuff(name, place, location)
+ end
end
-end
-class Post
- backgrounded :do_stuff, :notify_users
+ class Post
+ backgrounded :do_stuff, :notify_users
- def do_stuff
+ def do_stuff
+ end
+ def notify_users
+ end
end
- def notify_users
+
+ class Comment
+ backgrounded :delete_spam!
+
+ def delete_spam!
+ end
end
-end
-class Comment
- backgrounded :delete_spam!
-
- def delete_spam!
+ class Dog
+ backgrounded :bark => {:priority => :low}
+
+ def bark
+ end
end
-end
-class Dog
- backgrounded :bark => {:priority => :low}
+ class Entry
+ backgrounded :do_stuff
+ backgrounded :notify_users
- def bark
+ def do_stuff
+ end
+ def notify_users
+ end
end
-end
-class BackgroundedTest < Test::Unit::TestCase
+
context 'an object with a single backgrounded method' do
setup do
@user = User.new
end
should "execute method in background" do
@@ -75,9 +87,19 @@
@post.expects(:do_stuff)
@post.do_stuff_backgrounded
@post.expects(:notify_users)
@post.notify_users_backgrounded
+ end
+ end
+
+ context 'an object with multiple backgrounded invokations' do
+ setup do
+ @post = Entry.new
+ end
+ should "setup options for both methods" do
+ assert_not_nil Entry.backgrounded_options[:do_stuff]
+ assert_not_nil Entry.backgrounded_options[:notify_users]
end
end
context 'an object with backgrounded method options' do
setup do