Sha256: 0845c0be7f6005407305b33fb63863cb0a0432456d69807cbbc770f26041ca48

Contents?: true

Size: 1.72 KB

Versions: 18

Compression:

Stored size: 1.72 KB

Contents

require File.expand_path('../test_helper', __FILE__)

describe "Backburner::Connection class" do
  describe "for initialize with single url" do
    before do
      @connection = Backburner::Connection.new("beanstalk://localhost")
    end

    it "should store url in accessor" do
      assert_equal "beanstalk://localhost", @connection.url
    end

    it "should setup beanstalk connection" do
      assert_kind_of Beaneater::Pool, @connection.beanstalk
    end
  end # initialize single connection

  describe "for initialize with multiple urls" do
    it "should support single string with commas" do
      @connection = Backburner::Connection.new("beanstalk://localhost,beanstalk://localhost")
      connections = @connection.beanstalk.connections
      assert_equal 2, connections.size
      assert_equal ['localhost:11300','localhost:11300'], connections.map(&:address)
    end

    it "should support array of connections" do
      @connection = Backburner::Connection.new(['beanstalk://127.0.0.1:11300','beanstalk://localhost'])
      connections = @connection.beanstalk.connections
      assert_equal 2, @connection.beanstalk.connections.size
      assert_equal ['127.0.0.1:11300','localhost:11300'], connections.map(&:address)
    end
  end # initialize

  describe "for bad uri" do
    it "should raise a BadUrl" do
      assert_raises(Backburner::Connection::BadURL) {
        @connection = Backburner::Connection.new("fake://foo")
      }
    end
  end

  describe "for delegated methods" do
    before do
      @connection = Backburner::Connection.new("beanstalk://localhost")
    end

    it "delegate methods to beanstalk connection" do
      assert_equal "localhost", @connection.connections.first.host
    end
  end # delegator
end # Connection

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
backburner-0.4.6 test/connection_test.rb
backburner-0.4.5 test/connection_test.rb
backburner-0.4.4 test/connection_test.rb
backburner-0.4.3 test/connection_test.rb
backburner-0.4.2 test/connection_test.rb
backburner-0.4.1 test/connection_test.rb
backburner-0.4.0 test/connection_test.rb
backburner-0.3.4 test/connection_test.rb
backburner-0.3.3 test/connection_test.rb
backburner-0.3.2 test/connection_test.rb
backburner-0.3.1 test/connection_test.rb
backburner-0.3.0 test/connection_test.rb
backburner-0.2.6 test/connection_test.rb
backburner-0.2.5 test/connection_test.rb
backburner-0.2.0 test/connection_test.rb
backburner-0.1.2 test/connection_test.rb
backburner-0.1.1 test/connection_test.rb
backburner-0.1.0 test/connection_test.rb