Sha256: d5d754c4daea2d3163e2da18a7610f03abe1297a851f41ff8286ddaa8ef6b7db

Contents?: true

Size: 1.59 KB

Versions: 53

Compression:

Stored size: 1.59 KB

Contents

# encoding: UTF-8

require File.expand_path("./helper", File.dirname(__FILE__))

test "URL defaults to 127.0.0.1:6379" do
  redis = Redis.connect

  assert "127.0.0.1" == redis.client.host
  assert 6379 == redis.client.port
  assert 0 == redis.client.db
  assert nil == redis.client.password
end

test "allows to pass in a URL" do
  redis = Redis.connect :url => "redis://:secr3t@foo.com:999/2"

  assert "foo.com" == redis.client.host
  assert 999 == redis.client.port
  assert 2 == redis.client.db
  assert "secr3t" == redis.client.password
end

test "override URL if path option is passed" do
  redis = Redis.connect :url => "redis://:secr3t@foo.com/foo:999/2", :path => "/tmp/redis.sock"

  assert "/tmp/redis.sock" == redis.client.path
  assert nil == redis.client.host
  assert nil == redis.client.port
end

test "overrides URL if another connection option is passed" do
  redis = Redis.connect :url => "redis://:secr3t@foo.com:999/2", :port => 1000

  assert "foo.com" == redis.client.host
  assert 1000 == redis.client.port
  assert 2 == redis.client.db
  assert "secr3t" == redis.client.password
end

test "does not modify the passed options" do
  options = { :url => "redis://:secr3t@foo.com:999/2" }

  redis = Redis.connect(options)

  assert({ :url => "redis://:secr3t@foo.com:999/2" } == options)
end

test "uses REDIS_URL over default if available" do
  ENV["REDIS_URL"] = "redis://:secr3t@foo.com:999/2"

  redis = Redis.connect

  assert "foo.com" == redis.client.host
  assert 999 == redis.client.port
  assert 2 == redis.client.db
  assert "secr3t" == redis.client.password

  ENV.delete("REDIS_URL")
end

Version data entries

53 entries across 53 versions & 6 rubygems

Version Path
classiccms-0.5.14 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.5.13 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.5.12 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.5.11 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.5.10 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.5.9 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.5.8 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.5.7 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.5.6 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.5.5 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.5.2 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.5.1 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.5.0 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.4.2 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.4.1 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.4.0 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.3.9 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.3.8 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.3.7 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb
classiccms-0.3.6 vendor/bundle/gems/redis-2.2.2/test/url_param_test.rb