Sha256: aded1b769fb11d4dc4b16ad57033d904c11cae30f746a61b901070e1af92a606

Contents?: true

Size: 1.78 KB

Versions: 5

Compression:

Stored size: 1.78 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

5 entries across 5 versions & 1 rubygems

Version Path
riak-client-2.4.1 spec/riak/index_collection_spec.rb
riak-client-2.4.0 spec/riak/index_collection_spec.rb
riak-client-2.4.0.pre1 spec/riak/index_collection_spec.rb
riak-client-2.3.2 spec/riak/index_collection_spec.rb
riak-client-2.3.1 spec/riak/index_collection_spec.rb