Sha256: 67534de11322a32c4446c9dd12d6998c164fe642bb8654e8e1f4e22fbc5a5550

Contents?: true

Size: 1.86 KB

Versions: 14

Compression:

Stored size: 1.86 KB

Contents

require "spec_helper"
include Redistat

describe Redistat::Connection do
  
  it "should have a valid Redis client instance" do
    Redistat.redis.should_not be_nil
  end

  it "should have initialized custom testing connection" do
    redis = Redistat.redis
    redis.client.host.should == '127.0.0.1'
    redis.client.port.should == 8379
    redis.client.db.should == 15
  end
  
  it "should be able to set and get data" do
    redis = Redistat.redis
    redis.set("hello", "world")
    redis.get("hello").should == "world"
    redis.del("hello").should be_true
  end
  
  it "should be able to store hashes to Redis" do
    redis = Redistat.redis
    redis.hset("hash", "field", "1")
    redis.hget("hash", "field").should == "1"
    redis.hincrby("hash", "field", 1)
    redis.hget("hash", "field").should == "2"
    redis.hincrby("hash", "field", -1)
    redis.hget("hash", "field").should == "1"
    redis.del("hash")
  end
  
  it "should be accessible from Redistat module" do
    Redistat.redis.should == Connection.get
    Redistat.redis.should == Redistat.connection
  end
  
  it "should handle multiple connections with refs" do
    Redistat.redis.client.db.should == 15
    Redistat.connect(:port => 8379, :db => 14, :ref => "Custom")
    Redistat.redis.client.db.should == 15
    Redistat.redis("Custom").client.db.should == 14
  end
  
  it "should be able to overwrite default and custom refs" do
    Redistat.redis.client.db.should == 15
    Redistat.connect(:port => 8379, :db => 14)
    Redistat.redis.client.db.should == 14
    
    Redistat.redis("Custom").client.db.should == 14
    Redistat.connect(:port => 8379, :db => 15, :ref => "Custom")
    Redistat.redis("Custom").client.db.should == 15
    
    # Reset the default connection to the testing server or all hell
    # might brake loose from the rest of the specs
    Redistat.connect(:port => 8379, :db => 15)
  end
  
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
redistat-0.2.6 spec/connection_spec.rb
redistat-0.2.5 spec/connection_spec.rb
redistat-0.2.4 spec/connection_spec.rb
redistat-0.2.3 spec/connection_spec.rb
redistat-0.2.2 spec/connection_spec.rb
redistat-0.2.1 spec/connection_spec.rb
redistat-0.2.0 spec/connection_spec.rb
redistat-0.1.1 spec/connection_spec.rb
redistat-0.1.0 spec/connection_spec.rb
redistat-0.0.9 spec/connection_spec.rb
redistat-0.0.8 spec/connection_spec.rb
redistat-0.0.7 spec/connection_spec.rb
redistat-0.0.6 spec/connection_spec.rb
redistat-0.0.5 spec/connection_spec.rb