riak-client 2.2.0.pre1 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +0 -2
  4. data/README.markdown +11 -7
  5. data/RELEASE_NOTES.md +29 -2
  6. data/Rakefile +5 -3
  7. data/lib/riak/bucket.rb +55 -23
  8. data/lib/riak/bucket_properties.rb +8 -1
  9. data/lib/riak/bucket_type.rb +29 -0
  10. data/lib/riak/bucket_typed/bucket.rb +15 -7
  11. data/lib/riak/client.rb +24 -8
  12. data/lib/riak/client/beefcake/bucket_properties_operator.rb +8 -8
  13. data/lib/riak/client/beefcake/crdt/set_loader.rb +1 -1
  14. data/lib/riak/client/beefcake/crdt_loader.rb +1 -1
  15. data/lib/riak/client/beefcake/crdt_operator.rb +9 -9
  16. data/lib/riak/client/beefcake/message_codes.rb +4 -0
  17. data/lib/riak/client/beefcake/message_overlay.rb +4 -0
  18. data/lib/riak/client/beefcake/messages.rb +35 -5
  19. data/lib/riak/client/beefcake/object_methods.rb +21 -13
  20. data/lib/riak/client/beefcake/protocol.rb +7 -7
  21. data/lib/riak/client/beefcake/socket.rb +2 -2
  22. data/lib/riak/client/beefcake_protobuffs_backend.rb +58 -33
  23. data/lib/riak/client/protobuffs_backend.rb +5 -5
  24. data/lib/riak/client/yokozuna.rb +3 -3
  25. data/lib/riak/core_ext/deep_dup.rb +1 -1
  26. data/lib/riak/counter.rb +10 -10
  27. data/lib/riak/crdt/base.rb +39 -21
  28. data/lib/riak/crdt/batch_counter.rb +5 -5
  29. data/lib/riak/crdt/batch_map.rb +2 -2
  30. data/lib/riak/crdt/counter.rb +7 -7
  31. data/lib/riak/crdt/inner_counter.rb +4 -4
  32. data/lib/riak/crdt/inner_flag.rb +3 -3
  33. data/lib/riak/crdt/inner_map.rb +1 -1
  34. data/lib/riak/crdt/inner_register.rb +1 -1
  35. data/lib/riak/crdt/inner_set.rb +5 -5
  36. data/lib/riak/crdt/map.rb +9 -9
  37. data/lib/riak/crdt/set.rb +10 -10
  38. data/lib/riak/crdt/typed_collection.rb +39 -36
  39. data/lib/riak/errors/base.rb +1 -1
  40. data/lib/riak/errors/crdt_error.rb +20 -0
  41. data/lib/riak/errors/search_error.rb +6 -0
  42. data/lib/riak/index_collection.rb +1 -1
  43. data/lib/riak/link.rb +5 -3
  44. data/lib/riak/locale/en.yml +5 -1
  45. data/lib/riak/map_reduce.rb +7 -7
  46. data/lib/riak/map_reduce/filter_builder.rb +2 -2
  47. data/lib/riak/map_reduce/phase.rb +2 -2
  48. data/lib/riak/preflist_item.rb +7 -0
  49. data/lib/riak/rcontent.rb +8 -8
  50. data/lib/riak/robject.rb +27 -14
  51. data/lib/riak/search.rb +1 -0
  52. data/lib/riak/search/index.rb +17 -3
  53. data/lib/riak/search/query.rb +14 -6
  54. data/lib/riak/search/result_collection.rb +56 -3
  55. data/lib/riak/search/result_document.rb +71 -1
  56. data/lib/riak/search/schema.rb +6 -6
  57. data/lib/riak/secondary_index.rb +20 -12
  58. data/lib/riak/serializers.rb +0 -1
  59. data/lib/riak/util/escape.rb +2 -2
  60. data/lib/riak/util/translation.rb +1 -2
  61. data/lib/riak/version.rb +1 -1
  62. data/lib/riak/walk_spec.rb +67 -32
  63. data/riak-client.gemspec +5 -4
  64. data/spec/integration/riak/bucket_types_spec.rb +35 -5
  65. data/spec/integration/riak/conflict_resolution_spec.rb +1 -1
  66. data/spec/integration/riak/counters_spec.rb +1 -1
  67. data/spec/integration/riak/crdt/configuration_spec.rb +37 -0
  68. data/spec/integration/riak/crdt_search_spec.rb +176 -0
  69. data/spec/integration/riak/crdt_spec.rb +9 -33
  70. data/spec/integration/riak/crdt_validation/map_spec.rb +4 -4
  71. data/spec/integration/riak/crdt_validation/set_spec.rb +13 -13
  72. data/spec/integration/riak/preflist_spec.rb +31 -0
  73. data/spec/integration/riak/protobuffs/interrupted_request_spec.rb +2 -2
  74. data/spec/integration/riak/protobuffs_backends_spec.rb +9 -2
  75. data/spec/integration/riak/search_spec.rb +3 -3
  76. data/spec/integration/riak/secondary_index_spec.rb +3 -3
  77. data/spec/integration/riak/security_spec.rb +7 -7
  78. data/spec/integration/yokozuna/queries_spec.rb +1 -1
  79. data/spec/riak/beefcake_protobuffs_backend/bucket_properties_operator_spec.rb +9 -9
  80. data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +9 -9
  81. data/spec/riak/beefcake_protobuffs_backend/protocol_spec.rb +5 -5
  82. data/spec/riak/beefcake_protobuffs_backend_spec.rb +8 -8
  83. data/spec/riak/bucket_properties_spec.rb +27 -6
  84. data/spec/riak/bucket_spec.rb +5 -5
  85. data/spec/riak/bucket_type_spec.rb +21 -5
  86. data/spec/riak/bucket_typed/bucket_spec.rb +62 -0
  87. data/spec/riak/client_spec.rb +36 -18
  88. data/spec/riak/counter_spec.rb +4 -4
  89. data/spec/riak/crdt/counter_spec.rb +2 -2
  90. data/spec/riak/crdt/inner_flag_spec.rb +2 -2
  91. data/spec/riak/crdt/inner_map_spec.rb +4 -4
  92. data/spec/riak/crdt/inner_register_spec.rb +1 -1
  93. data/spec/riak/crdt/map_spec.rb +4 -4
  94. data/spec/riak/crdt/shared_examples.rb +5 -5
  95. data/spec/riak/crdt/typed_collection_spec.rb +21 -21
  96. data/spec/riak/map_reduce/filter_builder_spec.rb +2 -2
  97. data/spec/riak/map_reduce/phase_spec.rb +4 -4
  98. data/spec/riak/map_reduce_spec.rb +60 -42
  99. data/spec/riak/multiget_spec.rb +2 -2
  100. data/spec/riak/robject_spec.rb +55 -14
  101. data/spec/riak/search/index_spec.rb +12 -2
  102. data/spec/riak/search/query_spec.rb +4 -4
  103. data/spec/riak/search/result_collection_spec.rb +6 -4
  104. data/spec/riak/search/result_document_spec.rb +52 -9
  105. data/spec/riak/search/schema_spec.rb +2 -2
  106. data/spec/riak/secondary_index_spec.rb +6 -6
  107. data/spec/riak/serializers_spec.rb +27 -10
  108. data/spec/riak/walk_spec_spec.rb +10 -6
  109. data/spec/spec_helper.rb +11 -2
  110. data/spec/support/crdt_search_config.rb +112 -0
  111. data/spec/support/crdt_search_fixtures.rb +42 -0
  112. data/spec/support/search_config.rb +7 -5
  113. data/spec/support/search_corpus_setup.rb +2 -2
  114. data/spec/support/test_client.rb +2 -2
  115. data/spec/support/unified_backend_examples.rb +5 -5
  116. data/spec/support/version_filter.rb +5 -3
  117. data/spec/support/wait_until.rb +9 -3
  118. metadata +36 -13
  119. data/spec/riak/bucket_typed/bucket.rb +0 -43
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+ require 'riak'
3
+
4
+ describe 'Preflist', integration: true, test_client: true do
5
+ let(:bucket){ random_bucket }
6
+ let(:robject) do
7
+ bucket.get_or_new(random_key).tap do |robj|
8
+ robj.data = 'asdf'
9
+ robj.store
10
+ end
11
+ end
12
+
13
+ matcher :be_a_preflist do
14
+ match do |actual|
15
+ actual.is_a?(Array) &&
16
+ actual.first.is_a?(Riak::PreflistItem)
17
+ end
18
+ end
19
+
20
+ it 'is available from RObjects' do
21
+ expect(robject.preflist).to be_a_preflist
22
+ end
23
+
24
+ it 'is available from Buckets' do
25
+ expect(bucket.get_preflist robject.key).to be_a_preflist
26
+ end
27
+
28
+ it 'is available from the Client' do
29
+ expect(test_client.get_preflist bucket.name, robject.key).to be_a_preflist
30
+ end
31
+ end
@@ -5,7 +5,7 @@ describe 'Protocol Buffers', test_client: true do
5
5
  describe 'interrupted requests' do
