riak-client 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/README.markdown +55 -12
  3. data/RELEASE_NOTES.md +20 -1
  4. data/lib/riak.rb +1 -0
  5. data/lib/riak/client.rb +2 -1
  6. data/lib/riak/client/beefcake/crdt/counter_loader.rb +18 -0
  7. data/lib/riak/client/beefcake/crdt/map_loader.rb +64 -0
  8. data/lib/riak/client/beefcake/crdt/set_loader.rb +18 -0
  9. data/lib/riak/client/beefcake/crdt_loader.rb +16 -59
  10. data/lib/riak/client/beefcake/crdt_operator.rb +2 -1
  11. data/lib/riak/client/instrumentation.rb +19 -0
  12. data/lib/riak/crdt/base.rb +16 -0
  13. data/lib/riak/errors/backend_creation.rb +9 -0
  14. data/lib/riak/instrumentation.rb +6 -0
  15. data/lib/riak/version.rb +1 -1
  16. data/riak-client.gemspec +3 -2
  17. data/spec/integration/riak/counters_spec.rb +1 -1
  18. data/spec/integration/riak/crdt_spec.rb +68 -23
  19. data/spec/integration/riak/protobuffs_backends_spec.rb +1 -1
  20. data/spec/integration/riak/threading_spec.rb +4 -4
  21. data/spec/integration/yokozuna/index_spec.rb +5 -5
  22. data/spec/integration/yokozuna/queries_spec.rb +15 -16
  23. data/spec/integration/yokozuna/schema_spec.rb +2 -2
  24. data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +8 -8
  25. data/spec/riak/beefcake_protobuffs_backend/object_methods_spec.rb +1 -1
  26. data/spec/riak/beefcake_protobuffs_backend_spec.rb +8 -8
  27. data/spec/riak/bucket_spec.rb +38 -38
  28. data/spec/riak/client_spec.rb +26 -27
  29. data/spec/riak/core_ext/to_param_spec.rb +2 -2
  30. data/spec/riak/counter_spec.rb +11 -11
  31. data/spec/riak/crdt/counter_spec.rb +4 -2
  32. data/spec/riak/crdt/inner_counter_spec.rb +1 -1
  33. data/spec/riak/crdt/inner_flag_spec.rb +4 -4
  34. data/spec/riak/crdt/inner_map_spec.rb +3 -3
  35. data/spec/riak/crdt/inner_register_spec.rb +5 -5
  36. data/spec/riak/crdt/inner_set_spec.rb +1 -1
  37. data/spec/riak/crdt/map_spec.rb +2 -2
  38. data/spec/riak/crdt/set_spec.rb +4 -2
  39. data/spec/riak/crdt/shared_examples.rb +15 -15
  40. data/spec/riak/crdt/typed_collection_spec.rb +16 -22
  41. data/spec/riak/escape_spec.rb +10 -10
  42. data/spec/riak/feature_detection_spec.rb +1 -1
  43. data/spec/riak/index_collection_spec.rb +7 -4
  44. data/spec/riak/instrumentation_spec.rb +124 -0
  45. data/spec/riak/link_spec.rb +12 -12
  46. data/spec/riak/list_buckets_spec.rb +2 -2
  47. data/spec/riak/map_reduce/filter_builder_spec.rb +5 -5
  48. data/spec/riak/map_reduce/phase_spec.rb +20 -20
  49. data/spec/riak/map_reduce_spec.rb +50 -50
  50. data/spec/riak/multiget_spec.rb +5 -5
  51. data/spec/riak/node_spec.rb +3 -3
  52. data/spec/riak/robject_spec.rb +46 -45
  53. data/spec/riak/search_spec.rb +11 -11
  54. data/spec/riak/secondary_index_spec.rb +9 -9
  55. data/spec/riak/stamp_spec.rb +5 -5
  56. data/spec/riak/walk_spec_spec.rb +30 -30
  57. data/spec/spec_helper.rb +6 -0
  58. data/spec/support/certs/ca.crt +19 -20
  59. data/spec/support/certs/client.crl +13 -0
  60. data/spec/support/certs/client.crt +68 -69
  61. data/spec/support/certs/client.csr +18 -0
  62. data/spec/support/certs/client.key +25 -25
  63. data/spec/support/certs/server.crl +11 -11
  64. data/spec/support/certs/server.crt +68 -69
  65. data/spec/support/certs/server.key +25 -25
  66. data/spec/support/unified_backend_examples.rb +33 -33
  67. metadata +31 -5
@@ -8,17 +8,17 @@ describe Riak::MapReduce do
8
8
  @mr = Riak::MapReduce.new(@client)
9
9
  end
10
10
 
11
- it "should require a client" do
11
+ it "requires a client" do
12
12
  expect { Riak::MapReduce.new }.to raise_error
13
13
  expect { Riak::MapReduce.new(@client) }.not_to raise_error
14
14
  end
15
15
 
16
- it "should initialize the inputs and query to empty arrays" do
16
+ it "initializes the inputs and query to empty arrays" do
17
17
  expect(@mr.inputs).to eq([])
