Sha256: c9328b53fb7a9cd2668449677180503546d548076628d8b56a46f9b9f91b9b5e
Contents?: true
Size: 1.88 KB
Versions: 1
Compression:
Stored size: 1.88 KB
Contents
require 'spec_helper' require 'pwwka/queue_resque_job_handler' class MyTestJob end describe Pwwka::QueueResqueJobHandler do describe "::handle!" do let(:job_class) { MyTestJob } let(:routing_key) { "foo.bar.blah" } let(:delivery_info) { double("delivery info", routing_key: routing_key) } let(:properties_hash) { { "app_id" => "myapp", "timestamp" => "2015-12-12 13:22:99", "message_id" => "66", } } let(:properties) { Bunny::MessageProperties.new(properties_hash) } let(:payload) { { "this" => "is", "some" => true, "payload" => 99, } } before do allow(Resque).to receive(:enqueue) ENV["JOB_KLASS"] = MyTestJob.name end context "when not asking for more information explicitly" do it "should queue a resque job using JOB_KLASS and the payload" do described_class.handle!(delivery_info,properties,payload) expect(Resque).to have_received(:enqueue).with(MyTestJob,payload) end end context "when asking to NOT receive more information explicitly" do it "should queue a resque job using JOB_KLASS and the payload" do ENV["PWWKA_QUEUE_EXTENDED_INFO"] = 'false' described_class.handle!(delivery_info,properties,payload) expect(Resque).to have_received(:enqueue).with(MyTestJob,payload) end end context "when asking for more information via PWWKA_QUEUE_EXTENDED_INFO" do it "should queue a resque job using JOB_KLASS, payload, routing key, and properties as a hash" do ENV["PWWKA_QUEUE_EXTENDED_INFO"] = 'true' described_class.handle!(delivery_info,properties,payload) expect(Resque).to have_received(:enqueue).with(MyTestJob,payload,routing_key,properties_hash) end end after do ENV.delete("JOB_KLASS") ENV.delete("PWWKA_QUEUE_EXTENDED_INFO") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pwwka-0.12.0.RC1 | spec/unit/queue_resque_job_handler_spec.rb |