riak-client 1.4.5 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Gemfile +0 -1
  4. data/{LICENSE → LICENSE.md} +0 -0
  5. data/README.markdown +211 -66
  6. data/RELEASE_NOTES.md +22 -47
  7. data/Rakefile +45 -0
  8. data/lib/riak.rb +1 -1
  9. data/lib/riak/bucket.rb +2 -2
  10. data/lib/riak/client.rb +22 -195
  11. data/lib/riak/client/beefcake/crdt_loader.rb +127 -0
  12. data/lib/riak/client/beefcake/crdt_operator.rb +222 -0
  13. data/lib/riak/client/beefcake/footer +4 -0
  14. data/lib/riak/client/beefcake/header +6 -0
  15. data/lib/riak/client/beefcake/message_codes.rb +29 -0
  16. data/lib/riak/client/beefcake/message_overlay.rb +61 -0
  17. data/lib/riak/client/beefcake/messages.rb +733 -371
  18. data/lib/riak/client/beefcake/object_methods.rb +1 -1
  19. data/lib/riak/client/beefcake/protocol.rb +105 -0
  20. data/lib/riak/client/beefcake/socket.rb +243 -0
  21. data/lib/riak/client/beefcake_protobuffs_backend.rb +262 -122
  22. data/lib/riak/client/node.rb +4 -75
  23. data/lib/riak/client/protobuffs_backend.rb +6 -14
  24. data/lib/riak/client/search.rb +0 -64
  25. data/lib/riak/client/yokozuna.rb +52 -0
  26. data/lib/riak/counter.rb +1 -1
  27. data/lib/riak/crdt.rb +21 -0
  28. data/lib/riak/crdt/base.rb +97 -0
  29. data/lib/riak/crdt/batch_counter.rb +19 -0
  30. data/lib/riak/crdt/batch_map.rb +41 -0
  31. data/lib/riak/crdt/counter.rb +71 -0
  32. data/lib/riak/crdt/inner_counter.rb +74 -0
  33. data/lib/riak/crdt/inner_flag.rb +42 -0
  34. data/lib/riak/crdt/inner_map.rb +53 -0
  35. data/lib/riak/crdt/inner_register.rb +26 -0
  36. data/lib/riak/crdt/inner_set.rb +95 -0
  37. data/lib/riak/crdt/map.rb +88 -0
  38. data/lib/riak/crdt/operation.rb +19 -0
  39. data/lib/riak/crdt/set.rb +156 -0
  40. data/lib/riak/crdt/typed_collection.rb +131 -0
  41. data/lib/riak/errors/base.rb +9 -0
  42. data/lib/riak/errors/connection_error.rb +44 -0
  43. data/lib/riak/errors/crdt_error.rb +18 -0
  44. data/lib/riak/errors/failed_request.rb +56 -0
  45. data/lib/riak/errors/protobuffs_error.rb +11 -0
  46. data/lib/riak/i18n.rb +2 -0
  47. data/lib/riak/json.rb +1 -1
  48. data/lib/riak/locale/en.yml +26 -1
  49. data/lib/riak/locale/fr.yml +0 -1
  50. data/lib/riak/map_reduce.rb +1 -1
  51. data/lib/riak/map_reduce/results.rb +1 -1
  52. data/lib/riak/multiget.rb +1 -2
  53. data/lib/riak/rcontent.rb +8 -3
  54. data/lib/riak/robject.rb +2 -8
  55. data/lib/riak/secondary_index.rb +4 -4
  56. data/lib/riak/serializers.rb +1 -1
  57. data/lib/riak/util/escape.rb +3 -5
  58. data/lib/riak/version.rb +1 -1
  59. data/lib/riak/walk_spec.rb +7 -3
  60. data/riak-client.gemspec +10 -8
  61. data/spec/fixtures/bitcask.txt +25 -0
  62. data/spec/integration/riak/bucket_types_spec.rb +61 -0
  63. data/spec/integration/riak/counters_spec.rb +17 -32
  64. data/spec/integration/riak/crdt_spec.rb +181 -0
  65. data/spec/integration/riak/crdt_validation/map_spec.rb +63 -0
  66. data/spec/integration/riak/crdt_validation/set_spec.rb +122 -0
  67. data/spec/integration/riak/protobuffs_backends_spec.rb +9 -26
  68. data/spec/integration/riak/security_spec.rb +94 -0
  69. data/spec/integration/riak/threading_spec.rb +24 -67
  70. data/spec/integration/yokozuna/index_spec.rb +61 -0
  71. data/spec/integration/yokozuna/queries_spec.rb +116 -0
  72. data/spec/integration/yokozuna/schema_spec.rb +49 -0
  73. data/spec/riak/beefcake_protobuffs_backend/crdt_operator_spec.rb +222 -0
  74. data/spec/riak/beefcake_protobuffs_backend/object_methods_spec.rb +4 -4
  75. data/spec/riak/beefcake_protobuffs_backend/protocol_spec.rb +189 -0
  76. data/spec/riak/beefcake_protobuffs_backend/socket_spec.rb +151 -0
  77. data/spec/riak/beefcake_protobuffs_backend_spec.rb +68 -106
  78. data/spec/riak/bucket_spec.rb +81 -77
  79. data/spec/riak/client_spec.rb +43 -340
  80. data/spec/riak/core_ext/to_param_spec.rb +2 -2
  81. data/spec/riak/counter_spec.rb +20 -20
  82. data/spec/riak/crdt/counter_spec.rb +52 -0
  83. data/spec/riak/crdt/inner_counter_spec.rb +21 -0
  84. data/spec/riak/crdt/inner_flag_spec.rb +39 -0
  85. data/spec/riak/crdt/inner_map_spec.rb +47 -0
  86. data/spec/riak/crdt/inner_register_spec.rb +40 -0
  87. data/spec/riak/crdt/inner_set_spec.rb +33 -0
  88. data/spec/riak/crdt/map_spec.rb +77 -0
  89. data/spec/riak/crdt/set_spec.rb +58 -0
  90. data/spec/riak/crdt/shared_examples.rb +74 -0
  91. data/spec/riak/crdt/typed_collection_spec.rb +231 -0
  92. data/spec/riak/escape_spec.rb +33 -37
  93. data/spec/riak/feature_detection_spec.rb +45 -45
  94. data/spec/riak/index_collection_spec.rb +12 -12
  95. data/spec/riak/link_spec.rb +34 -34
  96. data/spec/riak/list_buckets_spec.rb +7 -7
  97. data/spec/riak/map_reduce/filter_builder_spec.rb +6 -6
  98. data/spec/riak/map_reduce/phase_spec.rb +35 -35
  99. data/spec/riak/map_reduce_spec.rb +89 -87
  100. data/spec/riak/multiget_spec.rb +20 -15
  101. data/spec/riak/node_spec.rb +5 -152
  102. data/spec/riak/robject_spec.rb +95 -108
  103. data/spec/riak/search_spec.rb +17 -139
  104. data/spec/riak/secondary_index_spec.rb +49 -49
  105. data/spec/riak/serializers_spec.rb +9 -9
  106. data/spec/riak/stamp_spec.rb +9 -9
  107. data/spec/riak/walk_spec_spec.rb +46 -46
  108. data/spec/spec_helper.rb +14 -22
  109. data/spec/support/certs/README.md +13 -0
  110. data/spec/support/certs/ca.crt +22 -0
  111. data/spec/support/certs/client.crt +95 -0
  112. data/spec/support/certs/client.key +27 -0
  113. data/spec/support/certs/empty_ca.crt +21 -0
  114. data/spec/support/certs/server.crl +13 -0
  115. data/spec/support/certs/server.crt +95 -0
  116. data/spec/support/certs/server.key +27 -0
  117. data/spec/support/integration_setup.rb +1 -1
  118. data/spec/support/search_corpus_setup.rb +29 -8
  119. data/spec/support/test_client.rb +46 -0
  120. data/spec/support/test_client.yml.example +10 -0
  121. data/spec/support/unified_backend_examples.rb +104 -83
  122. data/spec/support/version_filter.rb +2 -2
  123. data/spec/support/wait_until.rb +14 -0
  124. metadata +134 -132
  125. data/erl_src/riak_kv_test014_backend.beam +0 -0
  126. data/erl_src/riak_kv_test014_backend.erl +0 -189
  127. data/erl_src/riak_kv_test_backend.beam +0 -0
  128. data/erl_src/riak_kv_test_backend.erl +0 -731
  129. data/erl_src/riak_search_test_backend.beam +0 -0
  130. data/erl_src/riak_search_test_backend.erl +0 -175
  131. data/lib/riak/client/excon_backend.rb +0 -172
  132. data/lib/riak/client/http_backend.rb +0 -413
  133. data/lib/riak/client/http_backend/bucket_streamer.rb +0 -15
  134. data/lib/riak/client/http_backend/chunked_json_streamer.rb +0 -42
  135. data/lib/riak/client/http_backend/configuration.rb +0 -227
  136. data/lib/riak/client/http_backend/key_streamer.rb +0 -15
  137. data/lib/riak/client/http_backend/object_methods.rb +0 -114
  138. data/lib/riak/client/http_backend/request_headers.rb +0 -34
  139. data/lib/riak/client/http_backend/transport_methods.rb +0 -201
  140. data/lib/riak/client/instrumentation.rb +0 -25
  141. data/lib/riak/client/net_http_backend.rb +0 -82
  142. data/lib/riak/cluster.rb +0 -151
  143. data/lib/riak/failed_request.rb +0 -81
  144. data/lib/riak/instrumentation.rb +0 -6
  145. data/lib/riak/node.rb +0 -40
  146. data/lib/riak/node/configuration.rb +0 -304
  147. data/lib/riak/node/console.rb +0 -133
  148. data/lib/riak/node/control.rb +0 -207
  149. data/lib/riak/node/defaults.rb +0 -85
  150. data/lib/riak/node/generation.rb +0 -127
  151. data/lib/riak/node/log.rb +0 -34
  152. data/lib/riak/node/version.rb +0 -29
  153. data/lib/riak/search.rb +0 -3
  154. data/lib/riak/test_server.rb +0 -89
  155. data/lib/riak/util/headers.rb +0 -32
  156. data/lib/riak/util/multipart.rb +0 -52
  157. data/lib/riak/util/multipart/stream_parser.rb +0 -62
  158. data/spec/fixtures/munchausen.txt +0 -1033
  159. data/spec/integration/riak/cluster_spec.rb +0 -88
  160. data/spec/integration/riak/http_backends_spec.rb +0 -180
  161. data/spec/integration/riak/node_spec.rb +0 -170
  162. data/spec/integration/riak/test_server_spec.rb +0 -57
  163. data/spec/riak/excon_backend_spec.rb +0 -102
  164. data/spec/riak/headers_spec.rb +0 -21
  165. data/spec/riak/http_backend/configuration_spec.rb +0 -273
  166. data/spec/riak/http_backend/object_methods_spec.rb +0 -243
  167. data/spec/riak/http_backend/transport_methods_spec.rb +0 -97
  168. data/spec/riak/http_backend_spec.rb +0 -367
  169. data/spec/riak/instrumentation_spec.rb +0 -167
  170. data/spec/riak/multipart_spec.rb +0 -23
  171. data/spec/riak/net_http_backend_spec.rb +0 -15
  172. data/spec/riak/stream_parser_spec.rb +0 -53
  173. data/spec/support/drb_mock_server.rb +0 -39
  174. data/spec/support/http_backend_implementation_examples.rb +0 -253
  175. data/spec/support/mock_server.rb +0 -81
  176. data/spec/support/mocks.rb +0 -4
  177. data/spec/support/riak_test.rb +0 -77
  178. data/spec/support/sometimes.rb +0 -46
  179. data/spec/support/test_server.rb +0 -61
  180. data/spec/support/test_server.yml.example +0 -14