18
18
  expect(@mr.query).to eq([])
19
19
  end
20
20
 
21
- it "should yield itself when given a block on initializing" do
21
+ it "yields itself when given a block on initializing" do
22
22
  @mr2 = nil
23
23
  @mr = Riak::MapReduce.new(@client) do |mr|
24
24
  @mr2 = mr
@@ -27,45 +27,45 @@ describe Riak::MapReduce do
27
27
  end
28
28
 
29
29
  describe "adding inputs" do
30
- it "should return self for chaining" do
30
+ it "returns self for chaining" do
31
31
  expect(@mr.add("foo", "bar")).to eq(@mr)
32
32
  end
33
33
 
34
- it "should add bucket/key pairs to the inputs" do
34
+ it "adds bucket/key pairs to the inputs" do
35
35
  @mr.add("foo","bar")
36
36
  expect(@mr.inputs).to eq([["foo","bar"]])
37
37
  end
38
38
 
39
- it "should add an array containing a bucket/key pair to the inputs" do
39
+ it "adds an array containing a bucket/key pair to the inputs" do
40
40
  @mr.add(["foo","bar"])
41
41
  expect(@mr.inputs).to eq([["foo","bar"]])
42
42
  end
43
43
 
44
- it "should add an object to the inputs by its bucket and key" do
44
+ it "adds an object to the inputs by its bucket and key" do
45
45
  bucket = Riak::Bucket.new(@client, "foo")
46
46
  obj = Riak::RObject.new(bucket, "bar")
47
47
  @mr.add(obj)
48
48
  expect(@mr.inputs).to eq([["foo", "bar"]])
49
49
  end
50
50
 
51
- it "should add an array containing a bucket/key/key-data triple to the inputs" do
51
+ it "adds an array containing a bucket/key/key-data triple to the inputs" do
52
52
  @mr.add(["foo","bar",1000])
53
53
  expect(@mr.inputs).to eq([["foo","bar",1000]])
54
54
  end
55
55
 
56
- it "should use a bucket name as the single input" do
56
+ it "uses a bucket name as the single input" do
57
57
  @mr.add(Riak::Bucket.new(@client, "foo"))
58
58
  expect(@mr.inputs).to eq("foo")
59
59
  @mr.add("docs")
60
60
  expect(@mr.inputs).to eq("docs")
61
61
  end
62
62
 
63
- it "should accept a list of key-filters along with a bucket" do
63
+ it "accepts a list of key-filters along with a bucket" do
64
64
  @mr.add("foo", [[:tokenize, "-", 3], [:string_to_int], [:between, 2009, 2010]])
65
65
  expect(@mr.inputs).to eq({:bucket => "foo", :key_filters => [[:tokenize, "-", 3], [:string_to_int], [:between, 2009, 2010]]})
66
66
  end
67
67
 
68
- it "should add a bucket and filter list via a builder block" do
68
+ it "adds a bucket and filter list via a builder block" do
69
69
  @mr.filter("foo") do
70
70
  tokenize "-", 3
71
71
  string_to_int
@@ -75,17 +75,17 @@ describe Riak::MapReduce do
75
75
  end
76
76
 
77
77
  context "using secondary indexes as inputs" do
78
- it "should set the inputs for equality" do
78
+ it "sets the inputs for equality" do
79
79
  expect(@mr.index("foo", "email_bin", "sean@basho.com")).to eq(@mr)
80
80
  expect(@mr.inputs).to eq({:bucket => "foo", :index => "email_bin", :key => "sean@basho.com"})
81
81
  end
82
82
 
83
- it "should set the inputs for a range" do
83
+ it "sets the inputs for a range" do
84
84
  expect(@mr.index("foo", "rank_int", 10..20)).to eq(@mr)
85
85
  expect(@mr.inputs).to eq({:bucket => "foo", :index => "rank_int", :start => 10, :end => 20})
86
86
  end
87
87
 
88
- it "should raise an error when given an invalid query" do
88
+ it "raises an error when given an invalid query" do
89
89
  expect { @mr.index("foo", "rank_int", 1.0348) }.to raise_error(ArgumentError)
90
90
  expect { @mr.index("foo", "rank_int", Range.new(1.03, 1.05)) }.to raise_error(ArgumentError)
91
91
  end
@@ -99,29 +99,29 @@ describe Riak::MapReduce do
99
99
  before { @urldecode, Riak.url_decoding = Riak.url_decoding, false }
100
100
  after { Riak.url_decoding = @urldecode }
101
101
 
102
- it "should add bucket/key pairs to the inputs with bucket and key escaped" do
102
+ it "adds bucket/key pairs to the inputs with bucket and key escaped" do
103
103
  @mr.add("[foo]","(bar)")
104
104
  expect(@mr.inputs).to eq([["%5Bfoo%5D","%28bar%29"]])
105
105
  end
106
106
 
107
- it "should add an escaped array containing a bucket/key pair to the inputs" do
107
+ it "adds an escaped array containing a bucket/key pair to the inputs" do
108
108
  @mr.add(["[foo]","(bar)"])
