mirror of
https://github.com/jimeh/redistat.git
synced 2026-02-19 13:26:39 +00:00
more specs for Redistat and Redistat::Label
This commit is contained in:
@@ -2,9 +2,23 @@ require "spec_helper"
|
||||
|
||||
describe Redistat do
|
||||
|
||||
it "should create a valid redis connection to correct server" do
|
||||
Redistat.redis.should_not be_nil
|
||||
Redistat.redis.client.port.should == 8379
|
||||
it "should have a valid redis client instance" do
|
||||
redis.should_not be_nil
|
||||
end
|
||||
|
||||
it "should be connected to the testing server" do
|
||||
redis.client.port.should == 8379
|
||||
redis.client.host.should == "127.0.0.1"
|
||||
end
|
||||
|
||||
it "should be able to set and get data" do
|
||||
redis.set "hello", "world"
|
||||
redis.get("hello").should == "world"
|
||||
redis.del("hello").should be_true
|
||||
end
|
||||
|
||||
def redis
|
||||
Redistat.redis
|
||||
end
|
||||
|
||||
end
|
||||
@@ -9,4 +9,21 @@ describe Redistat::Label do
|
||||
label.hash.should == Digest::SHA1.hexdigest(name)
|
||||
end
|
||||
|
||||
it "should store a label hash lookup key" do
|
||||
name = "/about/us"
|
||||
label = Redistat::Label.new(name)
|
||||
label.save
|
||||
label.saved?.should be_true
|
||||
redis.get("Redistat:lables:#{label.hash}").should == name
|
||||
|
||||
name = "/contact/us"
|
||||
label = Redistat::Label.create(name)
|
||||
label.saved?.should be_true
|
||||
redis.get("Redistat:lables:#{label.hash}").should == name
|
||||
end
|
||||
|
||||
def redis
|
||||
Redistat.redis
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user