@@ -5,148 +5,26 @@ describe "Search features" do
5
5
  describe Riak::Client do
6
6
  before :each do
7
7
  @client = Riak::Client.new
8
- @http = mock(Riak::Client::HTTPBackend)
9
- @client.stub!(:http).and_yield(@http)
8
+ @pb = double(Riak::Client::BeefcakeProtobuffsBackend)
9
+ allow(@client).to receive(:backend).and_yield(@pb)
10
10
  end
11
11
 
12
12
  describe "searching" do
13
13
  it "should search the default index" do
14
- @http.should_receive(:search).with(nil, "foo", {}).and_return({})
14
+ expect(@pb).to receive(:search).with(nil, "foo", {}).and_return({})
15
15
  @client.search("foo")
16
16
  end
17
17
 
18
18
  it "should search the default index with additional options" do
19
- @http.should_receive(:search).with(nil, 'foo', 'rows' => 30).and_return({})
19
+ expect(@pb).to receive(:search).with(nil, 'foo', 'rows' => 30).and_return({})
20
20
  @client.search("foo", 'rows' => 30)
21
21
  end
22
22
 
23
23
  it "should search the specified index" do
24
- @http.should_receive(:search).with('search', 'foo', {}).and_return({})
24
+ expect(@pb).to receive(:search).with('search', 'foo', {}).and_return({})
25
25
  @client.search("search", "foo")