109
109
  expect(@mr.inputs).to eq([["%5Bfoo%5D","%28bar%29"]])
110
110
  end
111
111
 
112
- it "should add an object to the inputs by its escaped bucket and key" do
112
+ it "adds an object to the inputs by its escaped bucket and key" do
113
113
  bucket = Riak::Bucket.new(@client, "[foo]")
114
114
  obj = Riak::RObject.new(bucket, "(bar)")
115
115
  @mr.add(obj)
116
116
  expect(@mr.inputs).to eq([["%5Bfoo%5D", "%28bar%29"]])
117
117
  end
118
118
 
119
- it "should add an escaped array containing a bucket/key/key-data triple to the inputs" do
119
+ it "adds an escaped array containing a bucket/key/key-data triple to the inputs" do
120
120
  @mr.add(["[foo]","(bar)","[]()"])
121
121
  expect(@mr.inputs).to eq([["%5Bfoo%5D", "%28bar%29","[]()"]])
122
122
  end
123
123
 
124
- it "should use an escaped bucket name as the single input" do
124
+ it "uses an escaped bucket name as the single input" do
125
125
  @mr.add(Riak::Bucket.new(@client, "[foo]"))
126
126
  expect(@mr.inputs).to eq("%5Bfoo%5D")
127
127
  @mr.add("docs")
@@ -133,29 +133,29 @@ describe Riak::MapReduce do
133
133
  before { @urldecode, Riak.url_decoding = Riak.url_decoding, true }
134
134
  after { Riak.url_decoding = @urldecode }
135
135
 
136
- it "should add bucket/key pairs to the inputs with bucket and key unescaped" do
136
+ it "adds bucket/key pairs to the inputs with bucket and key unescaped" do
137
137
  @mr.add("[foo]","(bar)")
138
138
  expect(@mr.inputs).to eq([["[foo]","(bar)"]])
139
139
  end
140
140
 
141
- it "should add an unescaped array containing a bucket/key pair to the inputs" do
141
+ it "adds an unescaped array containing a bucket/key pair to the inputs" do
142
142
  @mr.add(["[foo]","(bar)"])
143
143
  expect(@mr.inputs).to eq([["[foo]","(bar)"]])
144
144
  end
145
145
 
146
- it "should add an object to the inputs by its unescaped bucket and key" do
146
+ it "adds an object to the inputs by its unescaped bucket and key" do
147
147
  bucket = Riak::Bucket.new(@client, "[foo]")
148
148
  obj = Riak::RObject.new(bucket, "(bar)")
149
149
  @mr.add(obj)
150
150
  expect(@mr.inputs).to eq([["[foo]","(bar)"]])
151
151
  end
152
152
 
153
- it "should add an unescaped array containing a bucket/key/key-data triple to the inputs" do
153
+ it "adds an unescaped array containing a bucket/key/key-data triple to the inputs" do
154
154
  @mr.add(["[foo]","(bar)","[]()"])
155
155
  expect(@mr.inputs).to eq([["[foo]","(bar)","[]()"]])
156
156
  end
157
157
 
158
- it "should use an unescaped bucket name as the single input" do
158
+ it "uses an unescaped bucket name as the single input" do
159
159
  @mr.add(Riak::Bucket.new(@client, "[foo]"))
160
160
  expect(@mr.inputs).to eq("[foo]")
161
161
  @mr.add("docs")
@@ -168,29 +168,29 @@ describe Riak::MapReduce do
168
168
  before { @oldesc, Riak.escaper = Riak.escaper, CGI }
169
169
  after { Riak.escaper = @oldesc }
170
170
 
171
- it "should add bucket/key pairs to the inputs with bucket and key escaped" do
171
+ it "adds bucket/key pairs to the inputs with bucket and key escaped" do
172
172
  @mr.add("[foo]","(bar)")
173
173
  expect(@mr.inputs).to eq([["%5Bfoo%5D","%28bar%29"]])
174
174
  end
175
175
 
176
- it "should add an escaped array containing a bucket/key pair to the inputs" do
176
+ it "adds an escaped array containing a bucket/key pair to the inputs" do
177
177
  @mr.add(["[foo]","(bar)"])
178
178
  expect(@mr.inputs).to eq([["%5Bfoo%5D","%28bar%29"]])
179
179
  end
180
180
 
181
- it "should add an object to the inputs by its escaped bucket and key" do
181
+ it "adds an object to the inputs by its escaped bucket and key" do
182
182
  bucket = Riak::Bucket.new(@client, "[foo]")
183
183
  obj = Riak::RObject.new(bucket, "(bar)")
184
184
  @mr.add(obj)
185
185
  expect(@mr.inputs).to eq([["%5Bfoo%5D", "%28bar%29"]])
186
186
  end
187
187
 
188
- it "should add an escaped array containing a bucket/key/key-data triple to the inputs" do
188
+ it "adds an escaped array containing a bucket/key/key-data triple to the inputs" do
189
189
  @mr.add(["[foo]","(bar)","[]()"])
