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
@@ -3,124 +3,124 @@ require 'spec_helper'
3
3
  describe Riak::Bucket do
4
4
  before :each do
5
5
  @client = Riak::Client.new
6
- @backend = mock("Backend")
7
- @client.stub!(:backend).and_yield(@backend)
8
- @client.stub!(:http).and_yield(@backend)
6
+ @backend = double("Backend")
7
+ allow(@client).to receive(:backend).and_yield(@backend)
8
+ allow(@client).to receive(:http).and_yield(@backend)
9
9
  @bucket = Riak::Bucket.new(@client, "foo")
10
10
  end
11
11
 
12
12
  describe "when initializing" do
13
13
  it "should require a client and a name" do
14
- lambda { Riak::Bucket.new }.should raise_error
15
- lambda { Riak::Bucket.new(@client) }.should raise_error
16
- lambda { Riak::Bucket.new("foo") }.should raise_error
17
- lambda { Riak::Bucket.new("foo", @client) }.should raise_error
18
- lambda { Riak::Bucket.new(@client, "foo") }.should_not raise_error
14
+ expect { Riak::Bucket.new }.to raise_error
15
+ expect { Riak::Bucket.new(@client) }.to raise_error
16
+ expect { Riak::Bucket.new("foo") }.to raise_error
17
+ expect { Riak::Bucket.new("foo", @client) }.to raise_error
18
+ expect { Riak::Bucket.new(@client, "foo") }.not_to raise_error
19
19
  expect { Riak::Bucket.new(@client, '') }.to raise_error(ArgumentError)
20
20
  end
21
21
 
22
22
  it "should set the client and name attributes" do
23
23
  bucket = Riak::Bucket.new(@client, "foo")
24
- bucket.client.should == @client
25
- bucket.name.should == "foo"
24
+ expect(bucket.client).to eq(@client)
25
+ expect(bucket.name).to eq("foo")
26
26
  end
27
27
  end
28
28
 
29
29
  describe "accessing keys" do
30
30
  it "should list the keys" do
31
- @backend.should_receive(:list_keys).with(@bucket, {}).and_return(["bar"])
32
- @bucket.keys.should == ["bar"]
31
+ expect(@backend).to receive(:list_keys).with(@bucket, {}).and_return(["bar"])
32
+ expect(@bucket.keys).to eq(["bar"])
33
33
  end
34
34
 
35
35
  it "should allow streaming keys through block" do
36
- @backend.should_receive(:list_keys).with(@bucket, {}).and_yield([]).and_yield(["bar"]).and_yield(["baz"])
36
+ expect(@backend).to receive(:list_keys).with(@bucket, {}).and_yield([]).and_yield(["bar"]).and_yield(["baz"])
37
37
  all_keys = []
38
38
  @bucket.keys do |list|
39
39
  all_keys.concat(list)
40
40
  end
41
- all_keys.should == ["bar", "baz"]
41
+ expect(all_keys).to eq(["bar", "baz"])
42
42
  end
43
43
 
44
44
  it "should not cache the list of keys" do
45
- @backend.should_receive(:list_keys).with(@bucket, {}).twice.and_return(["bar"])
46
- 2.times { @bucket.keys.should == ['bar'] }
45
+ expect(@backend).to receive(:list_keys).with(@bucket, {}).twice.and_return(["bar"])
46
+ 2.times { expect(@bucket.keys).to eq(['bar']) }
47
47
  end
48
48
 
49
49
  it "should warn about the expense of list-keys when warnings are not disabled" do
50
50
  Riak.disable_list_keys_warnings = false
51
- @backend.stub!(:list_keys).and_return(%w{test test2})
52
- @bucket.should_receive(:warn)
51
+ allow(@backend).to receive(:list_keys).and_return(%w{test test2})
52
+ expect(@bucket).to receive(:warn)
53
53
  @bucket.keys
54
54
  Riak.disable_list_keys_warnings = true
55
55
  end
56
56
 
57
57
  it "should allow a specified timeout when listing keys" do
58
- @backend.should_receive(:list_keys).with(@bucket, timeout: 1234).and_return(%w{bar})
58
+ expect(@backend).to receive(:list_keys).with(@bucket, timeout: 1234).and_return(%w{bar})
59
59
 
60
60
  keys = @bucket.keys timeout: 1234
61
61
 
62
- keys.should == %w{bar}
62
+ expect(keys).to eq(%w{bar})
63
63
  end
64
64
  end
65
65
 
66
66
  describe "accessing a counter" do
67
67
  it "should return a counter object" do
68
- Riak::Counter.should_receive(:new).with(@bucket, 'asdf').and_return('example counter')
68
+ expect(Riak::Counter).to receive(:new).with(@bucket, 'asdf').and_return('example counter')
69
69
 
70
70
  new_counter = @bucket.counter 'asdf'
71
71
 
72
- new_counter.should == 'example counter'
72
+ expect(new_counter).to eq('example counter')
73
73
  end
74
74
  end
75
75
 
76
76
  describe "setting the bucket properties" do