26
26
  end
27
27
  end
28
-
29
- describe "indexing documents" do
30
- it "should update the default index" do
31
- doc = {'field' => "value", 'id' => 1}
32
- expect_update_body do |body|
33
- root = REXML::Document.new(body).root
34
- root.name.should == 'add'
35
- root.elements.should have(1).item
36
- root.elements[1].each_element do |el|
37
- case el.attributes['name']
38
- when 'field'
39
- el.text.should == 'value'
40
- when 'id'
41
- el.text.should == '1'
42
- else
43
- fail "Spurious element in #{root.elements[1]}! #{el}"
44
- end
45
- end
46
- end
47
- @client.index(doc)
48
- end
49
-
50
- it "should update the specified index" do
51
- doc = {'field' => "value", 'id' => 1}
52
- expect_update_body(nil, "foo") do |body|
53
- root = REXML::Document.new(body).root
54
- root.name.should == 'add'
55
- root.elements.should have(1).item
56
- root.elements[1].each_element do |el|
57
- case el.attributes['name']
58
- when 'field'
59
- el.text.should == 'value'
60
- when 'id'
61
- el.text.should == '1'
62
- else
63
- fail "Spurious element in #{root.elements[1]}! #{el}"
64
- end
65
- end
66
- end
67
- @client.index("foo", doc)
68
- end
69
-
70
- it "should raise an error when documents do not contain an id" do
71
- @http.stub!(:update_search_index).and_return(true)
72
- lambda { @client.index({:field => "value"}) }.should raise_error(ArgumentError)
73
- lambda { @client.index({:id => 1, :field => "value"}) }.should_not raise_error(ArgumentError)
74
- end
75
-
76
- it "should include multiple documents in the <add> request" do
77
- docs = {'field' => "value", 'id' => 1}, {'foo' => "bar", 'id' => 2}
78
- expect_update_body do |body|
79
- root = REXML::Document.new(body).root
80
- root.name.should == 'add'
81
- docs = root.elements
82
- docs.each do |d|
83
- d.name.should == 'doc'
84
- d.elements.size.should == 2
85
- end
86
- docs[1].each_element do |el|
87
- case el.attributes['name']
88
- when 'field'
89
- el.text.should == 'value'
90
- when 'id'
91
- el.text.should == '1'
92
- else
93
- fail "Spurious element in #{docs[0]}! #{el}"
94
- end
95
- end
96
- docs[2].each_element do |el|
97
- case el.attributes['name']
98
- when 'foo'
99
- el.text.should == 'bar'
100
- when 'id'
101
- el.text.should == '2'
102
- else
103
- fail "Spurious element in #{docs[1]}! #{el}"
104
- end
105
- end
106
- end
107
- @client.index(*docs)
108
- end
109
- end
110
-
111
- describe "removing documents" do
112
- it "should remove documents from the default index" do
113
- expect_update_body('<delete><id>1</id></delete>')
114
- @client.remove({:id => 1})
115
- end
116
-
117
- it "should remove documents from the specified index" do
118
- expect_update_body('<delete><id>1</id></delete>', 'foo')
119
- @client.remove("foo", {:id => 1})
120
- end
121
-
122
- it "should raise an error when document specifications don't include an id or query" do
123
- @http.stub!(:update_search_index).and_return({:code => 200})
124
- lambda { @client.remove({:foo => "bar"}) }.should raise_error(ArgumentError)
125
- lambda { @client.remove({:id => 1}) }.should_not raise_error
126
- end
127
-
128
- it "should build a Solr <delete> request" do
129
- expect_update_body('<delete><id>1</id></delete>')
130
- @client.remove(:id => 1)
131
- expect_update_body('<delete><query>title:old</query></delete>')
132
- @client.remove(:query => "title:old")
133
- end
134
-
135
- it "should include multiple specs in the <delete> request" do
136
- expect_update_body('<delete><id>1</id><query>title:old</query></delete>')
137
- @client.remove({:id => 1}, {:query => "title:old"})
138
- end
139
- end
140
-
141
- def expect_update_body(body=nil, index=nil)
142
- if block_given?
143
- @http.should_receive(:update_search_index).with(index, kind_of(String)) do |i, b|
144
- yield b
145
- end
146
- else
147
- @http.should_receive(:update_search_index).with(index, body)
148
- end
149
- end
150
28
  end
