more specs for Redistat and Redistat::Label

This commit is contained in:
2010-07-19 01:38:44 +03:00
parent 94001afc29
commit f1e3f20c88
2 changed files with 34 additions and 3 deletions

View File

@@ -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

View File

@@ -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