190
190
  expect(@mr.inputs).to eq([["%5Bfoo%5D", "%28bar%29","[]()"]])
191
191
  end
192
192
 
193
- it "should use an escaped bucket name as the single input" do
193
+ it "uses an escaped bucket name as the single input" do
194
194
  @mr.add(Riak::Bucket.new(@client, "[foo]"))
195
195
  expect(@mr.inputs).to eq("%5Bfoo%5D")
196
196
  @mr.add("docs")
@@ -202,13 +202,13 @@ describe Riak::MapReduce do
202
202
  before { Riak.disable_list_keys_warnings = false }
203
203
  after { Riak.disable_list_keys_warnings = true }
204
204
 
205
- it "should warn about list-keys on buckets" do
205
+ it "warns about list-keys on buckets" do
206
206
  expect(@mr).to receive(:warn).twice
207
207
  @mr.add("foo")
208
208
  @mr.add(Riak::Bucket.new(@client, "foo"))
209
209
  end
210
210
 
211
- it "should warn about list-keys on key-filters" do
211
+ it "warns about list-keys on key-filters" do
212
212
  expect(@mr).to receive(:warn)
213
213
  @mr.filter("foo") { matches "bar" }
214
214
  end
@@ -217,11 +217,11 @@ describe Riak::MapReduce do
217
217
 
218
218
  [:map, :reduce].each do |type|
219
219
  describe "adding #{type} phases" do
220
- it "should return self for chaining" do
220
+ it "returns self for chaining" do
221
221
  expect(@mr.send(type, "function(){}")).to eq(@mr)
222
222
  end
223
223
 
224
- it "should accept a function string" do
224
+ it "accepts a function string" do
225
225
  @mr.send(type, "function(){}")
226
226
  expect(@mr.query.size).to eq(1)
227
227
  phase = @mr.query.first
@@ -229,7 +229,7 @@ describe Riak::MapReduce do
229
229
  expect(phase.type).to eq(type)
230
230
  end
231
231
 
232
- it "should accept a function and options" do
232
+ it "accepts a function and options" do
233
233
  @mr.send(type, "function(){}", :keep => true)
234
234
  expect(@mr.query.size).to eq(1)
235
235
  phase = @mr.query.first
@@ -238,7 +238,7 @@ describe Riak::MapReduce do
238
238
  expect(phase.keep).to be_truthy
239
239
  end
240
240
 
241
- it "should accept a module/function pair" do
241
+ it "accepts a module/function pair" do
242
242
  @mr.send(type, ["riak","mapsomething"])
243
243
  expect(@mr.query.size).to eq(1)
244
244
  phase = @mr.query.first
@@ -247,7 +247,7 @@ describe Riak::MapReduce do
247
247
  expect(phase.language).to eq("erlang")
248
248
  end
249
249
 
250
- it "should accept a module/function pair with extra options" do
250
+ it "accepts a module/function pair with extra options" do
251
251
  @mr.send(type, ["riak", "mapsomething"], :arg => [1000])
252
252
  expect(@mr.query.size).to eq(1)
253
253
  phase = @mr.query.first
@@ -260,11 +260,11 @@ describe Riak::MapReduce do
260
260
  end
261
261
 
262
262
  describe "adding link phases" do
263
- it "should return self for chaining" do
263
+ it "returns self for chaining" do
264
264
  expect(@mr.link({})).to eq(@mr)
265
265
  end
266
266
 
267
- it "should accept a WalkSpec" do
267
+ it "accepts a WalkSpec" do
268
268
  @mr.link(Riak::WalkSpec.new(:tag => "next"))
269
269
  expect(@mr.query.size).to eq(1)
270
270
  phase = @mr.query.first
@@ -273,7 +273,7 @@ describe Riak::MapReduce do
273
273
  expect(phase.function.tag).to eq("next")
274
274
  end
275
275
 
276
- it "should accept a WalkSpec and a hash of options" do
276
+ it "accepts a WalkSpec and a hash of options" do
277
277
  @mr.link(Riak::WalkSpec.new(:bucket => "foo"), :keep => true)
278
278
  expect(@mr.query.size).to eq(1)
279
279
  phase = @mr.query.first
@@ -283,7 +283,7 @@ describe Riak::MapReduce do
283
283
  expect(phase.keep).to be_truthy
284
284
  end
285
285
 
286
- it "should accept a hash of options intermingled with the walk spec options" do
286
+ it "accepts a hash of options intermingled with the walk spec options" do
287
287
  @mr.link(:tag => "snakes", :arg => [1000])
288
288
  expect(@mr.query.size).to eq(1)
289
289
  phase = @mr.query.first
@@ -294,34 +294,34 @@ describe Riak::MapReduce do
294
294
  end
295
295
 
296
296
  describe "converting to JSON for the job" do
297
- it "should include the inputs and query keys" do
297
+ it "includes the inputs and query keys" do
298
298
  expect(@mr.to_json).to match(/"inputs":/)
299
299
  end
300
300
 
301
- it "should map phases to their JSON equivalents" do
301
+ it "maps phases to their JSON equivalents" do
302
302
  phase = Riak::MapReduce::Phase.new(:type => :map, :function => "function(){}")