151
29
 
152
30
  describe Riak::Bucket do
@@ -165,22 +43,22 @@ describe "Search features" do
165
43
 
166
44
  it "should detect whether the indexing hook is installed" do
167
45
  load_without_index_hook
168
- @bucket.is_indexed?.should be_false
46
+ expect(@bucket.is_indexed?).to be_falsey
169
47
 
170
48
  load_with_index_hook
171
- @bucket.is_indexed?.should be_true
49
+ expect(@bucket.is_indexed?).to be_truthy
172
50
  end
173
51
 
174
52
  describe "enabling indexing" do
175
53
  it "should add the index hook when not present" do
176
54
  load_without_index_hook
177
- @bucket.should_receive(:props=).with({"precommit" => [Riak::Bucket::SEARCH_PRECOMMIT_HOOK], "search" => true})
55
+ expect(@bucket).to receive(:props=).with({"precommit" => [Riak::Bucket::SEARCH_PRECOMMIT_HOOK], "search" => true})
178
56
  @bucket.enable_index!
179
57
  end
180
58
 
181
59
  it "should not modify the precommit when the hook is present" do
182
60
  load_with_index_hook
183
- @bucket.should_not_receive(:props=)
61
+ expect(@bucket).not_to receive(:props=)
184
62
  @bucket.enable_index!
