Sha256: f79ecb23b9dc0ecbda485b8cdf139c507336acbd763d7bd544843051be273021

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require File.expand_path("../../spec_helper", __FILE__)

describe RedisRing::Shard do

  describe "possible statuses" do
    before(:each) do
      @shard = RedisRing::Shard.new(RedisRing::ShardConfig.new(0, RedisRing::Configuration.new))
      @pid = 123
      @shard.shard_config.stubs(:save)
      @shard.stubs(:fork_redis_server => @pid)
      @shard.stubs(:send_kill_signal)
    end

    it "should be stopped initially" do
      @shard.status.should == :stopped
    end

    it "should be running if started and alive" do
      @shard.stubs(:alive? => true)
      @shard.start

      @shard.status.should == :running
    end

    it "should be stopping if started then stopped but still alive" do
      @shard.stubs(:alive? => true)
      @shard.start
      @shard.stop

      @shard.status.should == :stopping
    end

    it "should be stopped if started then stopped and not alive" do
      @shard.stubs(:alive? => false)
      @shard.start
      @shard.stop

      @shard.status.should == :stopped
    end

    it "should be dead if started but not alive" do
      @shard.stubs(:alive? => false)
      @shard.start

      @shard.status.should == :dead
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redis_ring-0.0.1 spec/redis_ring/shard_spec.rb