Sha256: 73ad558b156ad4e9ebc643d5ee7de6f34a495016fa203429c394296159a5ced8

Contents?: true

Size: 1.89 KB

Versions: 8

Compression:

Stored size: 1.89 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 :freeswitch' do
      it 'sets up an Freeswitch connection, passing options, and a client with the connection attached' do
        mock_connection = stub_everything 'Connection'
        options = {:username => 'foo', :password => 'bar'}
        Punchblock::Connection::Freeswitch.expects(:new).once.with(options).returns mock_connection
        client = Punchblock.client_with_connection :freeswitch, 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

8 entries across 8 versions & 1 rubygems

Version Path
punchblock-1.6.1 spec/punchblock_spec.rb
punchblock-1.6.0 spec/punchblock_spec.rb
punchblock-1.5.3 spec/punchblock_spec.rb
punchblock-1.5.2 spec/punchblock_spec.rb
punchblock-1.5.1 spec/punchblock_spec.rb
punchblock-1.5.0 spec/punchblock_spec.rb
punchblock-1.4.1 spec/punchblock_spec.rb
punchblock-1.4.0 spec/punchblock_spec.rb