Sha256: 022bb8bc06eb0f17e6e69f9d6834222797bdf625f7b6ff09db12b7a952955d0e

Contents?: true

Size: 1.82 KB

Versions: 10

Compression:

Stored size: 1.82 KB

Contents

require 'spec_helper'

describe Punchblock do
  describe '#client_with_connection' do
    let(:mock_connection) { stub('Connection').as_null_object }

    context 'with :XMPP' do
      it 'sets up an XMPP connection, passing options, and a client with the connection attached' do
        options = {:username => 'foo', :password => 'bar'}
        Punchblock::Connection::XMPP.should_receive(:new).once.with(options).and_return 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
        options = {:username => 'foo', :password => 'bar'}
        Punchblock::Connection::Asterisk.should_receive(:new).once.with(options).and_return 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
        options = {:username => 'foo', :password => 'bar'}
        Punchblock::Connection::Freeswitch.should_receive(:new).once.with(options).and_return 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

10 entries across 10 versions & 1 rubygems

Version Path
punchblock-1.9.4 spec/punchblock_spec.rb
punchblock-1.9.3 spec/punchblock_spec.rb
punchblock-1.9.2 spec/punchblock_spec.rb
punchblock-1.9.1 spec/punchblock_spec.rb
punchblock-1.9.0 spec/punchblock_spec.rb
punchblock-1.8.2 spec/punchblock_spec.rb
punchblock-1.8.1 spec/punchblock_spec.rb
punchblock-1.8.0 spec/punchblock_spec.rb
punchblock-1.7.1 spec/punchblock_spec.rb
punchblock-1.7.0 spec/punchblock_spec.rb