303
303
  @mr.query << phase
304
304
  expect(@mr.to_json).to include('"source":"function(){}"')
305
305
  expect(@mr.to_json).to include('"query":[{"map":{')
306
306
  end
307
307
 
308
- it "should emit only the bucket name when the input is the whole bucket" do
308
+ it "emits only the bucket name when the input is the whole bucket" do
309
309
  @mr.add("foo")
310
310
  expect(@mr.to_json).to include('"inputs":"foo"')
311
311
  end
312
312
 
313
- it "should emit an array of inputs when there are multiple inputs" do
313
+ it "emits an array of inputs when there are multiple inputs" do
314
314
  @mr.add("foo","bar",1000).add("foo","baz")
315
315
  expect(@mr.to_json).to include('"inputs":[["foo","bar",1000],["foo","baz"]]')
316
316
  end
317
317
 
318
- it "should add the timeout value when set" do
318
+ it "adds the timeout value when set" do
319
319
  @mr.timeout(50000)
320
320
  expect(@mr.to_json).to include('"timeout":50000')
321
321
  end
322
322
  end
323
323
 
324
- it "should return self from setting the timeout" do
324
+ it "returns self from setting the timeout" do
325
325
  expect(@mr.timeout(5000)).to eq(@mr)
326
326
  end
327
327
 
@@ -330,19 +330,19 @@ describe Riak::MapReduce do
330
330
  @mr.map("Riak.mapValues",:keep => true)
331
331
  end
332
332
 
333
- it "should submit the query to the backend" do
333
+ it "submits the query to the backend" do
334
334
  expect(@backend).to receive(:mapred).with(@mr).and_return([])
335
335
  expect(@mr.run).to eq([])
336
336
  end
337
337
 
338
- it "should pass the given block to the backend for streaming" do
338
+ it "passes the given block to the backend for streaming" do
339
339
  arr = []
340
340
  expect(@backend).to receive(:mapred).with(@mr).and_yield("foo").and_yield("bar")
341
341
  @mr.run {|v| arr << v }
342
342
  expect(arr).to eq(["foo", "bar"])
343
343
  end
344
344
 
345
- it "should interpret failed requests with JSON content-types as map reduce errors" do
345
+ it "interprets failed requests with JSON content-types as map reduce errors" do
346
346
  allow(@backend).to receive(:mapred).
347
347
  and_raise(Riak::ProtobuffsFailedRequest.new(:server_error, '{"error":"syntax error"}'))
348
348
  expect{ @mr.run }.to raise_error(Riak::MapReduceError)
@@ -355,7 +355,7 @@ describe Riak::MapReduce do
355
355
  end
356
356
  end
357
357
 
358
- it "should re-raise non-JSON error responses" do
358
+ it "re-raises non-JSON error responses" do
359
359
  allow(@backend).to receive(:mapred).
360
360
  and_raise(Riak::ProtobuffsFailedRequest.new(:server_error, 'Oops, you bwoke it.'))
361
361
  expect { @mr.run }.to raise_error(Riak::FailedRequest)
@@ -8,13 +8,13 @@ describe Riak::Multiget do
8
8
  end
9
9
 
10
10
  describe "initialization" do
11
- it "should accept a client and an array of bucket/key pairs" do
11
+ it "accepts a client and an array of bucket/key pairs" do
12
12
  expect { Riak::Multiget.new(@client, @pairs) }.not_to raise_error
13
13
  end
14
14
  end
15
15
 
16
16
  describe "operation" do
17
- it "should fetch both keys from the bucket" do
17
+ it "fetches both keys from the bucket" do
18
18
  expect(@bucket).to receive(:[]).with('key1')
19
19
  expect(@bucket).to receive(:[]).with('key2')
20
20
 
@@ -23,7 +23,7 @@ describe Riak::Multiget do
23
23
  @multiget.wait_for_finish
24
24
  end
25
25
 
26
- it "should asynchronously fetch" do
26
+ it "fetches asynchronously" do
27
27
  # make fetches slow
28
28
  @slow_mtx = Mutex.new
29
29
  @slow_mtx.lock
@@ -50,7 +50,7 @@ describe Riak::Multiget do
50
50
  expect(@results).to be_a Hash
51
51
  end
52
52
 
53
- it "should not die when objects aren't found" do
53
+ it "returns found objects when only some objects are found" do
54
54
  expect(@bucket).to receive(:[]).
55
55
  with('key1').
56
56
  and_raise(Riak::ProtobuffsFailedRequest.new(:not_found, "not found"))
@@ -67,7 +67,7 @@ describe Riak::Multiget do
67
67
  end
68
68
 
69
69
  describe "results" do
70
- it "should return a hash of pairs to values" do
70
+ it "returns a hash of pairs to values" do
71
71
  expect(@bucket).to receive(:[]).with('key1')
72
72
  expect(@bucket).to receive(:[]).with('key2')
73
73
 
@@ -7,18 +7,18 @@ describe Riak::Client::Node do
7
7
  end
