Sha256: 2daab011987a702531ce3dfa43ea9fe74fc24bbc0467eaf35a25f5986ac4e002

Contents?: true

Size: 1.57 KB

Versions: 2

Compression:

Stored size: 1.57 KB

Contents

require 'spec_helper'
require 'pry'

describe Rack::AMQP::Client do
  before :each do
    Rack::AMQP::Client::Synchronizer.instance.instance_variable_set('@mgr', nil)
  end

  describe "#client" do
    it "returns a Manager" do
      Rack::AMQP::Client::Manager.any_instance.stub(:connect!).and_return(nil)
      expect(Rack::AMQP::Client.client(nil)).to be_instance_of(Rack::AMQP::Client::Manager)
    end
  end

  describe '#with_client' do
    it 'yields something' do
      x = nil
      Rack::AMQP::Client::Manager.any_instance.stub(:connect!).and_return(nil)
      Rack::AMQP::Client.with_client({}) do |mgr|
        x = mgr
      end
      expect(x).to_not be_nil
    end

    it "passes options it doesn't understand to Bunny" do
      fake_bunny = double("Bunny", start: true, create_channel: true)
      expect(Bunny).to receive(:new).with({foo: 'bar'}).and_return(fake_bunny)
      Rack::AMQP::Client.with_client({foo: 'bar'}) {|m| }
    end

    it "integrates", brittle: true do
      pending "Some better way to test integrations"
      Timeout.timeout(3) do
        Rack::AMQP::Client.with_client(host: 'localhost') do |c|
          response = c.request('test.simple/users.json', {http_method: 'GET', headers: {}})
          expect(response.payload).to eq("[{\"id\":1,\"login\":\"someguy\",\"password\":\"awesomenesssss\",\"created_at\":\"2013-12-07T17:11:45.518Z\",\"updated_at\":\"2013-12-07T17:11:45.518Z\"},{\"id\":2,\"login\":\"Hi\",\"password\":\"There\",\"created_at\":\"2014-03-30T18:31:21.106Z\",\"updated_at\":\"2014-03-30T18:31:21.106Z\"}]")
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-amqp-client-0.0.3 spec/rack/amqp/client/client_spec.rb
rack-amqp-client-0.0.2 spec/rack/amqp/client/client_spec.rb