6
6
 
7
7
  let(:bucket){ random_bucket 'interrupted_requests' }
8
-
8
+
9
9
  before do
10
10
  first = bucket.new 'first'
11
11
  first.data = 'first'
@@ -28,6 +28,6 @@ describe 'Protocol Buffers', test_client: true do
28
28
  end.to raise_error Timeout::Error
29
29
 
30
30
  expect(bucket.get('second').data).to eq 'second'
31
- end
31
+ end
32
32
  end
33
33
  end
@@ -21,9 +21,16 @@ describe "Protocol Buffers", test_client: true do
21
21
 
22
22
  it 'returns documents with UTF-8 fields (GH #75)' do
23
23
  utf8 = Encoding.find('UTF-8')
24
- results = @backend.search @search_bucket.name, 'fearless elephant rushed', df: 'text'
24
+ results = @backend.search(
25
+ @search_bucket.name,
26
+ 'fearless elephant rushed',
27
+ df: 'text'
28
+ )
25
29
  results['docs'].each do |d|
26
- d.each {|(k,v)| expect(k.encoding).to eq(utf8); expect(v.encoding).to eq(utf8) }
30
+ d.each do |(k, v)|
31
+ expect(k.encoding).to eq(utf8)
32
+ expect(v.encoding).to eq(utf8)
33
+ end
27
34
  end
