Sha256: 855620c2dfffea722f3a2daf66052d19efb5299a1795a1cd4fab4f36464fe998

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'

describe Punchblock do
  describe '#client_with_connection' do
    context 'with :XMPP' do
      it 'sets up an XMPP connection, passing options, and a client with the connection attached' do
        mock_connection = stub_everything 'Connection'
        options = {:username => 'foo', :password => 'bar'}
        Punchblock::Connection::XMPP.expects(:new).once.with(options).returns mock_connection
        client = Punchblock.client_with_connection :XMPP, options
        client.should be_a Punchblock::Client
        client.connection.should be mock_connection
      end
    end

    context 'with :asterisk' do
      it 'sets up an Asterisk connection, passing options, and a client with the connection attached' do
        mock_connection = stub_everything 'Connection'
        options = {:username => 'foo', :password => 'bar'}
        Punchblock::Connection::Asterisk.expects(:new).once.with(options).returns mock_connection
        client = Punchblock.client_with_connection :asterisk, options
        client.should be_a Punchblock::Client
        client.connection.should be mock_connection
      end
    end

    context 'with :yate' do
      it 'raises ArgumentError' do
        options = {:username => 'foo', :password => 'bar'}
        lambda { Punchblock.client_with_connection :yate, options }.should raise_error(ArgumentError)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
punchblock-1.3.0 spec/punchblock_spec.rb