77
77
  it "should prefetch the properties when they are not present" do
78
- @backend.stub!(:set_bucket_props)
79
- @backend.should_receive(:get_bucket_props).with(@bucket).and_return({"name" => "foo"})
78
+ allow(@backend).to receive(:set_bucket_props)
79
+ expect(@backend).to receive(:get_bucket_props).with(@bucket, { }).and_return({"name" => "foo"})
80
80
  @bucket.props = {"precommit" => []}
81
81
  end
82
82
 
83
83
  it "should set the new properties on the bucket" do
84
84
  @bucket.instance_variable_set(:@props, {}) # Pretend they are there
85
- @backend.should_receive(:set_bucket_props).with(@bucket, { :name => "foo" })
85
+ expect(@backend).to receive(:set_bucket_props).with(@bucket, { :name => "foo" }, nil)
86
86
  @bucket.props = { :name => "foo" }
87
87
  end
88
88
 
89
89
  it "should raise an error if an invalid type is given" do
90
- lambda { @bucket.props = "blah" }.should raise_error(ArgumentError)
90
+ expect { @bucket.props = "blah" }.to raise_error(ArgumentError)
91
91
  end
92
92
  end
93
93
 
94
94
  describe "fetching the bucket properties" do
95
95
  it "should fetch properties on first access" do
96
- @bucket.instance_variable_get(:@props).should be_nil
97
- @backend.should_receive(:get_bucket_props).with(@bucket).and_return({"name" => "foo"})
98
- @bucket.props.should == {"name" => "foo"}
96
+ expect(@bucket.instance_variable_get(:@props)).to be_nil
97
+ expect(@backend).to receive(:get_bucket_props).with(@bucket, { }).and_return({"name" => "foo"})
98
+ expect(@bucket.props).to eq({"name" => "foo"})
99
99
  end
100
100
 
101
101
  it "should memoize fetched properties" do
102
- @backend.should_receive(:get_bucket_props).once.with(@bucket).and_return({"name" => "foo"})
103
- @bucket.props.should == {"name" => "foo"}
104
- @bucket.props.should == {"name" => "foo"}
102
+ expect(@backend).to receive(:get_bucket_props).once.with(@bucket, { }).and_return({"name" => "foo"})
103
+ expect(@bucket.props).to eq({"name" => "foo"})
104
+ expect(@bucket.props).to eq({"name" => "foo"})
105
105
  end
106
106
  end
107
107
 
108
108
  describe "clearing the bucket properties" do
109
109
  it "should make the request and delete the internal properties cache" do
110
- @client.should_receive(:clear_bucket_props).with(@bucket).and_return(true)
111
- @bucket.clear_props.should be_true
112
- @bucket.instance_variable_get(:@props).should be_nil
110
+ expect(@client).to receive(:clear_bucket_props).with(@bucket).and_return(true)
111
+ expect(@bucket.clear_props).to be_truthy
112
+ expect(@bucket.instance_variable_get(:@props)).to be_nil
113
113
  end
114
114
  end
115
115
 
116
116
  describe "fetching an object" do
117
117
  it "should fetch the object via the backend" do
118
- @backend.should_receive(:fetch_object).with(@bucket, "db", {}).and_return(nil)
118
+ expect(@backend).to receive(:fetch_object).with(@bucket, "db", {}).and_return(nil)
119
119
  @bucket.get("db")
120
120
  end
121
121
 
122
122
  it "should use the specified R quroum" do
123
- @backend.should_receive(:fetch_object).with(@bucket, "db", {:r => 2}).and_return(nil)
123
+ expect(@backend).to receive(:fetch_object).with(@bucket, "db", {:r => 2}).and_return(nil)
124
124
  @bucket.get("db", :r => 2)
125
125
  end
126
126
 
@@ -134,56 +134,59 @@ describe Riak::Bucket do
134
134
  describe "creating a new blank object" do
135
135
  it "should instantiate the object with the given key, default to JSON" do
136
136
  obj = @bucket.new('bar')
137
- obj.should be_kind_of(Riak::RObject)
138
- obj.key.should == 'bar'
139
- obj.content_type.should == 'application/json'
137
+ expect(obj).to be_kind_of(Riak::RObject)
138
+ expect(obj.key).to eq('bar')
139
+ expect(obj.content_type).to eq('application/json')
140
140
  end
141
141
  end
142
142
 
143
143
  describe "fetching or creating a new object" do
144
+ let(:not_found_error){ Riak::ProtobuffsFailedRequest.new :not_found, 'not found' }
145
+ let(:other_error){ Riak::ProtobuffsFailedRequest.new :server_error, 'server error' }
146
+
144
147
  it "should return the existing object if present" do
145
- @object = mock("RObject")
146
- @backend.should_receive(:fetch_object).with(@bucket,"db", {}).and_return(@object)
147
- @bucket.get_or_new('db').should == @object
148
+ @object = double("RObject")
149
+ expect(@backend).to receive(:fetch_object).with(@bucket,"db", {}).and_return(@object)
150
+ expect(@bucket.get_or_new('db')).to eq(@object)
148
151
  end
