Sha256: 43a910c07cd8ab534216e9e6291aff6ae95d041fb744eacca79f647b1855c0f1

Contents?: true

Size: 1.75 KB

Versions: 3

Compression:

Stored size: 1.75 KB

Contents

require 'spec_helper'

describe Riak::IndexCollection do
  describe "json initialization" do
    it "should accept 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 "should accept 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 "should accept 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 "should accept 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

3 entries across 3 versions & 1 rubygems

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