Sha256: ff2ed9210a8140b1468936eb5a0b44ec46650a3fb0c7ee2532ccb69c720f7e22

Contents?: true

Size: 977 Bytes

Versions: 3

Compression:

Stored size: 977 Bytes

Contents

require 'spec_helper'

describe Riak::ListBuckets do
  before :each do
    @client = Riak::Client.new
    @backend = double 'backend'
    @fake_pool = double 'connection pool'
    allow(@fake_pool).to receive(:take).and_yield(@backend)

    @expect_list = expect(@backend).to receive(:list_buckets)

    @client.instance_variable_set :@protobuffs_pool, @fake_pool
  end

  describe "non-streaming" do
    it 'should call the backend without a block' do
      @expect_list.with({}).and_return(%w{a b c d})

      @client.list_buckets
    end
  end

  describe "streaming" do
    it 'should call the backend with a block' do
      @expect_list.
        and_yield(%w{abc abd abe}).
        and_yield(%w{bbb ccc ddd})

      @yielded = []

      @client.list_buckets do |bucket|
        @yielded << bucket
      end

      @yielded.each do |b|
        expect(b).to be_a Riak::Bucket
      end
      expect(@yielded.map(&:name)).to eq(%w{abc abd abe bbb ccc ddd})
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
riak-client-2.0.0 spec/riak/list_buckets_spec.rb
riak-client-2.0.0.rc2 spec/riak/list_buckets_spec.rb
riak-client-2.0.0.rc1 spec/riak/list_buckets_spec.rb