Use ruby-debug on jruby, debugger on mri-ruby

Signed-off-by: Greg Hurrell <greg@causes.com>
Change-Id: I3ed31ee344e951fbad36e6313c3ac1f842d2c06f
Reviewed-on: https://gerrit.causes.com/25538
Tested-by: jenkins <jenkins@causes.com>
Fix flapping tests under JRuby by switching to Rationals

Floats are lossy; use Rationals where possible to prevent flapping in
the tests; fixes all tests that were flapping in jruby

Signed-off-by: Greg Hurrell <greg@causes.com>
Change-Id: Id1852c054531f13edc8b59d00a70da2a6d75fb54
Reviewed-on: https://gerrit.causes.com/25539
Tested-by: jenkins <jenkins@causes.com>
Add jruby-19mode to travis-ci config

Signed-off-by: Greg Hurrell <greg@causes.com>
Change-Id: I07fb68a709385abe2c533029a046fe5db82c9d17
Reviewed-on: https://gerrit.causes.com/25540
Tested-by: jenkins <jenkins@causes.com>
Cut 0.8.2 release

Change-Id: Ib3338947d4f032e8bd15f3100851cbb2ce056b09
Reviewed-on: https://gerrit.causes.com/25631
Tested-by: jenkins <jenkins@causes.com>
Reviewed-by: Jimmy Kittiyachavalit <jimmy@causes.com>
Reviewed-by: Joe Lencioni <joe.lencioni@causes.com>
Add futures to pipeline that copy the real redis's behaviour

Based on this pull request:

  https://github.com/causes/mock_redis/pull/62

with some style fixes applied:

  - improved commit message formatting
  - removed `puts` debug statements
  - remove some unnecessary blank lines
  - converted double quotes to singles
  - squashed both commits in the pull request into one
  - tidied up some whitespace (mostly alignment)
  - dropped unnecessary explicit `(:each)` from `before` blocks
  - dropped "should" from `it` descriptions

Signed-off-by: Greg Hurrell <greg@causes.com>
Change-Id: If2b62f830efca103dd29b7f4a863954a65acd342
Reviewed-on: https://gerrit.causes.com/26222
Tested-by: jenkins <jenkins@causes.com>
Reviewed-by: Kim Douglas Clarence Mason <kim.mason@causes.com>
Cut 0.9.0 release

Change-Id: I1ea61ea2dd84ac9837ed5a023c5f1788fb8a4766
Reviewed-on: https://gerrit.causes.com/26326
Tested-by: jenkins <jenkins@causes.com>
Reviewed-by: Greg Hurrell <greg@causes.com>
Tested-by: Greg Hurrell <greg@causes.com>
Add MIT license to Gemspec

We had the license file, but we didn't have it listed in the gemspec.

Issue: https://github.com/causes/mock_redis/issues/64

Change-Id: Ibadb34b3c7825774dfbc5bffd3c6fdd611b05429
Reviewed-on: https://gerrit.causes.com/26336
Tested-by: jenkins <jenkins@causes.com>
Reviewed-by: Aaron Neyer <aaron.neyer@causes.com>
Tested-by: Aaron Neyer <aaron.neyer@causes.com>
Tidy up gemspec

I was tackling this issue:

  https://github.com/causes/mock_redis/issues/64

but had a mid-air collision with Aaron who was working on it
simultaneously here:

  https://gerrit.causes.com/26336

I've removed the hunk that adds the license, and am pushing the nearby
clean-up changes that I'd made (double quotes to singles, wrapped long
lines).

Change-Id: I0b9e00bfe0db01c5d7e083e4fa0a05ff44b8e634
Reviewed-on: https://gerrit.causes.com/26337
Tested-by: jenkins <jenkins@causes.com>
Reviewed-by: Aaron Neyer <aaron.neyer@causes.com>
Support :nx, :xx, :ex, :px options for SET command

Based on:

  https://github.com/causes/mock_redis/pull/71

with minor tweaks.

Signed-off-by: Greg Hurrell <greg@causes.com>
Change-Id: I6cc1fe8544a02e8ce673ef9fa6154c7a61ca6112
Reviewed-on: https://gerrit.causes.com/30771
Tested-by: jenkins <jenkins@causes.com>
Cut 0.10.0 release

Change-Id: If5bb6c6f20d1263b53846d1464a8d6c46232f99e
Reviewed-on: https://gerrit.causes.com/30853
Tested-by: jenkins <jenkins@causes.com>
Reviewed-by: Hao Su <hao.su@causes.com>
Raise Errors For Empty Arrays as Arguments

Redis will unwrap arguments passed as arrays, so [] becomes
nothing, as if you didn't pass an argument. This means it will raise
"ERR wrong number of arguments for ':command'" errors when an empty
array is passed to something that accepts a variable number of
arguments (eg 'lpush'). Also, for lpushx and rpushx you can only pass
one value, so it will throw that same error if you try to pass an
array of multiple items.

I added handlers for the cases mentioned above, along with
corresponding tests. The commands I updated are: lpush, lpushx,
rpush, rpushx, sadd, zadd. I don't believe this is an exhaustive list
of commands where this error pops up, but these seem to be the most
common ones.

