Sha256: e39270e551f122370bc4fb03266dad03fd871a9efb4ae946e54dbbdbb88248b3

Contents?: true

Size: 1.72 KB

Versions: 8

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'

describe Riak::IndexCollection do
  describe "json initialization" do
    it "accepts a list of keys" do
      @input = {
        'keys' => %w{first second third}
      }.to_json
      expect { @coll = Riak::IndexCollection.new_from_json @input }.not_to raise_error
      expect(%w{first second third}).to eq(@coll)
    end

    it "accepts a list of keys and a continuation" do
      @input = {
        'keys' => %w{first second third},
        'continuation' => 'examplecontinuation'
      }.to_json
      expect { @coll = Riak::IndexCollection.new_from_json @input }.not_to raise_error
      expect(%w{first second third}).to eq(@coll)
      expect(@coll.continuation).to eq('examplecontinuation')
    end

    it "accepts a list of results hashes" do
      @input = {
        'results' => [
          {'first' => 'first'},
          {'second' => 'second'},
          {'second' => 'other'}
        ]
      }.to_json

      expect { @coll = Riak::IndexCollection.new_from_json @input }.not_to raise_error
      expect(%w{first second other}).to eq(@coll)
      expect({'first' => %w{first}, 'second' => %w{second other}}).to eq(@coll.with_terms)
    end

    it "accepts a list of results hashes and a continuation" do
      @input = {
        'results' => [
          {'first' => 'first'},
          {'second' => 'second'},
          {'second' => 'other'}
        ],
        'continuation' => 'examplecontinuation'
      }.to_json

      expect { @coll = Riak::IndexCollection.new_from_json @input }.not_to raise_error
      expect(%w{first second other}).to eq(@coll)
      expect(@coll.continuation).to eq('examplecontinuation')
      expect({'first' => %w{first}, 'second' => %w{second other}}).to eq(@coll.with_terms)
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
riak-client-2.5.0 spec/riak/index_collection_spec.rb
riak-client-2.3.0 spec/riak/index_collection_spec.rb
riak-client-2.2.2 spec/riak/index_collection_spec.rb
riak-client-2.2.1 spec/riak/index_collection_spec.rb
riak-client-noenc-1.0.0 spec/riak/index_collection_spec.rb
riak-client-2.2.0 spec/riak/index_collection_spec.rb
riak-client-2.2.0.pre1 spec/riak/index_collection_spec.rb
riak-client-2.1.0 spec/riak/index_collection_spec.rb