28
35
  end
29
36
  end
@@ -17,7 +17,7 @@ describe 'Object-oriented Search API', test_client: true, integration: true, sea
17
17
  it 'performs queries' do
18
18
  results = nil
19
19
  expect{ results = subject.results }.to_not raise_error
20
- expect(results.raw).to_not be_empty
20
+ expect(results.raw).to_not be_empty
21
21
  expect(results).to_not be_empty
22
22
  end
23
23
 
@@ -34,7 +34,7 @@ describe 'Object-oriented Search API', test_client: true, integration: true, sea
34
34
  let(:index){ Riak::Search::Index.new test_client, index_name }
35
35
  let(:query){ Riak::Search::Query.new test_client, index, term }
36
36
  subject { query.results }
37
-
37
+
38
38
  it 'exposes search-result documents' do
39
39
  expect(subject).to_not be_empty
40
40
 
@@ -50,7 +50,7 @@ describe 'Object-oriented Search API', test_client: true, integration: true, sea
50
50
 
51
51
  it 'exposes RObjects' do
52
52
  expect(subject).to_not be_empty
53
-
53
+
54
54
  expect(first = subject.first).to be_a Riak::RObject
55
55
  expect(first).to eq subject.docs.first.robject
56
56
 
@@ -18,7 +18,7 @@ describe 'Secondary indexes', test_client: true, integration: true do
18
18
  end
19
19
 
20
20
  it "finds keys for a range query" do
21
- expect(bucket.get_index('index_int', 19..21)).to match_array(["19","20", "21"])
21
+ expect(bucket.get_index('index_int', 19..21)).to match_array(%w(19 20 21))
22
22
  end
23
23
 
24
24
  it "returns an empty array for a query that does not match any keys" do
@@ -29,7 +29,7 @@ describe 'Secondary indexes', test_client: true, integration: true do
29
29
  results = nil
30
30
  expect do
31
31
  results = bucket.get_index('index_int',
32
- 19..21,
32
+ 19..21,
33
33
  return_terms: true)
34
34
  end.to_not raise_error
35
35
 
@@ -41,7 +41,7 @@ describe 'Secondary indexes', test_client: true, integration: true do
41
41
  results = nil
42
42
  expect do
