mirror of
https://github.com/jimeh/redistat.git
synced 2026-02-19 13:26:39 +00:00
initial import
This commit is contained in:
10
spec/_redistat_spec.rb
Normal file
10
spec/_redistat_spec.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
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
|
||||
end
|
||||
|
||||
end
|
||||
42
spec/date_spec.rb
Normal file
42
spec/date_spec.rb
Normal file
@@ -0,0 +1,42 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Redistat::Date do
|
||||
|
||||
it "should initialize from Time object" do
|
||||
now = Time.now
|
||||
rdate = Redistat::Date.new(now)
|
||||
[:year, :month, :day, :hour, :min, :sec].each { |k| rdate.send(k).should == now.send(k) }
|
||||
end
|
||||
|
||||
it "should initialize from Date object" do
|
||||
today = Date.today
|
||||
rdate = Redistat::Date.new(today)
|
||||
[:year, :month, :day].each { |k| rdate.send(k).should == today.send(k) }
|
||||
[:hour, :min, :sec].each { |k| rdate.send(k).should == nil }
|
||||
end
|
||||
|
||||
it "should initialize from String object" do
|
||||
now = Time.now
|
||||
rdate = Redistat::Date.new(now.to_s)
|
||||
[:year, :month, :day, :hour, :min, :sec].each { |k| rdate.send(k).should == now.send(k) }
|
||||
end
|
||||
|
||||
it "should convert to string with correct depths" do
|
||||
today = Date.today
|
||||
rdate = Redistat::Date.new(today)
|
||||
props = [:year, :month, :day, nil]
|
||||
props.each do
|
||||
rdate.to_s(props.last).should == props.map { |k| today.send(k).to_s.rjust(2, '0') if !k.nil? }.join
|
||||
props.pop
|
||||
end
|
||||
|
||||
now = Time.now
|
||||
rdate = Redistat::Date.new(now)
|
||||
props = [:year, :month, :day, :hour, :min, :sec, nil]
|
||||
props.each do
|
||||
rdate.to_s(props.last).should == props.map { |k| now.send(k).to_s.rjust(2, '0') if !k.nil? }.join
|
||||
props.pop
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
1
spec/db/dump.rdb
Normal file
1
spec/db/dump.rdb
Normal file
@@ -0,0 +1 @@
|
||||
REDIS0001<EFBFBD>
|
||||
7
spec/key_spec.rb
Normal file
7
spec/key_spec.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Redistat::Key do
|
||||
|
||||
|
||||
|
||||
end
|
||||
12
spec/label_spec.rb
Normal file
12
spec/label_spec.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
require "spec_helper"
|
||||
|
||||
describe Redistat::Label do
|
||||
|
||||
it "should initialize and SHA1 hash the label name" do
|
||||
name = "/about/us"
|
||||
label = Redistat::Label.new(name)
|
||||
label.name.should == name
|
||||
label.hash.should == Digest::SHA1.hexdigest(name)
|
||||
end
|
||||
|
||||
end
|
||||
9
spec/redis-test.conf
Normal file
9
spec/redis-test.conf
Normal file
@@ -0,0 +1,9 @@
|
||||
daemonize yes
|
||||
dir ./spec/db
|
||||
pidfile ./redis.pid
|
||||
port 8379
|
||||
bind 127.0.0.1
|
||||
timeout 300
|
||||
loglevel debug
|
||||
logfile stdout
|
||||
databases 16
|
||||
5
spec/spec_helper.rb
Normal file
5
spec/spec_helper.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
require "rubygems"
|
||||
require File.dirname(__FILE__) + "/../lib/redistat"
|
||||
|
||||
Redistat.connect({:port => 8379, :db => 15})
|
||||
Redistat.flush
|
||||
Reference in New Issue
Block a user