Sha256: b5042c76fc69f6cd449c3cadacd043112b003d9ed6fee90e08d9133c9b9b2072

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

# adapted from redis-rb
require 'spec_helper'

describe EventMachine::Hiredis, "URL parsing" do
  it "defaults URL defaults to 127.0.0.1:6379" do
    redis = EventMachine::Hiredis.setup

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

  it "allows to pass in a URL" do
    redis = EventMachine::Hiredis.setup "redis://:secr3t@foo.com:999/2"

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

  it "does not modify the passed options" do
    options = "redis://:secr3t@foo.com:999/2"

    redis = EventMachine::Hiredis.setup(options)

    options.should == "redis://:secr3t@foo.com:999/2"
  end

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

    redis = EventMachine::Hiredis.setup

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

    ENV.delete("REDIS_URL")
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
cs-em-hiredis-0.1.2 spec/url_param_spec.rb
em-hiredis-0.1.1 spec/url_param_spec.rb
em-hiredis-0.1.0 spec/url_param_spec.rb