Sha256: 02ab8ae8b09f5dfde49abb0d304a0719e10171e462b01cd5c6c2070d6a69e4da

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 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))
      @task = stub(:start => true, :stop => true)
      @shard.shard_config.stubs(:save)
      @shard.stubs(:fork_redis_server => @task)
      @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
      @task.stubs(:running? => true)
      @shard.start

      @shard.status.should == :running
    end

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

      @shard.status.should == :stopping
    end

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

      @shard.status.should == :stopped
    end

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

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

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
redis_ring-0.1.3 spec/redis_ring/shard_spec.rb
redis_ring-0.1.2 spec/redis_ring/shard_spec.rb
redis_ring-0.1.1 spec/redis_ring/shard_spec.rb
redis_ring-0.1.0 spec/redis_ring/shard_spec.rb
redis_ring-0.0.2 spec/redis_ring/shard_spec.rb