185
63
  end
186
64
  end
@@ -188,13 +66,13 @@ describe "Search features" do
188
66
  describe "disabling indexing" do
189
67
  it "should remove the index hook when present" do
190
68
  load_with_index_hook
191
- @bucket.should_receive(:props=).with({"precommit" => [], "search" => false})
69
+ expect(@bucket).to receive(:props=).with({"precommit" => [], "search" => false})
192
70
  @bucket.disable_index!
193
71
  end
194
72
 
195
73
  it "should not modify the precommit when the hook is missing" do
196
74
  load_without_index_hook
197
- @bucket.should_not_receive(:props=)
75
+ expect(@bucket).not_to receive(:props=)
198
76
  @bucket.disable_index!
199
77
  end
200
78
  end
@@ -209,20 +87,20 @@ describe "Search features" do
209
87
  describe "using a search query as inputs" do
210
88
  it "should accept a bucket name and query" do
211
89
  @mr.search("foo", "bar OR baz")
212
- @mr.inputs.should == {:module => "riak_search", :function => "mapred_search", :arg => ["foo", "bar OR baz"]}
90
+ expect(@mr.inputs).to eq({:module => "riak_search", :function => "mapred_search", :arg => ["foo", "bar OR baz"]})
213
91
  end
214
92
 
215
93
  it "should accept a Riak::Bucket and query" do
216
94
  @mr.search(Riak::Bucket.new(@client, "foo"), "bar OR baz")
217
- @mr.inputs.should == {:module => "riak_search", :function => "mapred_search", :arg => ["foo", "bar OR baz"]}
95
+ expect(@mr.inputs).to eq({:module => "riak_search", :function => "mapred_search", :arg => ["foo", "bar OR baz"]})
218
96
  end
219
97
 
220
98
  it "should emit the Erlang function and arguments" do
221
99
  @mr.search("foo", "bar OR baz")
222
- @mr.to_json.should include('"inputs":{')
223
- @mr.to_json.should include('"module":"riak_search"')
224
- @mr.to_json.should include('"function":"mapred_search"')
225
- @mr.to_json.should include('"arg":["foo","bar OR baz"]')
100
+ expect(@mr.to_json).to include('"inputs":{')
101
+ expect(@mr.to_json).to include('"module":"riak_search"')
102
+ expect(@mr.to_json).to include('"function":"mapred_search"')
103
+ expect(@mr.to_json).to include('"arg":["foo","bar OR baz"]')
226
104
  end
227
105
  end
