Sha256: e9d63255c6a5ef9c19beed764fc55c49317b7052564e62b8807aaaa39e77dd24

Contents?: true

Size: 1.47 KB

Versions: 3

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'

describe Riak::TimeSeries::List do
  subject { described_class.new client, table_name }
  let(:table_name){ 'GeoCheckin' }
  let(:client){ instance_double('Riak::Client') }
  let(:key){ double 'key' }
  let(:backend) do
    instance_double('Riak::Client::BeefcakeProtobuffsBackend').tap do |be|
      allow(client).to receive(:backend).and_yield be
    end
  end
  let(:operator) do
    Riak::Client::BeefcakeProtobuffsBackend.configured?
    instance_double(
      'Riak::Client::BeefcakeProtobuffsBackend::TimeSeriesListOperator'
    ).tap do |op|
      allow(backend).to receive(:time_series_list_operator).
                         and_return(op)
    end
  end

  let(:list_results) do
    Riak::TimeSeries::Collection.new.tap do |buf|
      %w{family series timestamp}
    end
  end

  it 'initializes with client and table name' do
    expect{ described_class.new client, table_name }.to_not raise_error
    expect{ described_class.new client }.to raise_error ArgumentError
  end

  it 'passes a block to the operator' do
    streamer = proc { double 'block contents' }

    expect(operator).to receive(:list).with(table_name, streamer, timeout: nil)

    subject.issue! &streamer
  end

  it 'returns a list of results' do
    expect(operator).to receive(:list).
                         with(table_name, nil, timeout: nil).
                         and_return(list_results)

    expect(subject.issue!).to eq list_results
    expect(subject.results).to eq list_results
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
riak-client-2.3.2 spec/riak/time_series/listing_spec.rb
riak-client-2.3.1 spec/riak/time_series/listing_spec.rb
riak-client-2.3.0 spec/riak/time_series/listing_spec.rb