spec/sneakers/worker_handlers_spec.rb in sneakers-2.11.0 vs spec/sneakers/worker_handlers_spec.rb in sneakers-2.12.0.rc1

- old
+ new

@@ -232,32 +232,34 @@ mock(channel).acknowledge(37, false) @error_exchange.extend MockPublish worker.do_work(@header, @props_with_x_death, :reject, @handler) @error_exchange.called.must_equal(true) - @error_exchange.opts.must_equal({ :routing_key => '#' }) - data = JSON.parse(@error_exchange.data) + @error_exchange.opts[:routing_key].must_equal('#') + data = JSON.parse(@error_exchange.opts[:headers][:retry_info]) rescue nil + data.wont_be_nil data['error'].must_equal('reject') data['num_attempts'].must_equal(2) - data['payload'].must_equal(Base64.encode64(:reject.to_s)) - data['properties'].must_equal(Base64.encode64(@props_with_x_death.to_json)) + @error_exchange.data.must_equal(:reject) + data['properties'].to_json.must_equal(@props_with_x_death.to_json) Time.parse(data['failed_at']).wont_be_nil end it 'counts the number of attempts using the count key' do mock(@header).routing_key { '#' } mock(channel).acknowledge(37, false) @error_exchange.extend MockPublish worker.do_work(@header, props_with_x_death_count, :reject, @handler) @error_exchange.called.must_equal(true) - @error_exchange.opts.must_equal({ :routing_key => '#' }) - data = JSON.parse(@error_exchange.data) + @error_exchange.opts[:routing_key].must_equal('#') + data = JSON.parse(@error_exchange.opts[:headers][:retry_info]) rescue nil + data.wont_be_nil data['error'].must_equal('reject') data['num_attempts'].must_equal(4) - data['payload'].must_equal(Base64.encode64(:reject.to_s)) - data['properties'].must_equal(Base64.encode64(props_with_x_death_count.to_json)) + @error_exchange.data.must_equal(:reject) + data['properties'].to_json.must_equal(props_with_x_death_count.to_json) Time.parse(data['failed_at']).wont_be_nil end end end @@ -298,17 +300,18 @@ mock(channel).acknowledge(37, false) @error_exchange.extend MockPublish worker.do_work(@header, @props_with_x_death, StandardError.new('boom!'), @handler) @error_exchange.called.must_equal(true) - @error_exchange.opts.must_equal({ :routing_key => '#' }) - data = JSON.parse(@error_exchange.data) + @error_exchange.opts[:routing_key].must_equal('#') + data = JSON.parse(@error_exchange.opts[:headers][:retry_info]) rescue nil + data.wont_be_nil data['error'].must_equal('boom!') data['error_class'].must_equal(StandardError.to_s) data['backtrace'].wont_be_nil data['num_attempts'].must_equal(2) - data['payload'].must_equal(Base64.encode64('boom!')) - data['properties'].must_equal(Base64.encode64(@props_with_x_death.to_json)) + @error_exchange.data.to_s.must_equal('boom!') + data['properties'].to_json.must_equal(@props_with_x_death.to_json) Time.parse(data['failed_at']).wont_be_nil end end end