Sha256: f8fb7e8e62e621db105a24b8b0ad28313c0b4f3592ea9a117f6fd4ed5f88121b

Contents?: true

Size: 1.45 KB

Versions: 17

Compression:

Stored size: 1.45 KB

Contents

shared_examples_for "a zset-only command" do
  it "raises an error for non-zset values" do
    key = 'mock-redis-test:zset-only'

    method = method_from_description
    args = args_for_method(method).unshift(key)

    @redises.set(key, 1)
    lambda do
      @redises.send(method, *args)
    end.should raise_error(RuntimeError)
  end
end

shared_examples_for "arg 1 is a score" do
  before { @_arg_index = 1 }
  it_should_behave_like "arg N is a score"
end

shared_examples_for "arg 2 is a score" do
  before { @_arg_index = 2 }
  it_should_behave_like "arg N is a score"
end

shared_examples_for "arg N is a score" do
  before do
    key = 'mock-redis-test:zset-only'

    @method = method_from_description
    @args = args_for_method(@method).unshift(key)
  end

  it "is okay with positive ints" do
    @args[@_arg_index] = 1
    lambda { @redises.send(@method, *@args) }.should_not raise_error
  end

  it "is okay with negative ints" do
    @args[@_arg_index] = -1
    lambda { @redises.send(@method, *@args) }.should_not raise_error
  end

  it "is okay with positive floats" do
    @args[@_arg_index] = 1.5
    lambda { @redises.send(@method, *@args) }.should_not raise_error
  end

  it "is okay with negative floats" do
    @args[@_arg_index] = 1.5
    lambda { @redises.send(@method, *@args) }.should_not raise_error
  end

  it "rejects non-numbers" do
    @args[@_arg_index] = 'foo'
    lambda { @redises.send(@method, *@args) }.should raise_error(RuntimeError)
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
mock_redis-0.5.4 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.5.3 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.5.2 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.5.1 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.5.0 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.4.1 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.4.0 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.3.0 spec/support/shared_examples/only_operates_on_zsets.rb
ryansch-mock_redis-0.3.0 spec/support/shared_examples/only_operates_on_zsets.rb
ryansch-mock_redis-0.2.0.2 spec/support/shared_examples/only_operates_on_zsets.rb
ryansch-mock_redis-0.2.0.1 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.2.0 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.1.2 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.1.1 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.1.0 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.0.2 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.0.1 spec/support/shared_examples/only_operates_on_zsets.rb