149
152
 
150
153
  it "should create a new blank object if the key does not exist" do
151
- @backend.should_receive(:fetch_object).and_raise(Riak::HTTPFailedRequest.new(:get, 200, 404, {}, "File not found"))
154
+ expect(@backend).to receive(:fetch_object).and_raise(not_found_error)
152
155
  obj = @bucket.get_or_new('db')
153
- obj.key.should == 'db'
154
- obj.data.should be_blank
156
+ expect(obj.key).to eq('db')
157
+ expect(obj.data).to be_blank
155
158
  end
156
159
 
157
160
  it "should bubble up non-ok non-missing errors" do
158
- @backend.should_receive(:fetch_object).and_raise(Riak::HTTPFailedRequest.new(:get, 200, 500, {}, "File not found"))
159
- lambda { @bucket.get_or_new('db') }.should raise_error(Riak::HTTPFailedRequest)
161
+ expect(@backend).to receive(:fetch_object).and_raise(other_error)
162
+ expect { @bucket.get_or_new('db') }.to raise_error(Riak::ProtobuffsFailedRequest)
160
163
  end
161
164
 
162
165
  it "should pass along the given R quorum parameter" do
163
- @object = mock("RObject")
164
- @backend.should_receive(:fetch_object).with(@bucket,"db", {:r => "all"}).and_return(@object)
165
- @bucket.get_or_new('db', :r => "all").should == @object
166
+ @object = double("RObject")
167
+ expect(@backend).to receive(:fetch_object).with(@bucket,"db", {:r => "all"}).and_return(@object)
168
+ expect(@bucket.get_or_new('db', :r => "all")).to eq(@object)
166
169
  end
167
170
  end
168
171
 
169
172
  describe "fetching multiple objects" do
170
173
  it 'should get each object individually' do
171
- @object1 = mock('obj1')
172
- @object2 = mock('obj2')
173
- @bucket.should_receive(:[]).with('key1').and_return(@object1)
174
- @bucket.should_receive(:[]).with('key2').and_return(@object2)
174
+ @object1 = double('obj1')
175
+ @object2 = double('obj2')
176
+ expect(@bucket).to receive(:[]).with('key1').and_return(@object1)
177
+ expect(@bucket).to receive(:[]).with('key2').and_return(@object2)
175
178
 
176
179
  @results = @bucket.get_many %w{key1 key2}
177
180
 
178
- @results['key1'].should == @object1
179
- @results['key2'].should == @object2
181
+ expect(@results['key1']).to eq(@object1)
182
+ expect(@results['key2']).to eq(@object2)
180
183
  end
181
184
  end
182
185
 
183
186
  describe "querying an index" do
184
187
  it "should list the matching keys" do
185
- @backend.
186
- should_receive(:get_index).
188
+ expect(@backend).
189
+ to receive(:get_index).
187
190
  with(@bucket, "test_bin", "testing", {return_terms: true}).
