Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def assert_worker_runs_methods(worker, *methods)
- worker_klass = "#{worker.to_s.camelize}Worker".constantize
- methods.each do |method|
- worker_klass.any_instance.stubs(method).returns(true)
- MiddleMan.expects(:worker).with(:"#{worker}_worker").returns(worker_klass.new)
- end
- end
- def deny_worker_runs_methods(worker, *methods)
- worker_klass = "#{worker.to_s.camelize}Worker".constantize
- methods.each do |method|
- worker_klass.any_instance.stubs(method).returns(true)
- MiddleMan.expects(:worker).with(:"#{worker}_worker").returns(worker_klass.new).never
- end
- end
- # Shoulda examples
- should "update cached csv registration after save" do
- assert_worker_runs_methods :form_updater, :async_update_cached_csv_registrations
- assert forms(:one).save
- end
- should "not update cached csv registration after update if event has no registrations" do
- Registration.delete_all
- deny_worker_runs_methods :form_updater, :async_update_cached_csv_registrations
- assert forms(:one).save
- end
Add Comment
Please, Sign In to add comment