8
8
 
9
9
  describe 'when initializing' do
10
- it 'should default to the local interface on port 8087' do
10
+ it 'defaults to the local interface on port 8087' do
11
11
  node = Riak::Client::Node.new @client
12
12
  expect(node.host).to eq('127.0.0.1')
13
13
  expect(node.pb_port).to eq(8087)
14
14
  end
15
15
 
16
- it 'should accept a host' do
16
+ it 'accepts a host' do
17
17
  node = Riak::Client::Node.new(@client, :host => 'riak.basho.com')
18
18
  expect(node.host).to eq("riak.basho.com")
19
19
  end
20
20
 
21
- it 'should accept a Protobuffs port' do
21
+ it 'accepts a Protobuffs port' do
22
22
  node = Riak::Client::Node.new @client, :pb_port => 9000
23
23
  expect(node.pb_port).to eq(9000)
24
24
  end
@@ -7,34 +7,34 @@ describe Riak::RObject do
7
7
  end
8
8
 
9
9
  describe "initialization" do
10
- it "should set the bucket" do
10
+ it "sets the bucket" do
11
11
  @object = Riak::RObject.new(@bucket)
12
12
  expect(@object.bucket).to eq(@bucket)
13
13
  end
14
14
 
15
- it "should set the key" do
15
+ it "sets the key" do
16
16
  @object = Riak::RObject.new(@bucket, "bar")
17
17
  expect(@object.key).to eq("bar")
18
18
  end
19
19
 
20
- it "should initialize the links to an empty set" do
20
+ it "initializes the links to an empty set" do
21
21
  @object = Riak::RObject.new(@bucket, "bar")
22
22
  expect(@object.links).to eq(Set.new)
23
23
  end
24
24
 
25
- it "should initialize the meta to an empty hash" do
25
+ it "initializes the meta to an empty hash" do
26
26
  @object = Riak::RObject.new(@bucket, "bar")
27
27
  expect(@object.meta).to eq({})
28
28
  end
29
29
 
30
- it "should initialize indexes to an empty hash with a Set for the default value" do
30
+ it "initializes indexes to an empty hash with a Set for the default value" do
31
31
  @object = Riak::RObject.new(@bucket, "bar")
32
32
  expect(@object.indexes).to be_kind_of(Hash)
33
33
  expect(@object.indexes).to be_empty
34
34
  expect(@object.indexes['foo_bin']).to be_kind_of(Set)
35
35
  end
36
36
 
37
- it "should yield itself to a given block" do
37
+ it "yields itself to a given block" do
38
38
  Riak::RObject.new(@bucket, "bar") do |r|
39
39
  expect(r.key).to eq("bar")
40
40
  end
@@ -73,19 +73,19 @@ describe Riak::RObject do
73
73
  @object.data = { 'some' => 'data' }
74
74
  end
75
75
 
76
- it "should reset unserialized forms when stored" do
76
+ it "resets unserialized forms when stored" do
77
77
  @object.raw_data = value = '{ "raw": "json" }'
78
78
 
79
79
  expect(@object.raw_data).to eq(value)
80
80
  expect(@object.data).to eq({ "raw" => "json" })
81
81
  end
82
82
 
83
- it "should lazily serialize when read" do
83
+ it "lazily serializes when read" do
84
84
  expect(@object.raw_data).to eq('{"some":"data"}')
85
85
  end
86
86
  end
87
87
 
88
- it "should not unnecessarily marshal/demarshal" do
88
+ it "only marshal/demarshals when necessary" do
89
89
  expect(@object).not_to receive(:serialize)
90
90
  expect(@object).not_to receive(:deserialize)
91
91
  @object.raw_data = value = "{not even valid json!}}"
@@ -99,13 +99,13 @@ describe Riak::RObject do
99
99
  @object.raw_data = '{"some":"data"}'
100
100
  end
101
101
 
102
- it "should reset previously stored raw data" do
102
+ it "resets previously stored raw data" do
103
103
  @object.data = value = { "new" => "data" }
104
104
  expect(@object.raw_data).to eq('{"new":"data"}')
105
105
  expect(@object.data).to eq(value)
106
106
  end
107
107
 
108
- it "should lazily deserialize when read" do
108
+ it "lazily deserializes when read" do
109
109
  expect(@object.data).to eq({ "some" => "data" })
110
110
  end
111
111
 
@@ -118,7 +118,8 @@ describe Riak::RObject do
118
118
  expect(@object.data).to eq('deserialized')
119
119
  end
120
120
 
121
- it 'does not allow it to be assigned directly to data since it should be assigned to raw_data instead' do
121
+ it 'does not allow it to be assigned directly to data' do
122
+ # it should be assigned to raw_data instead
122
123
  expect {
123
124
  @object.data = io_object
124
125
  }.to raise_error(ArgumentError)
@@ -126,7 +127,7 @@ describe Riak::RObject do
126
127
  end
127
128
  end
128
129
 
129
- it "should not unnecessarily marshal/demarshal" do
130
+ it "only marshal/demarshals when necessary" do
130
131
  expect(@object).not_to receive(:serialize)