228
106
  end
@@ -8,49 +8,49 @@ describe Riak::SecondaryIndex do
8
8
 
9
9
  describe "initialization" do
10
10
  it "should accept a bucket, index name, and scalar" do
11
- lambda { Riak::SecondaryIndex.new @bucket, 'asdf', 'aaaa' }.should_not raise_error
12
- lambda { Riak::SecondaryIndex.new @bucket, 'asdf', 12345 }.should_not raise_error
11
+ expect { Riak::SecondaryIndex.new @bucket, 'asdf', 'aaaa' }.not_to raise_error
12
+ expect { Riak::SecondaryIndex.new @bucket, 'asdf', 12345 }.not_to raise_error
13
13
  end
14
14
 
15
15
  it "should accept a bucket, index name, and a range" do
16
- lambda { Riak::SecondaryIndex.new @bucket, 'asdf', 'aaaa'..'zzzz' }.should_not raise_error
17
- lambda { Riak::SecondaryIndex.new @bucket, 'asdf', 1..5 }.should_not raise_error
16
+ expect { Riak::SecondaryIndex.new @bucket, 'asdf', 'aaaa'..'zzzz' }.not_to raise_error
17
+ expect { Riak::SecondaryIndex.new @bucket, 'asdf', 1..5 }.not_to raise_error
18
18
  end
19
19
  end
20
20
 
21
21
  describe "operation" do
22
22
  before(:each) do
23
- @backend = mock 'Backend'
24
- @client.stub!(:backend).and_yield(@backend)
23
+ @backend = double 'Backend'
24
+ allow(@client).to receive(:backend).and_yield(@backend)
25
25
  @args = [@bucket, 'asdf', 'aaaa'..'zzzz', {}]
26
26
  @index = Riak::SecondaryIndex.new *@args
27
27
 
28
- @backend.should_receive(:get_index).with(*@args).and_return(%w{abcd efgh})
28
+ expect(@backend).to receive(:get_index).with(*@args).and_return(%w{abcd efgh})
29
29
  end
30
30
 
31
31
  it "should return an array of keys" do
32
32
  @results = @index.keys
33
- @results.should be_a Array
34
- @results.first.should be_a String
33
+ expect(@results).to be_a Array
34
+ expect(@results.first).to be_a String
35
35
  end
36
36
  it "should return an array of values" do
37
- @backend.should_receive(:fetch_object).with(@bucket, 'abcd', {}).and_return('abcd')
38
- @backend.should_receive(:fetch_object).with(@bucket, 'efgh', {}).and_return('efgh')
37
+ expect(@backend).to receive(:fetch_object).with(@bucket, 'abcd', {}).and_return('abcd')
38
+ expect(@backend).to receive(:fetch_object).with(@bucket, 'efgh', {}).and_return('efgh')
39
39
 
40
40
  @results = @index.values
41
- @results.should be_a Array
42
- @results.length.should == 2
41
+ expect(@results).to be_a Array
42
+ expect(@results.length).to eq(2)
43
43
  end
44
44
  end
45
45
 
46
46
  describe "streaming" do
47
47
  it "should stream keys into a block" do
48
- @backend = mock 'Backend'
49
- @client.stub!(:backend).and_yield(@backend)
48
+ @backend = double 'Backend'
49
+ allow(@client).to receive(:backend).and_yield(@backend)
50
50
  @args = [@bucket, 'asdf', 'aaaa'..'zzzz', {stream: true}]
51
51
  @index = Riak::SecondaryIndex.new *@args
52
52
 
53
- @backend.should_receive(:get_index).with(*@args).and_yield('abcd').and_yield('efgh')
53
+ expect(@backend).to receive(:get_index).with(*@args).and_yield('abcd').and_yield('efgh')
54
54
 
55
55
  @index.keys {|b| :noop }
56
56
  end
@@ -65,10 +65,10 @@ describe Riak::SecondaryIndex do
65
65
  'continuation' => 'examplecontinuation'
66
66
  }.to_json)
67
67
 
68
- @backend = mock 'Backend'
69
- @client.stub!(:backend).and_yield(@backend)
70
- @backend.
71
- should_receive(:get_index).
68
+ @backend = double 'Backend'
69
+ allow(@client).to receive(:backend).and_yield(@backend)
70
+ expect(@backend).
71
+ to receive(:get_index).
72
72
  with(
73
73
  @bucket,
74
74
  'asdf',
@@ -76,7 +76,7 @@ describe Riak::SecondaryIndex do
76
76
  :max_results => @max_results
77
77
  ).