188
191
  and_return(Riak::IndexCollection.new_from_json({
189
192
  'results' => [
@@ -192,38 +195,38 @@ describe Riak::Bucket do
192
195
  }.to_json))
193
196
  result = @bucket.get_index("test_bin", "testing", return_terms: true)
194
197
 
195
- result.should be_a Riak::IndexCollection
196
- result.to_a.should == %w{asdf hjkl}
197
- result.with_terms.should == {'testing' => %w{asdf hjkl}}
198
+ expect(result).to be_a Riak::IndexCollection
199
+ expect(result.to_a).to eq(%w{asdf hjkl})
200
+ expect(result.with_terms).to eq({'testing' => %w{asdf hjkl}})
198
201
  end
199
202
  end
200
203
 
201
204
  describe "get/set allow_mult property" do
202
205
  before :each do
203
- @backend.stub!(:get_bucket_props).and_return({"allow_mult" => false})
206
+ allow(@backend).to receive(:get_bucket_props).and_return({"allow_mult" => false})
204
207
  end
205
208
 
206
209
  it "should extract the allow_mult property" do
207
- @bucket.allow_mult.should be_false
210
+ expect(@bucket.allow_mult).to be_falsey
208
211
  end
209
212
 
210
213
  it "should set the allow_mult property" do
211
- @bucket.should_receive(:props=).with(hash_including('allow_mult' => true))
214
+ expect(@bucket).to receive(:props=).with(hash_including('allow_mult' => true))
212
215
  @bucket.allow_mult = true
213
216
  end
214
217
  end
215
218
 
216
219
  describe "get/set the N value" do
217
220
  before :each do
218
- @backend.stub!(:get_bucket_props).and_return({"n_val" => 3})
221
+ allow(@backend).to receive(:get_bucket_props).and_return({"n_val" => 3})
219
222
  end
220
223
 
221
224
  it "should extract the N value" do
222
- @bucket.n_value.should == 3
225
+ expect(@bucket.n_value).to eq(3)
223
226
  end
224
227
 
225
228
  it "should set the N value" do
226
- @bucket.should_receive(:props=).with(hash_including('n_val' => 1))
229
+ expect(@bucket).to receive(:props=).with(hash_including('n_val' => 1))
227
230
  @bucket.n_value = 1
228
231
  end
229
232
  end
@@ -231,15 +234,15 @@ describe Riak::Bucket do
231
234
  [:r, :w, :dw, :rw].each do |q|
232
235
  describe "get/set the default #{q} quorum" do
233
236
  before :each do
234
- @backend.stub!(:get_bucket_props).and_return({"r" => "quorum", "w" => "quorum", "dw" => "quorum", "rw" => "quorum"})
237
+ allow(@backend).to receive(:get_bucket_props).and_return({"r" => "quorum", "w" => "quorum", "dw" => "quorum", "rw" => "quorum"})
235
238
  end
236
239
 
237
240
  it "should extract the default #{q} quorum" do
238
- @bucket.send(q).should == "quorum"
241
+ expect(@bucket.send(q)).to eq("quorum")
239
242
  end
240
243
 
241
244
  it "should set the #{q} quorum" do
242
- @bucket.should_receive(:props=).with(hash_including("#{q}" => 1))
245
+ expect(@bucket).to receive(:props=).with(hash_including("#{q}" => 1))
243
246
  @bucket.send("#{q}=",1)
244
247
  end
245
248
  end
@@ -247,24 +250,25 @@ describe Riak::Bucket do
247
250
 
248
251
  describe "checking whether a key exists" do
249
252
  it "should return true if the object does exist" do
250
- @backend.should_receive(:fetch_object).and_return(mock)
251
- @bucket.exists?("foo").should be_true
253
+ expect(@backend).to receive(:fetch_object).and_return(double)
254
+ expect(@bucket.exists?("foo")).to be_truthy
252
255
  end
253
256
 
254
257
  it "should return false if the object doesn't exist" do
255
- @backend.should_receive(:fetch_object).and_raise(Riak::HTTPFailedRequest.new(:get, [200,300], 404, {}, "not found"))
256
- @bucket.exists?("foo").should be_false
258
+ expect(@backend).to receive(:fetch_object).
259
+ and_raise(Riak::ProtobuffsFailedRequest.new(:not_found, "not found"))
260
+ expect(@bucket.exists?("foo")).to be_falsey
257
261
  end
258
262
  end
259
263
 
260
264
  describe "deleting an object" do
261
265
  it "should delete a key from within the bucket" do
262
- @backend.should_receive(:delete_object).with(@bucket, "bar", {})
266
+ expect(@backend).to receive(:delete_object).with(@bucket, "bar", {})
263
267
  @bucket.delete('bar')
264
268
  end
265
269
 
266
270
  it "should use the specified RW quorum" do
267
- @backend.should_receive(:delete_object).with(@bucket, "bar", {:rw => "all"})
271
+ expect(@backend).to receive(:delete_object).with(@bucket, "bar", {:rw => "all"})
268
272
  @bucket.delete('bar', :rw => "all")
269
273
  end
270
274
  end
@@ -1,81 +1,37 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Riak::Client do
3
+ describe Riak::Client, test_client: true do
4
4
  describe "when initializing" do
5
5
  it "should default a single local node" do
6
6
  client = Riak::Client.new
7
- client.nodes.should == [Riak::Client::Node.new(client)]
8
- end
9
-
10
- it "should accept a protocol" do
11
- client = Riak::Client.new :protocol => 'https'
12
- client.protocol.should eq('https')
7
+ expect(client.nodes).to eq([Riak::Client::Node.new(client)])
13
8
  end
14
9
 
15
10
  it "should accept a host" do
16
11
  client = Riak::Client.new :host => "riak.basho.com"
17
- client.nodes.size.should == 1
18
- client.nodes.first.host.should == "riak.basho.com"
19
- end
20
-
21
- it "should accept an HTTP port" do
22
- client = Riak::Client.new :http_port => 9000
23
- client.nodes.size.should == 1
24
- client.nodes.first.http_port.should == 9000
12
+ expect(client.nodes.size).to eq(1)
13
+ expect(client.nodes.first.host).to eq("riak.basho.com")
25
14
  end
26
15
 
27
16
  it "should accept a Protobuffs port" do
28
17
  client = Riak::Client.new :pb_port => 9000
29
- client.nodes.size.should == 1
30
- client.nodes.first.pb_port.should == 9000
31
- end
32
-
33
- it "should warn on setting :port" do
34
- # TODO: make a deprecation utility class/module instead
35
- client = Riak::Client.allocate
36
- client.should_receive(:warn).and_return(true)
37
- client.send :initialize, :port => 9000
38
- end
39
-
40
- it "should accept basic_auth" do
41
- client = Riak::Client.new :basic_auth => "user:pass"
42
- client.nodes.size.should == 1
43
- client.nodes.first.basic_auth.should eq("user:pass")
18
+ expect(client.nodes.size).to eq(1)
19
+ expect(client.nodes.first.pb_port).to eq(9000)
44
20
  end
45
21
 
46
22
  it "should accept a client ID" do
47
23
  client = Riak::Client.new :client_id => "AAAAAA=="
48
- client.client_id.should == "AAAAAA=="
24
+ expect(client.client_id).to eq("AAAAAA==")
49
25
  end
50
26
 
51
27
  it "should create a client ID if not specified" do
52
- Riak::Client.new.client_id.should_not be_nil
53
- end
54
-
55
- it "should accept a path prefix" do
56
- client = Riak::Client.new(:prefix => "/jiak/")
57
- client.nodes.first.http_paths[:prefix].should == "/jiak/"
58
- end
59
-
60
- it "should accept a mapreduce path" do
61
- client = Riak::Client.new(:mapred => "/mr")
62
- client.nodes.first.http_paths[:mapred].should == "/mr"
63
- end
64
-
65
- it "should accept a luwak path" do
66
- client = Riak::Client.new(:luwak => "/beans")
67
- client.nodes.first.http_paths[:luwak].should == "/beans"
68
- end
69
-
70
- it "should accept a solr path" do
71
- client = Riak::Client.new(:solr => "/solar")
72
- client.nodes.first.http_paths[:solr].should == "/solar"
28
+ expect(Riak::Client.new(pb_port: test_client.nodes.first.pb_port).client_id).not_to be_nil
73
29
  end
74
30
  end
75
31
 
76
32
  it "should expose a Stamp object" do
77
- subject.should respond_to(:stamp)
78
- subject.stamp.should be_kind_of(Riak::Stamp)
33
+ expect(subject).to respond_to(:stamp)
34
+ expect(subject.stamp).to be_kind_of(Riak::Stamp)
79
35
  end
80
36
 
81
37
  describe "reconfiguring" do
@@ -83,94 +39,42 @@ describe Riak::Client do
83
39
  @client = Riak::Client.new
84
40
  end
85
41
 
86
- describe "setting the protocol" do
87
- it "should allow setting the protocol" do
88
- @client.should respond_to(:protocol=)
89
- @client.protocol = "https"
90
- @client.protocol.should eq("https")
91
- end
92
-
93
- it "should require a valid protocol to be set" do
94
- lambda { @client.protocol = 'invalid-protocol' }.should(
95
- raise_error(ArgumentError, /^'invalid-protocol' is not a valid protocol/))
96
- end
97
- end
98
-
99
- describe "setting http auth" do
100
- it "should allow setting basic_auth" do
101
- @client.should respond_to(:basic_auth=)
102
- @client.basic_auth = "user:pass"
103
- @client.nodes.each do |node|
104
- node.basic_auth.should eq("user:pass")
105
- end
106
- end
107
- end
108
-
109
42
  describe "setting the client id" do
110
43
  it "should accept a string unmodified" do
111
44
  @client.client_id = "foo"
112
- @client.client_id.should == "foo"
45
+ expect(@client.client_id).to eq("foo")
113
46
  end
114
47
 
115
48
  it "should reject an integer equal to the maximum client id" do
116
- lambda { @client.client_id = Riak::Client::MAX_CLIENT_ID }.should raise_error(ArgumentError)
49
+ expect { @client.client_id = Riak::Client::MAX_CLIENT_ID }.to raise_error(ArgumentError)
117
50
  end
118
51
 
119
52
  it "should reject an integer larger than the maximum client id" do
120
- lambda { @client.client_id = Riak::Client::MAX_CLIENT_ID + 1 }.should raise_error(ArgumentError)
53
+ expect { @client.client_id = Riak::Client::MAX_CLIENT_ID + 1 }.to raise_error(ArgumentError)
121
54
  end
122
55
  end
123
56
  end
124
57
 
125
- describe "choosing an HTTP backend" do
126
- before :each do
127
- @client = Riak::Client.new
128
- end
129
-
130
- it "should choose the selected backend" do
131
- @client.http_backend = :NetHTTP
132
- @client.http do |h|
133
- h.should be_instance_of(Riak::Client::NetHTTPBackend)
134
- end
135
-
136
- @client = Riak::Client.new
137
- @client.http_backend = :Excon
138
- @client.http do |h|
139
- h.should be_instance_of(Riak::Client::ExconBackend)
140
- end
141
- end
142
-
143
- it "should clear the existing HTTP connections when changed" do
144
- @client.http_pool.should_receive(:clear)
145
- @client.http_backend = :Excon
146
- end
147
-
148
- it "should raise an error when the chosen backend is not valid" do
149
- Riak::Client::NetHTTPBackend.should_receive(:configured?).and_return(false)
150
- lambda { @client.http { |x| } }.should raise_error
151
- end
152
- end
153
-
154
58
  describe "choosing a Protobuffs backend" do
155
59
  before :each do
156
- @client = Riak::Client.new(:protocol => "pbc")
60
+ @client = Riak::Client.new
157
61
  end
158
62
 
159
63
  it "should choose the selected backend" do
160
64
  @client.protobuffs_backend = :Beefcake
161
65
  @client.protobuffs do |p|
162
- p.should be_instance_of(Riak::Client::BeefcakeProtobuffsBackend)
66
+ expect(p).to be_instance_of(Riak::Client::BeefcakeProtobuffsBackend)
163
67
  end
164
68
  end
165
69
 
166
70
  it "should teardown the existing Protobuffs connections when changed" do
167
- @client.protobuffs_pool.should_receive(:clear)
71
+ expect(@client.protobuffs_pool).to receive(:clear)
168
72
  @client.protobuffs_backend = :Beefcake
169
73
  end
170
74
 
171
75
  it "should raise an error when the chosen backend is not valid" do
172
- Riak::Client::BeefcakeProtobuffsBackend.should_receive(:configured?).and_return(false)
173
- lambda { @client.protobuffs { |x| } }.should raise_error
76
+ expect(Riak::Client::BeefcakeProtobuffsBackend).to receive(:configured?).and_return(false)
77
+ expect { @client.protobuffs { |x| } }.to raise_error
174
78
  end
175
79
  end
176
80
 
@@ -179,19 +83,9 @@ describe Riak::Client do
179
83
  @client = Riak::Client.new
180
84
  end
181
85
 
182
- it "should use HTTP when the protocol is http or https" do
183
- %w[http https].each do |p|
184
- @client.protocol = p
185
- @client.backend do |b|
186
- b.should be_kind_of(Riak::Client::HTTPBackend)
187
- end
188
- end
189
- end
190
-
191
86
  it "should use Protobuffs when the protocol is pbc" do
192
- @client.protocol = "pbc"
193
87
  @client.backend do |b|
194
- b.should be_kind_of(Riak::Client::ProtobuffsBackend)
88
+ expect(b).to be_kind_of(Riak::Client::ProtobuffsBackend)
195
89
  end
196
90
  end
197
91
  end
@@ -200,8 +94,8 @@ describe Riak::Client do
200
94
  before :each do
201
95
  @client = Riak::Client.new
202
96
  @bucket = @client.bucket('foo')
203
- @bucket.should_receive(:[]).with('value1').and_return(mock('robject'))
204
- @bucket.should_receive(:[]).with('value2').and_return(mock('robject'))
97
+ expect(@bucket).to receive(:[]).with('value1').and_return(double('robject'))
98
+ expect(@bucket).to receive(:[]).with('value2').and_return(double('robject'))
205
99
  @pairs = [
206
100
  [@bucket, 'value1'],
207
101
  [@bucket, 'value2']
@@ -209,37 +103,37 @@ describe Riak::Client do
209
103
  end
210
104
 
211
105
  it 'should accept an array of bucket and key pairs' do
212
- lambda{ @client.get_many(@pairs) }.should_not raise_error
106
+ expect{ @client.get_many(@pairs) }.not_to raise_error
213
107
  end
214
108
 
215
109
  it 'should return a hash of bucket/key pairs and robjects' do
216
110
  @results = @client.get_many(@pairs)
217
- @results.should be_a Hash
218
- @results.length.should be(@pairs.length)
111
+ expect(@results).to be_a Hash
112
+ expect(@results.length).to be(@pairs.length)
219
113
  end
220
114
  end
221
115
 
222
116
  describe "retrieving a bucket" do
223
117
  before :each do
224
118
  @client = Riak::Client.new
225
- @backend = mock("Backend")
226
- @client.stub!(:backend).and_yield(@backend)
119
+ @backend = double("Backend")
120
+ allow(@client).to receive(:backend).and_yield(@backend)
227
121
  end
228
122
 
229
123
  it "should return a bucket object" do
230
- @client.bucket("foo").should be_kind_of(Riak::Bucket)
124
+ expect(@client.bucket("foo")).to be_kind_of(Riak::Bucket)
231
125
  end
232
126
 
233
127
  it "should fetch bucket properties if asked" do
234
- @backend.should_receive(:get_bucket_props) {|b| b.name.should == "foo"; {} }
128
+ expect(@backend).to receive(:get_bucket_props) {|b| expect(b.name).to eq("foo"); {} }
235
129
  @client.bucket("foo", :props => true)
236
130
  end
237
131
 
238
132
  it "should memoize bucket parameters" do
239
- @bucket = mock("Bucket")
240
- Riak::Bucket.should_receive(:new).with(@client, "baz").once.and_return(@bucket)
241
- @client.bucket("baz").should == @bucket
242
- @client.bucket("baz").should == @bucket
133
+ @bucket = double("Bucket")
134
+ expect(Riak::Bucket).to receive(:new).with(@client, "baz").once.and_return(@bucket)
135
+ expect(@client.bucket("baz")).to eq(@bucket)
136
+ expect(@client.bucket("baz")).to eq(@bucket)
243
137
  end
244
138
 
245
139
  it "should reject buckets with zero-length names" do
@@ -250,224 +144,33 @@ describe Riak::Client do
250
144
  describe "listing buckets" do
251
145
  before do
252
146
  @client = Riak::Client.new
253
- @backend = mock("Backend")
254
- @client.stub!(:backend).and_yield(@backend)
147
+ @backend = double("Backend")
148
+ allow(@client).to receive(:backend).and_yield(@backend)
255
149
  end
256
150
 
257
151
  after { Riak.disable_list_keys_warnings = true }
258
152
 
259
153
  it "should list buckets" do
260
- @backend.should_receive(:list_buckets).and_return(%w{test test2})
154
+ expect(@backend).to receive(:list_buckets).and_return(%w{test test2})
261
155
  buckets = @client.buckets
262
- buckets.should have(2).items
263
- buckets.should be_all {|b| b.is_a?(Riak::Bucket) }
264
- buckets[0].name.should == "test"
265
- buckets[1].name.should == "test2"
156
+ expect(buckets.size).to eq(2)
157
+ expect(buckets).to be_all {|b| b.is_a?(Riak::Bucket) }
158
+ expect(buckets[0].name).to eq("test")
159
+ expect(buckets[1].name).to eq("test2")
266
160
  end
267
161
 
268
162
  it "should warn about the expense of list-buckets when warnings are not disabled" do
269
163
  Riak.disable_list_keys_warnings = false
270
- @backend.stub!(:list_buckets).and_return(%w{test test2})
271
- @client.should_receive(:warn)
164
+ allow(@backend).to receive(:list_buckets).and_return(%w{test test2})
165
+ expect(@client).to receive(:warn)
272
166
  @client.buckets
273
167
  end
274
168
 
275
169
  it "should support a timeout option" do
276
- @backend.should_receive(:list_buckets).with(timeout: 1234).and_return(%w{test test2})
170
+ expect(@backend).to receive(:list_buckets).with(timeout: 1234).and_return(%w{test test2})
277
171
 
278
172
  buckets = @client.buckets timeout: 1234
279
- buckets.should have(2).items
280
- end
281
- end
282
-
283
- describe "Luwak (large-files) support" do
284
- describe "storing a file" do
285
- before :each do
286
- @client = Riak::Client.new
287
- @http = mock(Riak::Client::HTTPBackend)
288
- @http.stub!(:node).and_return(@client.node)
289
- @client.stub!(:http).and_yield(@http)
290
- end
291
-
292
- it "should store the file via the HTTP interface" do
293
- @http.should_receive(:store_file).with("text/plain", "Hello, world").and_return("123456789")
294
- @client.store_file("text/plain", "Hello, world").should == "123456789"
295
- end
296
- end
297
-
298
- describe "retrieving a file" do
299
- before :each do
300
- @client = Riak::Client.new
301
- @http = mock(Riak::Client::HTTPBackend)
302
- @http.stub!(:node).and_return(@client.node)
303
- @client.stub!(:http).and_yield(@http)
304
- end
305
-
306
- it "should fetch via HTTP" do
307
- @http.should_receive(:get_file).with("greeting.txt")
308
- @client.get_file("greeting.txt")
309
- end
310
- end
311
-
312
- it "should delete a file" do
313
- @client = Riak::Client.new
314
- @http = mock(Riak::Client::HTTPBackend)
315
- @http.stub!(:node).and_return(@client.nodes.first)
316
- @client.stub!(:http).and_yield(@http)
317
- @http.should_receive(:delete_file).with("greeting.txt")
318
- @client.delete_file("greeting.txt")
319
- end
320
-
321
- it "should detect if file exists via HTTP" do
322
- @client = Riak::Client.new
323
- @http = mock(Riak::Client::HTTPBackend)
324
- @http.stub!(:node).and_return(@client.nodes.first)
325
- @client.stub!(:http).and_yield(@http)
326
- @http.should_receive(:file_exists?).and_return(true)
327
- @client.file_exists?("foo").should be_true
328
- end
329
- end
330
-
331
- describe "ssl", :ssl => true do
332
- before :each do
333
- @client = Riak::Client.new
334
- end
335
-
336
- it "should enable ssl when passed to the initializer" do
337
- client = Riak::Client.new(:ssl => true)
338
- client.nodes.first.ssl_options.should be_a(Hash)
339
- client.nodes.first.ssl_options.should_not be_empty
340
- end
341
-
342
- it "should allow passing ssl options into the initializer" do
343
- client = Riak::Client.new(:ssl => {:verify_mode => "peer"})
344
- client.nodes.first.ssl_options.should be_a(Hash)
345
- client.nodes.first.ssl_options[:verify_mode].should eq("peer")
346
- end
347
-
348
- it "should enable ssl options when initializing the client with https but not setting any ssl options" do
349
- client = Riak::Client.new(:protocol => 'https')
350
- client.nodes.first.ssl_options.should be_a(Hash)
351
- client.nodes.first.ssl_options.should_not be_empty
352
- end
353
-
354
- it "should allow setting ssl options and specifying the https protocol" do
355
- client = Riak::Client.new(:protocol => 'https', :ssl => {:verify_mode => 'peer'})
356
- client.nodes.first.ssl_options.should be_a(Hash)
357
- client.nodes.first.ssl_options[:verify_mode].should eq("peer")
358
- end
359
-
360
- it "should enable ssl options when setting the protocol to https but not setting any ssl options" do
361
- @client.protocol = 'https'
362
- @client.nodes.first.ssl_options.should be_a(Hash)
363
- @client.nodes.first.ssl_options.should_not be_empty
364
- end
365
-
366
- it "should not have ssl options by default" do
367
- @client.nodes.first.ssl_options.should be_nil
368
- end
369
-
370
- # The api should have an ssl= method for setting up all of the ssl
371
- # options. Once the ssl options have been assigned via `ssl=` they should
372
- # be read back out using the read only `ssl_options`. This is to provide
373
- # a seperate api for setting ssl options via client configuration and
374
- # reading them inside of a http backend.
375
- it "should not allow reading ssl options via ssl" do
376
- @client.should_not respond_to(:ssl)
377
- end
378
-
379
- it "should not allow writing ssl options via ssl_options=" do
380
- @client.should_not respond_to(:ssl_options=)
381
- end
382
-
383
- it "should allow setting ssl to true" do
384
- @client.ssl = true
385
- @client.nodes.first.ssl_options[:verify_mode].should eq('none')
386
- end
387
-
388
- it "should allow setting ssl options as a hash" do
389
- @client.ssl = {:verify_mode => "peer"}
390
- @client.nodes.first.ssl_options[:verify_mode].should eq('peer')
391
- end
392
-
393
- it "should set the protocol to https when setting ssl to true" do
394
- @client.ssl = true
395
- @client.protocol.should eq("https")
396
- end
397
-
398
- it "should set the protocol to http when setting ssl to false" do
399
- @client.protocol = 'https'
400
- @client.ssl = false
401
- @client.protocol.should eq('http')
402
- end
403
-
404
- it "should should clear ssl options when setting ssl to false" do
405
- @client.ssl = true
406
- @client.nodes.first.ssl_options.should_not be_nil
407
- @client.ssl = false
408
- @client.nodes.first.ssl_options.should be_nil
409
- end
410
-
411
- it "should set the protocol to https when setting ssl options" do
412
- @client.ssl = {:verify_mode => "peer"}
413
- @client.protocol.should eq("https")
414
- end
415
-
416
- it "should allow setting the verify_mode to none" do
417
- @client.ssl = {:verify_mode => "none"}
418
- @client.nodes.first.ssl_options[:verify_mode].should eq("none")
419
- end
420
-
421
- it "should allow setting the verify_mode to peer" do
422
- @client.ssl = {:verify_mode => "peer"}
423
- @client.nodes.first.ssl_options[:verify_mode].should eq("peer")
424
- end
425
-
426
- it "should not allow setting the verify_mode to anything else" do
427
- lambda {@client.ssl = {:verify_mode => :your_mom}}.should raise_error(ArgumentError)
428
- end
429
-
430
- it "should default verify_mode to none" do
431
- @client.ssl = true
432
- @client.nodes.first.ssl_options[:verify_mode].should eq("none")
433
- end
434
-
435
- it "should allow setting the pem" do
436
- @client.ssl = {:pem => 'i-am-a-pem'}
437
- @client.nodes.first.ssl_options[:pem].should eq('i-am-a-pem')
438
- end
439
-
440
- it "should set them pem from the contents of pem_file" do
441
- filepath = File.expand_path(File.join(File.dirname(__FILE__), '../fixtures/test.pem'))
442
- @client.ssl = {:pem_file => filepath}
443
- @client.nodes.first.ssl_options[:pem].should eq("i-am-a-pem\n")
444
- end
445
-
446
- it "should allow setting the pem_password" do
447
- @client.ssl = {:pem_password => 'pem-pass'}
448
- @client.nodes.first.ssl_options[:pem_password].should eq('pem-pass')
449
- end
450
-
451
- it "should allow setting the ca_file" do
452
- @client.ssl = {:ca_file => '/path/to/ca.crt'}
453
- @client.nodes.first.ssl_options[:ca_file].should eq('/path/to/ca.crt')
454
- end
455
-
456
- it "should allow setting the ca_path" do
457
- @client.ssl = {:ca_path => '/path/to/certs/'}
458
- @client.nodes.first.ssl_options[:ca_path].should eq('/path/to/certs/')
459
- end
460
-
461
- %w[pem ca_file ca_path].each do |option|
462
- it "should default the verify_mode to peer when setting the #{option}" do
463
- @client.ssl = {option.to_sym => 'test-data'}
464
- @client.nodes.first.ssl_options[:verify_mode].should eq("peer")
465
- end
466
-
467
- it "should allow setting the verify mode when setting the #{option}" do
468
- @client.ssl = {option.to_sym => 'test-data', :verify_mode => "none"}
469
- @client.nodes.first.ssl_options[:verify_mode].should eq("none")
470
- end
173
+ expect(buckets.size).to eq(2)
471
174
  end
472
175
  end
473
176
  end