spec/riak/client_spec.rb in riak-client-1.2.0 vs spec/riak/client_spec.rb in riak-client-1.4.0

- old
+ new

@@ -194,10 +194,33 @@ b.should be_kind_of(Riak::Client::ProtobuffsBackend) end end end + describe "retrieving many values" do + before :each do + @client = Riak::Client.new + @bucket = @client.bucket('foo') + @bucket.should_receive(:[]).with('value1').and_return(mock('robject')) + @bucket.should_receive(:[]).with('value2').and_return(mock('robject')) + @pairs = [ + [@bucket, 'value1'], + [@bucket, 'value2'] + ] + end + + it 'should accept an array of bucket and key pairs' do + lambda{ @client.get_many(@pairs) }.should_not raise_error + end + + it 'should return a hash of bucket/key pairs and robjects' do + @results = @client.get_many(@pairs) + @results.should be_a Hash + @results.length.should be(@pairs.length) + end + end + describe "retrieving a bucket" do before :each do @client = Riak::Client.new @backend = mock("Backend") @client.stub!(:backend).and_yield(@backend) @@ -216,10 +239,14 @@ @bucket = mock("Bucket") Riak::Bucket.should_receive(:new).with(@client, "baz").once.and_return(@bucket) @client.bucket("baz").should == @bucket @client.bucket("baz").should == @bucket end + + it "should reject buckets with zero-length names" do + expect { @client.bucket('') }.to raise_error(ArgumentError) + end end describe "listing buckets" do before do @client = Riak::Client.new @@ -241,9 +268,16 @@ it "should warn about the expense of list-buckets when warnings are not disabled" do Riak.disable_list_keys_warnings = false @backend.stub!(:list_buckets).and_return(%w{test test2}) @client.should_receive(:warn) @client.buckets + end + + it "should support a timeout option" do + @backend.should_receive(:list_buckets).with(timeout: 1234).and_return(%w{test test2}) + + buckets = @client.buckets timeout: 1234 + buckets.should have(2).items end end describe "Luwak (large-files) support" do describe "storing a file" do