78
78
  and_return(@expected_collection)
79
- @backend.stub(:get_server_version => '1.4.0')
79
+ allow(@backend).to receive(:get_server_version).and_return('1.4.0')
80
80
 
81
81
 
82
82
  @index = Riak::SecondaryIndex.new(
@@ -87,9 +87,9 @@ describe Riak::SecondaryIndex do
87
87
  )
88
88
 
89
89
  @results = @index.keys
90
- @results.should be_an Array
91
- @results.should == @expected_collection
92
- @results.length.should == @max_results
90
+ expect(@results).to be_an Array
91
+ expect(@results).to eq(@expected_collection)
92
+ expect(@results.length).to eq(@max_results)
93
93
  end
94
94
 
95
95
  it "should support continuations" do
@@ -99,10 +99,10 @@ describe Riak::SecondaryIndex do
99
99
  'keys' => %w{ffff gggg hhhh}
100
100
  }.to_json)
101
101
 
102
- @backend = mock 'Backend'
103
- @client.stub!(:backend).and_yield(@backend)
104
- @backend.
105
- should_receive(:get_index).
102
+ @backend = double 'Backend'
103
+ allow(@client).to receive(:backend).and_yield(@backend)
104
+ expect(@backend).
105
+ to receive(:get_index).
106
106
  with(
107
107
  @bucket,
108
108
  'asdf',
@@ -111,7 +111,7 @@ describe Riak::SecondaryIndex do
111
111
  continuation: 'examplecontinuation'
112
112
  ).
113
113
  and_return(@expected_collection)
114
- @backend.stub(:get_server_version => '1.4.0')
114
+ allow(@backend).to receive(:get_server_version).and_return('1.4.0')
115
115
 
116
116
 
117
117
  @index = Riak::SecondaryIndex.new(
@@ -123,8 +123,8 @@ describe Riak::SecondaryIndex do
123
123
  )
124
124
 
125
125
  @results = @index.keys
126
- @results.should be_an Array
127
- @results.should == @expected_collection
126
+ expect(@results).to be_an Array
127
+ expect(@results).to eq(@expected_collection)
128
128
  end
129
129
 
130
130
  it "should support a next_page method" do
@@ -135,10 +135,10 @@ describe Riak::SecondaryIndex do
135
135
  'continuation' => 'examplecontinuation'
136
136
  }.to_json)
137
137
 
138
- @backend = mock 'Backend'
139
- @client.stub!(:backend).and_yield(@backend)
140
- @backend.
141
- should_receive(:get_index).
138
+ @backend = double 'Backend'
139
+ allow(@client).to receive(:backend).and_yield(@backend)
140
+ expect(@backend).
141
+ to receive(:get_index).
142
142
  once.
143
143
  with(
144
144
  @bucket,
@@ -147,7 +147,7 @@ describe Riak::SecondaryIndex do
147
147
  :max_results => @max_results
148
148
  ).
149
149
  and_return(@expected_collection)
150
- @backend.stub(:get_server_version => '1.4.0')
150
+ allow(@backend).to receive(:get_server_version).and_return('1.4.0')
151
151
 
152
152
 
153
153
  @index = Riak::SecondaryIndex.new(
@@ -158,13 +158,13 @@ describe Riak::SecondaryIndex do
158
158
  )
159
159
 
160
160
  @results = @index.keys
161
- @results.should == @expected_collection
161
+ expect(@results).to eq(@expected_collection)
162
162
 
163
163
  @second_collection = Riak::IndexCollection.new_from_json({
164
164
  'keys' => %w{ffff gggg hhhh}
165
165
  }.to_json)
166
- @backend.
167
- should_receive(:get_index).
166
+ expect(@backend).
167
+ to receive(:get_index).
168
168
  once.
169
169
  with(
170
170
  @bucket,
@@ -177,7 +177,7 @@ describe Riak::SecondaryIndex do
177
177
 
178
178
  @second_page = @index.next_page
179
179
  @second_results = @second_page.keys
180
- @second_results.should == @second_collection
180
+ expect(@second_results).to eq(@second_collection)
181
181
  end
182
182
  end
183
183
 
@@ -192,10 +192,10 @@ describe Riak::SecondaryIndex do
192
192
  }.to_json)
