require 'spec_helper'

describe "#zremrangebyscore(key, min, max)" do
  before do
    @key = 'mock-redis-test:zremrangebyscore'
    @redises.zadd(@key, 1, 'Washington')
    @redises.zadd(@key, 2, 'Adams')
    @redises.zadd(@key, 3, 'Jefferson')
    @redises.zadd(@key, 4, 'Madison')
  end

  it "returns the number of elements in range" do
    @redises.zremrangebyscore(@key, 2, 3).should == 2
  end

  it "removes the elements" do
    @redises.zremrangebyscore(@key, 2, 3)
    @redises.zrange(@key, 0, -1).should == %w[Washington Madison]
  end

  # As seen in http://redis.io/commands/zremrangebyscore
  it "removes the elements for complex statements" do
    @redises.zremrangebyscore(@key, '-inf', '(4')
    @redises.zrange(@key, 0, -1).should == %w[Madison]
  end

  it_should_behave_like "a zset-only command"

  it "should throw a command error" do
    expect { @redises.zrevrangebyscore(@key, DateTime.now, '-inf') }.to raise_error(Redis::CommandError)
  end
end

require 'spec_helper'

describe "#zremrangebyscore(key, min, max)" do
  before do
    @key = 'mock-redis-test:zremrangebyscore'
    @redises.zadd(@key, 1, 'Washington')
    @redises.zadd(@key, 2, 'Adams')
    @redises.zadd(@key, 3, 'Jefferson')
    @redises.zadd(@key, 4, 'Madison')
  end

  it "returns the number of elements in range" do
    @redises.zremrangebyscore(@key, 2, 3).should == 2
  end

  it "removes the elements" do
    @redises.zremrangebyscore(@key, 2, 3)
    @redises.zrange(@key, 0, -1).should == %w[Washington Madison]
  end

  # As seen in http://redis.io/commands/zremrangebyscore
  it "removes the elements for complex statements" do
    @redises.zremrangebyscore(@key, '-inf', '(4')
    @redises.zrange(@key, 0, -1).should == %w[Madison]
  end

  it_should_behave_like "a zset-only command"

  it "throws a command error" do
    expect { @redises.zrevrangebyscore(@key, DateTime.now, '-inf') }.to raise_error(Redis::CommandError)
  end
end

Reword description in zremrangebyscore spec
Reword description in zremrangebyscore spec

"Should" is unnecessary in spec descriptions as it is implied.

Change-Id: I1e77bb758635a3107ebada7deb86c4d75ac5786d
Reviewed-on: http://gerrit.causes.com/37709
Reviewed-by: Shane da Silva <6f6e68d1df92f30cb4b3ce35260ddf94a402f33d@causes.com>
Tested-by: Shane da Silva <6f6e68d1df92f30cb4b3ce35260ddf94a402f33d@causes.com>
