Sha256: 8d541455778facdccb9b7ef8a2f072187c189f3c5934eed26a61a0f4e672e0a8
Contents?: true
Size: 1.44 KB
Versions: 3
Compression:
Stored size: 1.44 KB
Contents
require 'spec_helper' require File.join(File.dirname(__FILE__), '../../', 'examples/customers') describe Rodent::Base do include EventedSpec::AMQPSpec include EventedSpec::SpecHelper em_before { AMQP.cleanup_state } em_after { AMQP.cleanup_state } default_options({host: 'localhost', port: 5672}) default_timeout(10) amqp_before do @channel = AMQP::Channel.new @channel.should be_open @message_id = BSON::ObjectId.new.to_s @replies_queue = @channel.queue(@message_id, exclusive: true, auto_delete: true) @consumer = AMQP::Consumer.new(@channel, @replies_queue) @consumer.consume do @consumer.on_delivery do |metadata, payload| @response = MultiJson.load(payload) metadata.ack @consumer.cancel end end done do CustomersAPI.bind end end after(:all) do AMQP.cleanup_state done end it 'should return right response' do params = {name: 'Bob Marley', email: 'bob@example.com'} @channel.direct('rodent.requests').publish MultiJson.dump(params), routing_key: 'customers.create', message_id: @message_id, reply_to: @replies_queue.name done(2.0) do @response.should_not be_nil @response['status'].should == 201 @response['headers'].should == {'API-Version' => 'v1'} @response['body'].should_not be_nil MultiJson.load(@response['body']).should == {'name' => 'Bob Marley', 'email' => 'bob@example.com'} end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rodent-0.0.7 | spec/rodent/base_spec.rb |
rodent-0.0.6 | spec/rodent/base_spec.rb |
rodent-0.0.4 | spec/rodent/base_spec.rb |