43
43
  results = bucket.get_index('index_bin',
44
- '19'..'21',
44
+ '19'..'21',
45
45
  return_terms: true,
46
46
  term_regex: '20')
47
47
  end.to_not raise_error
@@ -17,7 +17,7 @@ describe 'Secure Protobuffs', test_client: true, integration: true do
17
17
  with_auth_config[:authentication] = { user: 'user', password: 'password' }
18
18
 
19
19
  secure_client = Riak::Client.new with_auth_config
20
-
20
+
21
21
  expect{ secure_client.ping }.to raise_error(Riak::TlsError)
22
22
  end
23
23
  end
@@ -59,13 +59,13 @@ describe 'Secure Protobuffs', test_client: true, integration: true do
59
59
  it "refuses to connect if the server cert is revoked" do
60
60
  revoked_auth_config = config.dup
61
61
  revoked_auth_config[:authentication] = revoked_auth_config[:authentication].dup
62
-
62
+
63
63
  revoked_auth_config[:authentication][:crl_file] =
64
- File.expand_path(File.join('..',
65
- '..',
64
+ File.expand_path(File.join('..',
65
+ '..',
66
66
  '..',
67
- 'support',
68
- 'certs',
67
+ 'support',
68
+ 'certs',
69
69
  'server.crl'),
70
70
  __FILE__)
71
71
  revoked_auth_config[:authentication][:crl] = true
@@ -81,7 +81,7 @@ describe 'Secure Protobuffs', test_client: true, integration: true do
81
81
  describe 'with client certificate security enabled on Riak', yes_security: true do
82
82
  it 'connects normally with authentication configured' do
83
83
  client_cert_config = config.dup
84
- client_cert_config[:authentication] =
84
+ client_cert_config[:authentication] =
85
85
  client_cert_config[:authentication].dup
86
86
 
87
87
  client_cert_config[:authentication][:client_ca] = client_cert_config[:authentication]['ca_file']
@@ -22,7 +22,7 @@ describe "Yokozuna queries", test_client: true, integration: true do
22
22
  end
23
23
 
24
24
  @o1 = build_json_obj(@bucket, "cat", {"cat_s"=>"Lela"})
25
- @o2 = build_json_obj(@bucket, "docs", {"dog_ss"=>["Einstein", "Olive"]})
25
+ @o2 = build_json_obj(@bucket, "docs", {"dog_ss"=>%w(Einstein Olive)})
26
26
  build_json_obj(@bucket, "Z", {"username_s"=>"Z", "name_s"=>"ryan", "age_i"=>30})
27
27
  build_json_obj(@bucket, "R", {"username_s"=>"R", "name_s"=>"eric", "age_i"=>34})
28
28
  build_json_obj(@bucket, "F", {"username_s"=>"F", "name_s"=>"bryan fink", "age_i"=>32})
@@ -4,7 +4,7 @@ Riak::Client::BeefcakeProtobuffsBackend.configured?
4
4
  describe Riak::Client::BeefcakeProtobuffsBackend::BucketPropertiesOperator do
5
5
  let(:backend_class){ Riak::Client::BeefcakeProtobuffsBackend }
6
6
  let(:backend) { instance_double('Riak::Client::BeefcakeProtobuffsBackend') }
7
-
7
+
8
8
  let(:protocol) do
9
9
  instance_double('Riak::Client::BeefcakeProtobuffsBackend::Protocol').
10
10
  tap do |p|
@@ -50,16 +50,16 @@ describe Riak::Client::BeefcakeProtobuffsBackend::BucketPropertiesOperator do
50
50
  let(:get_bucket_request) do
51
51
  backend_class::RpbGetBucketReq.new bucket: bucket_name
52
52
  end
53
-
53
+
54
54
  let(:get_bucket_response) do
55
55
  backend_class::RpbGetBucketResp.
56
56
  new(props: test_props)
57
57
  end
58
58
 
59
- let(:get_bucket_expectation) do
59
+ let(:get_bucket_expectation) do
60
60
  expect(protocol).to receive(:write).
61
61
  with(:GetBucketReq, get_bucket_request)
62
-
62
+
63
63
  expect(protocol).to receive(:expect).
64
64
  with(:GetBucketResp,
65
65
  backend_class::RpbGetBucketResp).
@@ -118,11 +118,11 @@ describe Riak::Client::BeefcakeProtobuffsBackend::BucketPropertiesOperator do
118
118
  with(:SetBucketResp)
119
119
 
120
120
  # support both strings and symbols for quorum names
121
- write_props = {
121
+ write_props = {
122
122
  pr: 'one',
123
123
  r: :quorum,
124
124
  w: 'all',
125
- pw: :default,
125
+ pw: :default,
126
126
  dw: 0,
127
127
  rw: 1
128
128
  }
@@ -135,7 +135,7 @@ describe Riak::Client::BeefcakeProtobuffsBackend::BucketPropertiesOperator do
135
135
  it 'rubyfies' do
136
136
  expect(protocol).to receive(:write).
137
137
  with(:GetBucketReq, get_bucket_request)
138
-
138
+
139
139
  expect(protocol).to receive(:expect).
140
140
  with(:GetBucketResp,
141
141
  backend_class::RpbGetBucketResp).
@@ -175,7 +175,7 @@ describe Riak::Client::BeefcakeProtobuffsBackend::BucketPropertiesOperator do
175
175
  expect(protocol).to receive(:expect).
176
176
  with(:SetBucketResp)
177
177
 
178
- write_props = {
178
+ write_props = {
179
179
  precommit: { mod: 'validate_json', fun: 'validate' },
180
180
  postcommit: ['piper']
181
181
  }
@@ -216,7 +216,7 @@ describe Riak::Client::BeefcakeProtobuffsBackend::BucketPropertiesOperator do
216
216
  expect(protocol).to receive(:expect).
217
217
  with(:SetBucketResp)
218
218
 
219
- write_props = {
219
+ write_props = {
220
220
  linkfun: { mod: 'nachos', fun: 'galacticos' }
221
221
  }
222
222
 
@@ -7,7 +7,7 @@ describe Riak::Client::BeefcakeProtobuffsBackend::CrdtOperator do
7
7
  let(:backend){ double 'beefcake protobuffs backend' }
8
8
  subject { described_class.new backend }
9
9
 
10
-
10
+
11
11
  describe 'operating on a counter' do
12
12
  let(:increment){ 5 }
13
13
  let(:operation) do
@@ -16,10 +16,10 @@ describe Riak::Client::BeefcakeProtobuffsBackend::CrdtOperator do
16
16
  op.value = increment
17
17
  end
18
18
  end
19
-
19
+
20
20
  it 'serializes a counter operation into protobuffs' do
21
21
  result = subject.serialize operation
22
-
22
+
23
23
  expect(result).to be_a backend_class::DtOp
24
24
  expect(result.counter_op).to be_a backend_class::CounterOp
25
25
  expect(result.counter_op.increment).to eq increment
@@ -29,7 +29,7 @@ describe Riak::Client::BeefcakeProtobuffsBackend::CrdtOperator do
29
29
  result = subject.serialize [operation, operation]
30
30
 
31
31
  expect{result.encode}.to_not raise_error
32
-
32
+
33
33
  expect(result).to be_a backend_class::DtOp
34
34
  expect(result.counter_op).to be_a backend_class::CounterOp
35
35
  expect(result.counter_op.increment).to eq (increment * 2)
@@ -53,7 +53,7 @@ describe Riak::Client::BeefcakeProtobuffsBackend::CrdtOperator do
53
53
  result = subject.serialize operation
54
54
 
55
55
  expect{result.encode}.to_not raise_error
56
-
56
+
57
57
  expect(result).to be_a backend_class::DtOp
58
58
  expect(result.set_op).to be_a backend_class::SetOp
59
59
  expect(result.set_op.adds).to eq [added_element]
@@ -74,7 +74,7 @@ describe Riak::Client::BeefcakeProtobuffsBackend::CrdtOperator do
74
74
  end
75
75
 
76
76
  result = subject.serialize map_op
77
-
77
+
78
78
  expect{result.encode}.to_not raise_error
79
79
 
80
80
  expect(result).to be_a backend_class::DtOp
@@ -84,7 +84,7 @@ describe Riak::Client::BeefcakeProtobuffsBackend::CrdtOperator do
84
84
  expect(map_update.counter_op).to be_a backend_class::CounterOp
85
85
  expect(map_update.counter_op.increment).to eq 12345
86
86
  end
87
-
87
+
88
88
  it 'serializes inner flag operations' do
89
89
  flag_op = Riak::Crdt::Operation::Update.new.tap do |op|
90
90
  op.name = 'inner_flag'
@@ -168,7 +168,7 @@ describe Riak::Client::BeefcakeProtobuffsBackend::CrdtOperator do
168
168
  expect(map_delete.name).to eq 'inner_register'
169
169
  expect(map_delete.type).to eq backend_class::MapField::MapFieldType::REGISTER
170
170
  end
171
-
171
+
172
172
  it 'serializes inner set operations' do
173
173
  set_op = Riak::Crdt::Operation::Update.new.tap do |op|
174
174
  op.name = 'inner_set'
@@ -190,7 +190,7 @@ describe Riak::Client::BeefcakeProtobuffsBackend::CrdtOperator do
190
190
  expect(map_update).to be_a backend_class::MapUpdate
191
191
  expect(map_update.set_op.adds).to eq 'added_member'
192
192
  end
193
-
193
+
194
194
  it 'serializes inner map operations' do
195
195
  register_op = Riak::Crdt::Operation::Update.new.tap do |op|
196
196
  op.name = 'inner_inner_register'
@@ -84,7 +84,7 @@ describe Riak::Client::BeefcakeProtobuffsBackend::Protocol do
84
84
  and_return(message_str)
85
85
 
86
86
  code, payload = subject.receive
87
-
87
+
88
88
  expect(code).to eq name
89
89
  expect(payload).to eq message_str
90
90
  end
@@ -111,7 +111,7 @@ describe Riak::Client::BeefcakeProtobuffsBackend::Protocol do
111
111
  message_len = message_str.length
112
112
  name = :CounterGetResp
113
113
  header = [message_len + 1, codes.index(name)].pack 'NC'
114
-
114
+
115
115
  expect(socket).to receive(:read).
116
116
  ordered.
117
117
  with(5).
@@ -120,7 +120,7 @@ describe Riak::Client::BeefcakeProtobuffsBackend::Protocol do
120
120
  ordered.
121
121
  with(message_len).
122
122
  and_return(message_str)
123
-
123
+
124
124
  payload = subject.expect name, message.class
125
125
 
126
126
  expect(payload).to eq message
@@ -149,7 +149,7 @@ describe Riak::Client::BeefcakeProtobuffsBackend::Protocol do
149
149
  message_len = message_str.length
150
150
  name = :CounterGetResp
151
151
  header = [message_len + 1, codes.index(name)].pack 'NC'
152
-
152
+
153
153
  expect(socket).to receive(:read).
154
154
  ordered.
155
155
  with(5).
@@ -171,7 +171,7 @@ describe Riak::Client::BeefcakeProtobuffsBackend::Protocol do
171
171
  message_len = message_str.length
172
172
  name = :ErrorResp
173
173
  header = [message_len + 1, codes.index(name)].pack 'NC'
174
-
174
+
175
175
  expect(socket).to receive(:read).
176
176
  ordered.
177
177
  with(5).
@@ -28,13 +28,13 @@ describe Riak::Client::BeefcakeProtobuffsBackend do
28
28
  errcode: 0)
29
29
  )
30
30
  )
31
-
31
+
32
32
  expect{ backend.get_index 'bucket', 'words', 'asdf' }.to raise_error /Secondary indexes aren't supported/
33
33
  # '
34
34
  end
35
-
35
+
36
36
  context 'when streaming' do
37
- it "streams when a block is given" do
37
+ it "streams when a block is given" do
38
38
  expect(protocol).to receive(:write) do |msg, req|
39
39
  expect(msg).to eq(:IndexReq)
40
40
  expect(req[:stream]).to eq(true)
@@ -43,15 +43,15 @@ describe Riak::Client::BeefcakeProtobuffsBackend do
43
43
  and_return(Riak::Client::BeefcakeProtobuffsBackend::RpbIndexResp.new keys: %w{'asdf'}, done: true)
44
44
 
45
45
  blk = proc{:asdf}
46
-
46
+
47
47
  backend.get_index('bucket', 'words', 'asdf'..'hjkl', &blk)
48
48
  end
49
49
 
50
50
  it "sends batches of results to the block" do
51
51
  expect(protocol).to receive(:write)
52
-
52
+
53
53
  response_sets = [%w{asdf asdg asdh}, %w{gggg gggh gggi}]
54
- response_messages = response_sets.map do |s|
54
+ response_messages = response_sets.map do |s|
55
55
  Riak::Client::BeefcakeProtobuffsBackend::RpbIndexResp.new keys: s
56
56
  end
57
57
  response_messages.last.done = true
@@ -61,7 +61,7 @@ describe Riak::Client::BeefcakeProtobuffsBackend do
61
61
  block_body = double 'block'
62
62
  expect(block_body).to receive(:check).with(response_sets.first).once
63
63
  expect(block_body).to receive(:check).with(response_sets.last).once
64
-
64
+
65
65
  blk = proc {|m| block_body.check m }
66
66
 
67
67
  backend.get_index 'bucket', 'words', 'asdf'..'hjkl', &blk
@@ -80,7 +80,7 @@ describe Riak::Client::BeefcakeProtobuffsBackend do
80
80
  )
81
81
  expect(protocol).to receive(:expect).
82
82
  and_return(response_message)
83
-
83
+
84
84
  results = backend.get_index 'bucket', 'words', 'asdf'..'hjkl'
85
85
  expect(results).to eq(%w{asdf asdg asdh})
86
86
  end
@@ -8,10 +8,12 @@ describe Riak::BucketProperties do
8
8
  allow(client).to receive(:backend).and_yield be
9
9
  end
10
10
  end
11
-
11
+
12
12
  let(:props_operator) do
13
- instance_double('Riak::Client::BeefcakeProtobuffsBackend::BucketPropertiesOperator').
14
- tap do |po|
13
+ Riak::Client::BeefcakeProtobuffsBackend.configured?
14
+ instance_double(
15
+ 'Riak::Client::BeefcakeProtobuffsBackend::BucketPropertiesOperator'
16
+ ).tap do |po|
15
17
  allow(backend).to receive(:bucket_properties_operator).
16
18
  and_return(po)
17
19
  end
@@ -30,6 +32,15 @@ describe Riak::BucketProperties do
30
32
  end
31
33
  end
32
34
 
35
+ let(:index_name){ 'index_name' }
36
+
37
+ let(:index) do
38
+ instance_double('Riak::Search::Index').tap do |i|
39
+ allow(i).to receive(:name).and_return(index_name)
40
+ allow(i).to receive(:is_a?).with(Riak::Search::Index).and_return(true)
41
+ end
42
+ end
43
+
33
44
  subject{ described_class.new bucket }
34
45
 
35
46
  it 'is initialized with a bucket' do
@@ -61,6 +72,16 @@ describe Riak::BucketProperties do
61
72
  subject.store
62
73
  end
63
74
 
75
+ it 'unwraps index objects into names' do
76
+ expect(props_operator).to receive(:get).
77
+ with(bucket).
78
+ and_return('allow_mult' => true)
79
+
80
+ expect{ subject['search_index'] = index }.to_not raise_error
81
+
82
+ expect(subject['search_index']).to eq index_name
83
+ end
84
+
64
85
  it 'merges properties from hashes' do
65
86
  expect(props_operator).to receive(:get).
66
87
  with(bucket).
@@ -70,7 +91,7 @@ describe Riak::BucketProperties do
70
91
 
71
92
  property_hash = { 'allow_mult' => false }
72
93
  expect{ subject.merge! property_hash }.to_not raise_error
73
-
94
+
74
95
  expect(props_operator).to receive(:put).
75
96
  with(bucket, hash_including('allow_mult' => false))
76
97
 
@@ -89,7 +110,7 @@ describe Riak::BucketProperties do
89
110
  instance_variable_set :@cached_props, { 'allow_mult' => false}
90
111
 
91
112
  expect{ subject.merge! other_props }.to_not raise_error
92
-
113
+
93
114
  expect(props_operator).to receive(:put).
94
115
  with(bucket, hash_including('allow_mult' => false))
95
116
 
@@ -100,7 +121,7 @@ describe Riak::BucketProperties do
100
121
  expect(props_operator).to receive(:get).
101
122
  with(bucket).
102
123
  and_return('allow_mult' => true)
103
-
124
+
104
125
  expect(subject['allow_mult']).to be
105
126
 
106
127
  expect(props_operator).to receive(:get).