Sha256: 80a332aaa27c20598422aecdee7b37b23a245d9b5e816b51285fe3992a702b83

Contents?: true

Size: 1.32 KB

Versions: 47

Compression:

Stored size: 1.32 KB

Contents

require File.join(File.dirname(__FILE__), 'test_helper')

describe HammerCLI::Connection do
  let(:connections) { HammerCLI::Connection.new }

  describe '#create' do
    it "creates new connection" do
      connections.create(:test) do
        :conn1
      end
      assert_equal :conn1, connections.get(:test)
    end

    it "doesn't overwrite the connection when called multiple times" do
      connections.create(:test) do
        :conn1
      end
      connections.create(:test) do
        :conn2
      end
      assert_equal :conn1, connections.get(:test)
    end

    it 'writes message to log' do
      logger = stub()
      logger.expects(:debug).with('Registered: test_connection')

      connections = HammerCLI::Connection.new(logger)
      connections.create(:test_connection) do
        :test_connection
      end
    end
  end

  describe '#drop' do
    it 'drops the connection' do
      connections.create(:test) do
        :conn1
      end
      connections.drop(:test)
      assert_nil connections.get(:test)
    end
  end

  describe '#drop_all' do
    it 'drops all connections' do
      connections.create(:test1) do
        :conn1
      end
      connections.create(:test2) do
        :conn3
      end
      connections.drop_all

      assert_nil connections.get(:test1)
      assert_nil connections.get(:test2)
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
hammer_cli-3.13.0 test/unit/connection_test.rb
hammer_cli-3.12.0 test/unit/connection_test.rb
hammer_cli-3.10.0 test/unit/connection_test.rb
hammer_cli-3.9.0 test/unit/connection_test.rb
hammer_cli-3.8.0 test/unit/connection_test.rb
hammer_cli-3.7.0 test/unit/connection_test.rb
hammer_cli-3.5.1 test/unit/connection_test.rb
hammer_cli-3.6.0 test/unit/connection_test.rb
hammer_cli-3.5.0 test/unit/connection_test.rb
hammer_cli-3.4.0 test/unit/connection_test.rb
hammer_cli-3.3.0 test/unit/connection_test.rb
hammer_cli-3.2.0 test/unit/connection_test.rb
hammer_cli-3.1.1 test/unit/connection_test.rb
hammer_cli-3.0.2 test/unit/connection_test.rb
hammer_cli-3.1.0 test/unit/connection_test.rb
hammer_cli-3.0.1 test/unit/connection_test.rb
hammer_cli-3.0.0 test/unit/connection_test.rb
hammer_cli-2.5.1 test/unit/connection_test.rb
hammer_cli-2.5.0 test/unit/connection_test.rb
hammer_cli-2.3.1 test/unit/connection_test.rb