Sha256: 09d60c2c759c04783662b6cc42f5c19187a08615c1fac22cccdfc0418fdd43a0

Contents?: true

Size: 1.49 KB

Versions: 13

Compression:

Stored size: 1.49 KB

Contents

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

    method = method_from_description(example)
    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 |example|
    key = 'mock-redis-test:zset-only'

    @method = method_from_description(example)
    @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

13 entries across 13 versions & 1 rubygems

Version Path
mock_redis-0.19.0 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.18.0 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.17.3 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.17.2 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.17.1 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.17.0 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.16.1 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.16.0 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.15.4 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.15.3 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.15.2 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.15.1 spec/support/shared_examples/only_operates_on_zsets.rb
mock_redis-0.15.0 spec/support/shared_examples/only_operates_on_zsets.rb