spec/seam/worker_spec.rb in seam-1.0.1 vs spec/seam/worker_spec.rb in seam-1.1.0
- old
+ new
@@ -17,9 +17,58 @@
worker.handles(:darren)
worker.step.must_equal "darren"
end
end
+ describe "inherited & all" do
+
+ before do
+ Seam::Worker.instance_eval { @handlers = nil }
+ end
+
+ it "should default to an empty set" do
+ Seam::Worker.all.count.must_equal 0
+ end
+
+ it "should return new instances of all handlers" do
+ instance = Object.new
+ klass = Struct.new(:new).new instance
+ Seam::Worker.inherited klass
+ Seam::Worker.all.count.must_equal 1
+ Seam::Worker.all[0].must_be_same_as instance
+ end
+
+ end
+
+ describe "handler for" do
+
+ let(:handler_1) { Struct.new(:handles).new SecureRandom.uuid }
+ let(:handler_2) { Struct.new(:handles).new SecureRandom.uuid }
+ let(:handler_3) { Struct.new(:handles).new SecureRandom.uuid }
+
+ before do
+ handler_1_class, handler_2_class, handler_3_class = Object.new, Object.new, Object.new
+
+ handler_1_class = Struct.new(:new).new handler_1
+ handler_2_class = Struct.new(:new).new handler_2
+ handler_3_class = Struct.new(:new).new handler_3
+
+ Seam::Worker.instance_eval do
+ @handlers = [handler_1_class, handler_2_class, handler_3_class]
+ end
+ end
+
+ it "should return the handler for the type" do
+ Seam::Worker.handler_for(handler_2.handles).must_be_same_as handler_2
+ Seam::Worker.handler_for(handler_1.handles).must_be_same_as handler_1
+ Seam::Worker.handler_for(handler_3.handles).must_be_same_as handler_3
+ end
+
+ it "should return nil if none exist" do
+ Seam::Worker.handler_for('test').nil?.must_equal true
+ end
+ end
+
describe "move_to_next_step" do
[:date].to_objects {[
['1/1/2011'],
['3/4/2015']