193
193
 
194
194
 
195
- @backend = mock 'Backend'
196
- @client.stub!(:backend).and_yield(@backend)
197
- @backend.
198
- should_receive(:get_index).
195
+ @backend = double 'Backend'
196
+ allow(@client).to receive(:backend).and_yield(@backend)
197
+ expect(@backend).
198
+ to receive(:get_index).
199
199
  with(
200
200
  @bucket,
201
201
  'asdf',
@@ -203,7 +203,7 @@ describe Riak::SecondaryIndex do
203
203
  :return_terms => true
204
204
  ).
205
205
  and_return(@expected_collection)
206
- @backend.stub(:get_server_version => '1.4.0')
206
+ allow(@backend).to receive(:get_server_version).and_return('1.4.0')
207
207
 
208
208
 
209
209
  @index = Riak::SecondaryIndex.new(
@@ -214,12 +214,12 @@ describe Riak::SecondaryIndex do
214
214
  )
215
215
 
216
216
  @results = @index.keys
217
- @results.should be_an Array
218
- @results.should == @expected_collection
219
- @results.with_terms.should == {
217
+ expect(@results).to be_an Array
218
+ expect(@results).to eq(@expected_collection)
219
+ expect(@results.with_terms).to eq({
220
220
  'aaaa' => %w{aaaa},
221
221
  'bbbb' => %w{bbbb bbbb2}
222
- }
222
+ })
223
223
  end
224
224
  end
225
225
  end
@@ -4,16 +4,16 @@ describe Riak::Serializers do
4
4
  shared_examples_for "a serializer" do |type, deserialized, serialized|
5
5
  context "for #{type}" do
6
6
  it "serializes #{deserialized} to #{serialized}" do
7
- described_class.serialize(type, deserialized).should == serialized
7
+ expect(described_class.serialize(type, deserialized)).to eq(serialized)
8
8
  end
9
9
 
10
10
  it "deserializes #{serialized} to #{deserialized}" do
11
- described_class.deserialize(type, serialized).should == deserialized
11
+ expect(described_class.deserialize(type, serialized)).to eq(deserialized)
12
12
  end
13
13
 
14
14
  it "round trips properly" do
15
15
  str = described_class.serialize(type, deserialized)
16
- described_class.deserialize(type, str).should == deserialized
16
+ expect(described_class.deserialize(type, str)).to eq(deserialized)
17
17
  end
18
18
  end
19
19
  end
@@ -28,17 +28,17 @@ describe Riak::Serializers do
28
28
 
29
29
  %w[ serialize deserialize ].each do |meth|
30
30
  describe ".#{meth}" do
31
- it 'raises a NotImplementedError when given an unrecognized content type' do
31
+ it 'raises an IOError when given an unrecognized content type' do
32
32
  expect {
33
33
  described_class.send(meth, "application/unrecognized", "string")
34
- }.to raise_error(NotImplementedError)
34
+ }.to raise_error(IOError)
35
35
  end
36
36
  end
37
37
  end
38
38
 
39
39
  describe "plain text serializer" do
40
40
  it 'calls #to_s to convert the object to a string' do
41
- described_class.serialize("text/plain", :a_string).should == "a_string"
41
+ expect(described_class.serialize("text/plain", :a_string)).to eq("a_string")
42
42
  end
43
43
  end
44
44
 
@@ -57,11 +57,11 @@ describe Riak::Serializers do
57
57
  s = h.to_json(Riak.json_options)
58
58
  expect {
59
59
  described_class.serialize('application/json', h)
60
- }.should_not raise_error
60
+ }.to_not raise_error
61
61
 
62
62
  expect {
63
63
  described_class.deserialize('application/json', s)
64
- }.should_not raise_error
64
+ }.to_not raise_error
65
65
  end
66
66
  end
67
67
 
@@ -80,7 +80,7 @@ describe Riak::Serializers do
80
80
 
81
81
  it 'can be registered' do
82
82
  described_class['application/custom-type-1'] = custom_serializer
83
- described_class['application/custom-type-1'].should be(custom_serializer)
83
+ expect(described_class['application/custom-type-1']).to be(custom_serializer)
84
84
  # fail
85
85
  end
86
86