131
132
  expect(@object).not_to receive(:deserialize)
132
133
  @object.data = value = { "some" => "data" }
@@ -166,55 +167,55 @@ describe Riak::RObject do
166
167
  expect(@object).to be_kind_of(Riak::RObject)
167
168
  end
168
169
 
169
- it "should load the content type" do
170
+ it "loads the content type" do
170
171
  expect(@object.content_type).to eq("application/json")
171
172
  end
172
173
 
173
- it "should load the body data" do
174
+ it "loads the body data" do
174
175
  expect(@object.data).to be_present
175
176
  end
176
177
 
177
- it "should deserialize the body data" do
178
+ it "deserializes the body data" do
178
179
  expect(@object.data).to eq({"email" => "mail@test.com", "_type" => "User"})
179
180
  end
180
181
 
181
- it "should set the vclock" do
182
+ it "sets the vclock" do
182
183
  expect(@object.vclock).to eq("a85hYGBgzmDKBVIsCfs+fc9gSN9wlA8q/hKosDpIOAsA")
183
184
  end
184
185
 
185
- it "should load and parse links" do
186
+ it "loads and parse links" do
186
187
  expect(@object.links.size).to eq(1)
187
188
  expect(@object.links.first.url).to eq("/riak/addresses/A2cbUQ2KEMbeyWGtdz97LoTi1DN")
188
189
  expect(@object.links.first.rel).to eq("home_address")
189
190
  end
190
191
 
191
- it "should load and parse indexes" do
192
+ it "loads and parse indexes" do
192
193
  expect(@object.indexes.size).to eq(2)
193
194
  expect(@object.indexes['email_bin'].size).to eq(2)
194
195
  expect(@object.indexes['rank_int'].size).to eq(1)
195
196
  end
196
197
 
197
- it "should set the ETag" do
198
+ it "sets the ETag" do
198
199
  expect(@object.etag).to eq("5bnavU3rrubcxLI8EvFXhB")
199
200
  end
200
201
 
201
- it "should set modified date" do
202
+ it "sets modified date" do
202
203
  expect(@object.last_modified.to_i).to eq(Time.httpdate("Mon, 12 Jul 2010 21:37:43 GMT").to_i)
203
204
  end
204
205
 
205
- it "should load meta information" do
206
+ it "loads meta information" do
206
207
  expect(@object.meta["King-Of-Robots"]).to eq(["I"])
207
208
  end
208
209
 
209
- it "should set the key" do
210
+ it "sets the key" do
210
211
  expect(@object.key).to eq("A2IbUQ2KEMbe4WGtdL97LoTi1DN[(\\/)]")
211
212
  end
212
213
 
213
- it "should not set conflict when there is none" do
214
+ it "doesn't set conflict when there is none" do
214
215
  expect(@object.conflict?).to be_falsey
215
216
  end
216
217
 
217
- it 'should return [RContent] for siblings' do
218
+ it 'returns [RContent] for siblings' do
218
219
  expect(@object.siblings).to eq([@object.content])
219
220
  end
220
221
 
@@ -234,27 +235,27 @@ describe Riak::RObject do
234
235
  @object = Riak::RObject.load_from_mapreduce( @client, response ).first
235
236
  end
236
237
 
237
- it "should expose siblings" do
238
+ it "exposes siblings" do
238
239
  expect(@object.siblings.size).to eq(2)
239
240
  expect(@object.siblings[0].etag).to eq("5bnavU3rrubcxLI8EvFXhB")
240
241
  expect(@object.siblings[1].etag).to eq("7jDZLdu0fIj2iRsjGD8qq8")
241
242
  end
242
243
 
243
- it "should be in conflict" do
244
+ it "raises the conflict? flag when in conflict" do
244
245
  expect { @object.data }.to raise_error(Riak::Conflict)
245
246
  expect(@object).to be_conflict
246
247
  end
247
248
  end
248
249
  end
249
250
 
250
- it "should not allow duplicate links" do
251
+ it "doesn't allow duplicate links" do
251
252
  @object = Riak::RObject.new(@bucket, "foo")
252
253
  @object.links << Riak::Link.new("/riak/foo/baz", "next")
253
254
  @object.links << Riak::Link.new("/riak/foo/baz", "next")
254
255
  expect(@object.links.length).to eq(1)
255
256
  end
256
257
 
257
- it "should allow mass-overwriting indexes while preserving default behavior" do
258
+ it "allows mass-overwriting indexes while preserving default behavior" do
258
259
  @object = described_class.new(@bucket, 'foo')
259
260
  @object.indexes = {"ts_int" => [12345], "foo_bin" => "bar"}
260
261
  expect(@object.indexes['ts_int']).to eq(Set.new([12345]))
@@ -272,21 +273,21 @@ describe Riak::RObject do
272
273
  # @headers = @object.store_headers
273
274
  end
274
275
 
275
- it "should raise an error when the content_type is blank" do
276
+ it "raises an error when the content_type is blank" do
276
277
  expect { @object.content_type = nil; @object.store }.to raise_error(ArgumentError)