Change-Id: Iae28adbc432fe4b18c53177b74349023602af456
Reviewed-on: https://gerrit.causes.com/33180
Tested-by: jenkins <jenkins@causes.com>
Reviewed-by: Shane da Silva <shane@causes.com>
Enable Redis service in Travis configuration

Our tests started failing with:

    Error connecting to Redis on 127.0.0.1:6379 (ECONNREFUSED)

Investigation reveals we now need to explicitly enable the Redis server
by including it in the services list.

Change-Id: I4c3b752212383b0629e3c34e51cc28b163e19c2f
Reviewed-on: https://gerrit.causes.com/33181
Tested-by: jenkins <jenkins@causes.com>
Reviewed-by: Shane da Silva <shane@causes.com>
Fix error messages for keys with wrong value type

In preparation for upgrading the version of Redis used in tests to 2.8,
it was noticed that the error message for incorrect value types of
various commands changed its prefix from 'ERR' to 'WRONGTYPE'. This is
confirmed by the release notes here:

https://raw.github.com/antirez/redis/2.8/00-RELEASENOTES

Fix the broken specs by updating the error message prefix.

Change-Id: Iea3fe537a475e9783edf6487b2cd312e0be5bb53
Reviewed-on: https://gerrit.causes.com/33196
Reviewed-by: Shane da Silva <shane@causes.com>
Tested-by: Shane da Silva <shane@causes.com>
Update TTL behavior when no key exists

In the process of moving the test suite onto Redis 2.8, change the
behavior of the `ttl` command to return -2 when the key does not exist.

From the docs at http://redis.io/commands/ttl:

Starting with Redis 2.8 the return value in case of error changed:

* The command returns -2 if the key does not exist.
* The command returns -1 if the key exists but has no associated expire.

This modifies the implementation and the associated spec to conform to
this new behavior.

Change-Id: I94b877aa4cc71b9454bc6a3f95b8185d11df505b
Reviewed-on: https://gerrit.causes.com/33197
Reviewed-by: Shane da Silva <shane@causes.com>
Tested-by: Shane da Silva <shane@causes.com>
Round start time in pexpire specs

We were seeing this test spuriously fail under JRuby 1.7.9. After some
investigation, it's clear that it has something to do with differing
precisions in the underlying objects (i.e. Java Time versus Ruby Time)
and how they are rounded.

Since this problem only occurs in JRuby and only potentially breaks
functionality at the millisecond level (e.g. the expire will be off by
+/- 1 millisecond), I'm not inclined to dig any deeper.

A simple solution is to round the starting time so that the time is
always guaranteed to be at the start of a second.

Change-Id: Ib7280cba69708afd2c71bc8b78c6a28ea287a807
Reviewed-on: https://gerrit.causes.com/33199
Reviewed-by: Shane da Silva <shane@causes.com>
Tested-by: Shane da Silva <shane@causes.com>
Add support for HINCRBYFLOAT

This commit adds HINCRBYFLOAT (available since Redis 2.6.0).
The code and specs were heavily inspired by the ones already
available for `hincrby` and `incrbyfloat`.

Change-Id: Id4c1c9be22b5f315fdbe945ab23166ca7b3e56db
Reviewed-on: https://gerrit.causes.com/33200
Reviewed-by: Shane da Silva <shane@causes.com>
Tested-by: Shane da Silva <shane@causes.com>
Update CHANGELOG and README

Update the CHANGELOG and README to reflect the new reality that tests
will only pass against Redis 2.8.4. Also record other recent changes.

Change-Id: I52f1a3b7bdf18e5c592bba403d6d634c90b83fef
Reviewed-on: https://gerrit.causes.com/33201
Reviewed-by: Shane da Silva <shane@causes.com>
Tested-by: Shane da Silva <shane@causes.com>
Add support for count in srandmember

The `count` argument was present but not used in the `srandmember`
method.

This change adds support for the `count` argument based on the
specification of `srandmember` as described on:

http://redis.io/commands/srandmember

We can't use result checking between MockRedis and Redis in the specs
because `srandmember` gives random members so we'll likely get
different results between MockRedis and Redis.

Change-Id: I639cd5ff36b3e4b1b5a5c80a50e1c261ba131b0b
Reviewed-on: https://gerrit.causes.com/33202
Reviewed-by: Shane da Silva <shane@causes.com>
Tested-by: Shane da Silva <shane@causes.com>
Cleanup srandmember implementation

Simplified implementation to use Array#sample, which does more of the
heavy lifting for us.

Change-Id: Ie4e8adbb7fb0af6b332ef16558fa5ebd28999d38
Reviewed-on: https://gerrit.causes.com/33203
Reviewed-by: Shane da Silva <shane@causes.com>
Tested-by: Shane da Silva <shane@causes.com>
Add test cases for commands run against empty zsets

This disproves the need for #47.

Change-Id: I17662e8b76c9bb925a0cb4af1cc53d06b6a619e6
Reviewed-on: https://gerrit.causes.com/33204
Reviewed-by: Shane da Silva <shane@causes.com>
Tested-by: Shane da Silva <shane@causes.com>