Sha256: c34f0c36b03394749a349a86b3a4d5c1c3b29520b5156f1f089225dcac186808

Contents?: true

Size: 1.41 KB

Versions: 19

Compression:

Stored size: 1.41 KB

Contents

require "test_helper"

describe Vanity::Connection do
  describe "#new" do
    it "establishes connection with default specification" do
      Vanity::Adapters.expects(:establish_connection).with(adapter: "redis")
      Vanity::Connection.new
    end

    it "establishes connection given a connection specification" do
      Vanity::Adapters.expects(:establish_connection).with(adapter: "mock")
      Vanity::Connection.new(adapter: "mock")
    end

    it "can skip connection" do
      Vanity::Autoconnect.stubs(:playground_should_autoconnect?).returns(false)
      connection = Vanity::Connection.new(adapter: "mock")
      assert !connection.connected?
    end

    it "parses from a string" do
      Vanity::Adapters.expects(:establish_connection).with(
        adapter: 'redis',
        username: 'user',
        password: 'secrets',
        host: 'redis.local',
        port: 6379,
        path: '/5',
        params: nil
      )
      Vanity::Connection.new("redis://user:secrets@redis.local:6379/5")
    end

    it "raises an error for invalid specification hashes" do
      assert_raises(Vanity::Connection::InvalidSpecification) {
        Vanity::Connection.new("adapter" => "mock")
      }
    end

    it "allows a redis connection to be specified" do
      redis = stub("Redis")
      Vanity::Adapters.expects(:establish_connection).with(adapter: :redis, redis: redis)
      Vanity::Connection.new(redis: redis)
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
vanity-3.1.0 test/connection_test.rb
vanity-3.0.2 test/connection_test.rb
vanity-3.0.1 test/connection_test.rb
vanity-3.0.0 test/connection_test.rb
vanity-2.2.10 test/connection_test.rb
vanity-2.2.9 test/connection_test.rb
vanity-2.2.8 test/connection_test.rb
vanity-2.2.7 test/connection_test.rb
vanity-2.2.6 test/connection_test.rb
vanity-2.2.4 test/connection_test.rb
vanity-2.2.3 test/connection_test.rb
vanity-2.2.2 test/connection_test.rb
vanity-2.2.0 test/connection_test.rb
vanity-2.1.2 test/connection_test.rb
vanity-2.1.1 test/connection_test.rb
vanity-2.1.0 test/connection_test.rb
vanity-2.0.1 test/connection_test.rb
vanity-2.0.0 test/connection_test.rb
vanity-2.0.0.beta9 test/connection_test.rb