277
278
  expect { @object.content_type = " "; @object.store }.to raise_error(ArgumentError)
278
279
  end
279
280
 
280
- it "should raise an error when given an empty string as key" do
281
+ it "raises an error when given an empty string as key" do
281
282
  expect { @object.key = ''; @object.store }.to raise_error(ArgumentError)
282
283
  end
283
284
 
284
- it "should pass along quorum parameters and returnbody to the backend" do
285
+ it "passes quorum parameters and returnbody to the backend" do
285
286
  expect(@backend).to receive(:store_object).with(@object, :returnbody => false, :w => 3, :dw => 2).and_return(true)
286
287
  @object.store(:returnbody => false, :w => 3, :dw => 2)
287
288
  end
288
289
 
289
- it "should raise an error if the object is in conflict" do
290
+ it "raises an error if the object is in conflict" do
290
291
  @object.siblings << Riak::RContent.new(@object)
291
292
  expect { @object.store }.to raise_error(Riak::Conflict)
292
293
  end
@@ -300,29 +301,29 @@ describe Riak::RObject do
300
301
  @object.vclock = "somereallylongstring"
301
302
  end
302
303
 
303
- it "should return without requesting if the key is blank" do
304
+ it "returns without requesting if the key is blank" do
304
305
  @object.key = nil
305
306
  expect(@backend).not_to receive(:reload_object)
306
307
  @object.reload
307
308
  end
308
309
 
309
- it "should return without requesting if the vclock is blank" do
310
+ it "returns without requesting if the vclock is blank" do
310
311
  @object.vclock = nil
311
312
  expect(@backend).not_to receive(:reload_object)
312
313
  @object.reload
313
314
  end
314
315
 
315
- it "should reload the object if the key is present" do
316
+ it "reloads the object if the key is present" do
316
317
  expect(@backend).to receive(:reload_object).with(@object, {}).and_return(@object)
317
318
  @object.reload
318
319
  end
319
320
 
320
- it "should pass along the requested R quorum" do
321
+ it "passes the requested R quorum to the backend" do
321
322
  expect(@backend).to receive(:reload_object).with(@object, :r => 2).and_return(@object)
322
323
  @object.reload :r => 2
323
324
  end
324
325
 
325
- it "should disable matching conditions if the key is present and the :force option is given" do
326
+ it "disables matching conditions if the key is present and the :force option is given" do
326
327
  expect(@backend).to receive(:reload_object) do |obj, _|
327
328
  expect(obj.etag).to be_nil
328
329
  expect(obj.last_modified).to be_nil
@@ -339,42 +340,42 @@ describe Riak::RObject do
339
340
  @object = Riak::RObject.new(@bucket, "bar")
340
341
  end
341
342
 
342
- it "should make a DELETE request to the Riak server and freeze the object" do
343
+ it "makes a DELETE request to the Riak server and freeze the object" do
343
344
  expect(@backend).to receive(:delete_object).with(@bucket, "bar", {})
344
345
  @object.delete
345
346
  expect(@object).to be_frozen
346
347
  end
347
348
 
348
- it "should do nothing when the key is blank" do
349
+ it "does nothing when the key is blank" do
349
350
  expect(@backend).not_to receive(:delete_object)
350
351
  @object.key = nil
351
352
  @object.delete
352
353
  end
353
354
 
354
- it "should pass through a failed request exception" do
355
+ it "raises a failed request exception when the backend returns a server error" do
355
356
  expect(@backend).to receive(:delete_object).
356
357
  and_raise(Riak::ProtobuffsFailedRequest.new(:server_error, "server error"))
357
358
  expect { @object.delete }.to raise_error(Riak::FailedRequest)
358
359
  end
359
360
 
360
- it "should send the vector clock if present" do
361
+ it "sends the vector clock to the backend if present" do
361
362
  @object.vclock = "somevclock"
362
363
  expect(@backend).to receive(:delete_object).with(@bucket, "bar", {:vclock => "somevclock"})
363
364
  @object.delete
364
365
  end
365
366
  end
366
367
 
367
- it "should not convert to link without a tag" do
368
+ it "doesn't convert to link without a tag" do
368
369
  @object = Riak::RObject.new(@bucket, "bar")
369
370
  expect { @object.to_link }.to raise_error
370
371
  end
371
372
 
372
- it "should convert to a link having the same url and a supplied tag" do
373
+ it "converts to a link having the same url and a supplied tag" do
373
374
  @object = Riak::RObject.new(@bucket, "bar")
374
375
  expect(@object.to_link("next")).to eq(Riak::Link.new("/riak/foo/bar", "next"))
375
376
  end
376
377
 
377
- it "should escape the bucket and key when converting to a link" do
378
+ it "escapes the bucket and key when converting to a link" do
378
379
  @object = Riak::RObject.new(@bucket, "deep/path")
379
380
  expect(@bucket).to receive(:name).and_return("bucket spaces")
380
381
  expect(@object.to_link("bar").url).to eq("/riak/bucket%20spaces/deep%2Fpath")