Sha256: e827c70185634ccabaadccd77de928cf89d35100ab6dab7d98029ac0b51c498a
Contents?: true
Size: 1.68 KB
Versions: 21
Compression:
Stored size: 1.68 KB
Contents
shared_examples_for "a sortable" do it 'returns empty array on nil' do @redises.sort(nil).should == [] end context 'ordering' do it 'orders ascending by default' do @redises.sort(@key).should == ['1', '2'] end it 'orders by descending when specified' do @redises.sort(@key, :order => "DESC").should == ['2', '1'] end end context 'projections' do it 'projects element when :get is "#"' do @redises.sort(@key, :get => '#').should == ['1', '2'] end it 'projects through a key pattern' do @redises.sort(@key, :get => 'mock-redis-test:values_*').should == ['a', 'b'] end it 'projects through a key pattern and reflects element' do @redises.sort(@key, :get => ['#', 'mock-redis-test:values_*']).should == [['1', 'a'], ['2', 'b']] end it 'projects through a hash key pattern' do @redises.sort(@key, :get => 'mock-redis-test:hash_*->key').should == ['x', 'y'] end end context 'weights' do it 'weights by projecting through a key pattern' do @redises.sort(@key, :by => "mock-redis-test:weight_*").should == ['2', '1'] end it 'weights by projecting through a key pattern and a specific order' do @redises.sort(@key, :order => "DESC", :by => "mock-redis-test:weight_*").should == ['1', '2'] end end context 'limit' do it 'only returns requested window in the enumerable' do @redises.sort(@key, :limit => [0, 1]).should == ['1'] end end context 'store' do it 'stores into another key' do @redises.sort(@key, :store => "mock-redis-test:some_bucket").should == 2 @redises.lrange("mock-redis-test:some_bucket", 0, -1).should == ['1', '2'] end end end
Version data entries
21 entries across 21 versions & 1 rubygems