Sha256: 093fcebfa181e1be589fbbe7b59d3d25a34fe75f89119a0c7fd11ad9aa278178

Contents?: true

Size: 1.72 KB

Versions: 7

Compression:

Stored size: 1.72 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
      lambda { @coll = Riak::IndexCollection.new_from_json @input }.should_not raise_error
      %w{first second third}.should == @coll
    end
    it "should accept a list of keys and a continuation" do
      @input = {
        'keys' => %w{first second third},
        'continuation' => 'examplecontinuation'
      }.to_json
      lambda { @coll = Riak::IndexCollection.new_from_json @input }.should_not raise_error
      %w{first second third}.should == @coll
      @coll.continuation.should == 'examplecontinuation'
    end
    it "should accept a list of results hashes" do
      @input = {
        'results' => [
          {'first' => 'first'},
          {'second' => 'second'},
          {'second' => 'other'}
        ]
      }.to_json

      lambda { @coll = Riak::IndexCollection.new_from_json @input }.should_not raise_error
      %w{first second other}.should == @coll
      {'first' => %w{first}, 'second' => %w{second other}}.should == @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

      lambda { @coll = Riak::IndexCollection.new_from_json @input }.should_not raise_error
      %w{first second other}.should == @coll
      @coll.continuation.should == 'examplecontinuation'
      {'first' => %w{first}, 'second' => %w{second other}}.should == @coll.with_terms
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
riak-client-1.4.5 spec/riak/index_collection_spec.rb
riak-client-1.4.4.1 spec/riak/index_collection_spec.rb
riak-client-1.4.4 spec/riak/index_collection_spec.rb
riak-client-1.4.3 spec/riak/index_collection_spec.rb
riak-client-1.4.2 spec/riak/index_collection_spec.rb
riak-client-1.4.1 spec/riak/index_collection_spec.rb
riak-client-1.4.0 spec/riak/index_collection_spec.rb