Sha256: ce5387199502bf6538c98d58b2bbb0a023d84bb271a0a9fc1c2bab8ce2c93196

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

module FakeRedis
  describe "ServerMethods" do

    before(:each) do
      @client = Redis.new
    end

    it "should return the number of keys in the selected database" do
      @client.set("key1", "1")
      @client.set("key2", "2")
      @client.set("key2", "two")

      @client.dbsize.should be == 2
    end

    it "should get information and statistics about the server" do
      @client.info.key?("redis_version").should be == true
    end

    it "should handle non-existent methods" do
      lambda { @client.idontexist }.should raise_error(RuntimeError, "ERR unknown command 'idontexist'")
    end

    describe "multiple databases" do
      it "should default to database 0" do
        @client.inspect.should =~ %r#/0 \(#
      end

      it "should select another database" do
        @client.select(1)
        @client.inspect.should =~ %r#/1 \(#
      end

      it "should flush a database" do
        @client.select(0)
        @client.set("key1", "1")
        @client.set("key2", "2")
        @client.dbsize.should be == 2

        @client.flushdb.should be == "OK"

        @client.dbsize.should be == 0
      end

      it "should flush all databases" do
        @client.select(0)
        @client.set("key3", "3")
        @client.set("key4", "4")
        @client.dbsize.should be == 2

        @client.flushall.should be == "OK"

        @client.dbsize.should be == 0
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fakeredis-0.3.3 spec/server_spec.rb