$: << File.dirname(__FILE__) + "/../lib" require 'rubygems' require 'crowdflower' require 'json' API_KEY = ENV["API_KEY"] unless API_KEY && API_KEY.size > 5 puts < true say "-- Waiting for CrowdFlower to finish copying the job." # You could also register a webhook to have CrowdFlower notify your # server. wait_until { job2.get["units_count"] == 8 } say "Checking the status of the job." assert job.status["tainted_judgments"] == 0 say "Registering a webhook." job.update :webhook_uri => "http://localhost:8080/crowdflower" say "Adding title, instructions, and problem to the job." job.update({:title => 'testtt', :instructions => 'testttt fdsf sfds fsdfs fesfsdf', :problem => '' }) say "Ordering the job." order = CrowdFlower::Order.new(job) unit_count = 8 order.debit(8) wait_until { job.status["needed_judgments"] == 24} say "Canceling the unit." unit_id = job.units.all.to_a[0][0] unit = CrowdFlower::Unit.new(job) assert unit.get(unit_id)['state'] == 'judgable' puts unit.cancel(unit_id).inspect assert unit.get(unit_id)['state'] == 'new' say "Webhook test needs to be written." #job.test_webhook say ">-< Tests complete. >-<"