spec/seam/worker_spec.rb in seam-0.0.7 vs spec/seam/worker_spec.rb in seam-0.0.8
- old
+ new
@@ -32,10 +32,33 @@
effort = Seam::Effort.find(effort.id)
effort.next_step.must_equal "orange"
end
end
+ describe "move_to_next_step as a default" do
+ it "should go to move_to_next_step by default" do
+ flow = Seam::Flow.new
+ flow.apple
+ flow.orange
+
+ effort = flow.start( { first_name: 'John' } )
+ effort = Seam::Effort.find(effort.id)
+
+ effort.next_step.must_equal "apple"
+
+ apple_worker = Seam::Worker.new
+ apple_worker.handles(:apple)
+ def apple_worker.process
+ end
+
+ apple_worker.execute effort
+
+ effort = Seam::Effort.find(effort.id)
+ effort.next_step.must_equal "orange"
+ end
+ end
+
describe "try_again_in" do
let(:effort) do
flow = Seam::Flow.new
flow.apple
@@ -269,11 +292,11 @@
effort.data['hit 1'].must_equal 1
effort.data['hit 2'].must_equal 1
effort.data['hit 3'].must_equal 1
effort.complete?.must_equal true
- #effort.completed_at.must_equal Time.now
+ effort.completed_at.must_equal Time.now
# FUTURE WAVES
send_postcard_if_necessary_worker.execute_all
determine_if_postcard_should_be_sent_worker.execute_all
wait_for_attempting_contact_stage_worker.execute_all
@@ -573,12 +596,45 @@
it "should mark the next step to nil" do
fresh_effort = Seam::Effort.find(effort.id)
fresh_effort.next_step.nil?.must_equal true
end
+
+ it "should mark the completed_at date" do
+ fresh_effort = Seam::Effort.find(effort.id)
+ fresh_effort.completed_at.must_equal Time.now
+ end
it "should mark the history" do
effort.history[0].contrast_with!({"step"=>"apple", "result" => "eject" } )
end
end
+
+ describe "use the name of the worker to tie to a step" do
+
+ let(:effort) do
+ flow = Seam::Flow.new
+ flow.i_will_not_call_handles
+
+ e = flow.start
+ Seam::Effort.find(e.id)
+ end
+
+ before do
+ effort
+ worker = IWillNotCallHandlesWorker.new
+ IWillNotCallHandlesWorker.new.execute_all
+ end
+
+ it "should complete the effort" do
+ fresh_effort = Seam::Effort.find effort.id
+ fresh_effort.complete?.must_equal true
+ end
+
+ end
+end
+
+class IWillNotCallHandlesWorker < Seam::Worker
+ # no calling handles here
+ def process; end
end