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
@@ -0,0 +1,74 @@
1
+ shared_examples_for "Map CRDT" do
2
+ let(:typed_collection){ Riak::Crdt::TypedCollection }
3
+
4
+ it 'should contain counters' do
5
+ expect(subject).to respond_to(:counters)
6
+ expect(subject.counters).to be_an_instance_of typed_collection
7
+ end
8
+
9
+ it 'should contain flags' do
10
+ expect(subject).to respond_to(:flags)
11
+ expect(subject.counters).to be_an_instance_of typed_collection
12
+ end
13
+
14
+ it 'should contain maps' do
15
+ expect(subject).to respond_to(:maps)
16
+ expect(subject.counters).to be_an_instance_of typed_collection
17
+ end
18
+
19
+ it 'should contain registers' do
20
+ expect(subject).to respond_to(:registers)
21
+ expect(subject.counters).to be_an_instance_of typed_collection
22
+ end
23
+
24
+ it 'should contain sets' do
25
+ expect(subject).to respond_to(:sets)
26
+ expect(subject.counters).to be_an_instance_of typed_collection
27
+ end
28
+
29
+ it 'should accept operations' do
30
+ expect(subject).to respond_to(:operate)
31
+ end
32
+ end
33
+
34
+ shared_examples_for "Counter CRDT" do
35
+ it 'should have a value' do
36
+ expect(subject).to respond_to :value
37
+ end
38
+
39
+ it 'should have an increment method' do
40
+ expect(subject).to respond_to :increment
41
+ end
42
+
43
+ it 'should have a decrement method' do
44
+ expect(subject).to respond_to :decrement
45
+ end
46
+
47
+ it 'should have a batch method' do
48
+ expect(subject).to respond_to :batch
49
+ end
50
+ end
51
+
52
+ shared_examples_for 'Set CRDT' do
53
+ it 'should have a value' do
54
+ expect(subject).to respond_to :value
55
+ expect(subject).to respond_to :members
56
+ expect(subject).to respond_to :to_a
57
+ end
58
+
59
+ it 'should have an include? method' do
60
+ expect(subject).to respond_to :include?
61
+ end
62
+
63
+ it 'should have an empty? method' do
64
+ expect(subject).to respond_to :empty?
65
+ end
66
+
67
+ it 'should have an add method' do
68
+ expect(subject).to respond_to :add
69
+ end
70
+
71
+ it 'should have a remove method' do
72
+ expect(subject).to respond_to :remove
73
+ end
74
+ end
@@ -0,0 +1,231 @@
1
+ require 'spec_helper'
2
+
3
+ describe Riak::Crdt::TypedCollection do
4
+ let(:parent){ double 'parent' }
5
+ let(:operation){ double 'operation' }
6
+
7
+ describe 'initialization' do
8
+ it "should accept a type, parent, and hash of values" do
9
+ expect{ described_class.new Riak::Crdt::Counter, parent, {} }.to_not raise_error
10
+ end
11
+ end
12
+
13
+ describe 'containing' do
14
+ describe 'registers' do
15
+ let(:register_class){ Riak::Crdt::InnerRegister }
16
+ subject do
17
+ described_class.new register_class, parent, existing: 'existing'
18
+ end
19
+
20
+ it 'should expose them as frozen strings that are really Registers' do
21
+ expect(subject[:existing]).to eq 'existing'
22
+ expect(subject['existing']).to eq 'existing'
23
+ expect(subject[:existing]).to be_an_instance_of register_class
24
+ expect(subject['existing'].frozen?).to be
25
+ expect{subject['existing'].gsub!('e', 'a')}.to raise_error
26
+ end
27
+
28
+ describe 'creating and updating' do
29
+
30
+ let(:new_value){ 'the new value' }
31
+
32
+ it <<-EOD.gsub(/\s+/, ' ') do
33
+ should ask the register class for an operation with the new value,
34
+ add a name to it, and pass it up to the parent
35
+ EOD
36
+ expect(register_class).to receive(:update).
37
+ with(new_value).
38
+ and_return(operation)
39
+
40
+ expect(operation).
41
+ to receive(:name=).
42
+ with('existing')
43
+
44
+ expect(parent).
45
+ to receive(:operate).
46
+ with(operation)
47
+
48
+ subject['existing'] = new_value
49
+ end
50
+ end
51
+
52
+ describe 'removing' do
53
+
54
+ it <<-EOD.gsub(/\s+/, ' ') do
55
+ should ask the register class for a remove operation, add a name to
56
+ it, and pass it up to the parent
57
+ EOD
58
+ expect(register_class).
59
+ to receive(:delete).
60
+ and_return(operation)
61
+
62
+ expect(operation).
63
+ to receive(:name=).
64
+ with('existing')
65
+
66
+ expect(parent).
67
+ to receive(:operate).
68
+ with(operation)
69
+
70
+ subject.delete 'existing'
71
+ end
72
+ end
73
+ end
74
+ describe 'flags' do
75
+ let(:flag_class){ Riak::Crdt::InnerFlag }
76
+ subject do
77
+ described_class.new flag_class, parent, truthy: true, falsey: false
78
+ end
79
+
80
+ it 'should expose them as booleans' do
81
+ expect(subject[:truthy]).to eq true
82
+ expect(subject['falsey']).to eq false
83
+ end
84
+
85
+ it 'should update them' do
86
+ expect(flag_class).
87
+ to receive(:update).
88
+ with(true).
89
+ and_return(operation)
90
+
91
+ expect(operation).
92
+ to receive(:name=).
93
+ with('become_truthy')
94
+
95
+ expect(parent).
96
+ to receive(:operate).
97
+ with(operation)
98
+
99
+ subject['become_truthy'] = true
100
+ end
101
+
102
+ it 'should delete them' do
103
+ expect(flag_class).
104
+ to receive(:delete).
105
+ and_return(operation)
106
+
107
+ expect(operation).
108
+ to receive(:name=).
109
+ with('become_deleted')
110
+
111
+ expect(parent).
112
+ to receive(:operate).
113
+ with(operation)
114
+
115
+ subject.delete 'become_deleted'
116
+ end
117
+ end
118
+ describe 'counters' do
119
+ let(:counter_class){ Riak::Crdt::InnerCounter }
120
+
121
+ subject{ described_class.new counter_class, parent, zero: 0, one: 1 }
122
+
123
+ it 'should expose existing ones as Counter instances' do
124
+ expect(subject['zero']).to be_an_instance_of counter_class
125
+ expect(subject['zero'].to_i).to eq 0
126
+
127
+ expect(subject['one'].to_i).to eq 1
128
+ end
129
+
130
+ it 'should expose new ones as Counter instances' do
131
+ expect(subject['new_zero']).to be_an_instance_of counter_class
132
+ expect(subject['new_zero'].to_i).to eq 0
133
+ end
134
+
135
+ it 'should allow incrementing and decrementing' do
136
+ counter_name = 'counter'
137
+
138
+ expect(parent).to receive(:operate) do |op|
139
+ expect(op.name).to eq counter_name
140
+ expect(op.type).to eq :counter
141
+ expect(op.value).to eq 1
142
+ end
143
+ subject[counter_name].increment
144
+
145
+ expect(parent).to receive(:operate) do |op|
146
+ expect(op.name).to eq counter_name
147
+ expect(op.type).to eq :counter
148
+ expect(op.value).to eq -5
149
+ end
150
+
151
+ subject[counter_name].decrement 5
152
+ end
153
+ end
154
+ describe 'sets' do
155
+ let(:set_class){ Riak::Crdt::InnerSet }
156
+
157
+ subject{ described_class.new set_class, parent, brewers: %w{aeropress clever v60}}
158
+
159
+ it 'should expose existing ones as Set instances' do
160
+ expect(subject['brewers']).to be_an_instance_of set_class
161
+ expect(subject['brewers']).to include 'aeropress'
162
+ end
163
+
164
+ it 'should expose new ones as empty Set instances' do
165
+ expect(subject['filters']).to be_an_instance_of set_class
166
+ expect(subject['filters']).to be_empty
167
+ end
168
+
169
+ it 'should allow adding and removing' do
170
+ set_name = 'brewers'
171
+
172
+ expect(parent).to receive(:operate) do |op|
173
+ expect(op.name).to eq set_name
174
+ expect(op.type).to eq :set
175
+ expect(op.value).to eq add: 'frenchpress'
176
+ end
177
+ subject[set_name].add 'frenchpress'
178
+
179
+ expect(parent).to receive(:operate) do |op|
180
+ expect(op.name).to eq set_name
181
+ expect(op.type).to eq :set
182
+ expect(op.value).to eq remove: 'aeropress'
183
+ end
184
+ allow(parent).to receive(:context?).and_return(true)
185
+
186
+ subject[set_name].remove 'aeropress'
187
+ end
188
+ end
189
+
190
+ describe 'maps' do
191
+ let(:map_class){ Riak::Crdt::InnerMap }
192
+
193
+ let(:contents) do {a: {
194
+ counters: {},
195
+ flags: {},
196
+ maps: {},
197
+ registers: {'hello' => 'world'},
198
+ sets: {}
199
+ }}
200
+ end
201
+
202
+ let(:inner_map_name){ 'inner map' }
203
+
204
+ subject do
205
+ described_class.new map_class, parent, contents
206
+ end
207
+
208
+ it 'should expose existing ones as populated Map instances' do
209
+ expect(subject['a']).to be_an_instance_of map_class
210
+ expect(subject['a'].registers['hello']).to eq 'world'
211
+ end
212
+
213
+ it 'should expose new ones as empty Map instances' do
214
+ expect(subject['b']).to be_an_instance_of map_class
215
+ expect(subject['b'].registers['hello']).to be_nil
216
+ end
217
+
218
+ it 'should cascade operations to a parent map' do
219
+ expect(operation).
220
+ to receive(:name=).
221
+ with(inner_map_name)
222
+
223
+ expect(parent).
224
+ to receive(:operate).
225
+ with(operation)
226
+
227
+ subject.operate inner_map_name, operation
228
+ end
229
+ end
230
+ end
231
+ end
@@ -7,33 +7,33 @@ describe Riak::Util::Escape do
7
7
  @object.extend(Riak::Util::Escape)
8
8
  end
9
9
 
10
- it "uses URI by default for escaping" do
11
- Riak.escaper.should == CGI
10
+ it "should use URI by default for escaping" do
11
+ expect(Riak.escaper).to eq(URI)
12
12
  end
13
13
 
14
14
  context "when using CGI for escaping" do
15
15
  before { @oldesc, Riak.escaper = Riak.escaper, CGI }
16
16
  after { Riak.escaper = @oldesc }
17
17
 
18
- it "escapes standard non-safe characters" do
19
- @object.escape("some string").should == "some%20string"
20
- @object.escape("another^one").should == "another%5Eone"
21
- @object.escape("bracket[one").should == "bracket%5Bone"
18
+ it "should escape standard non-safe characters" do
19
+ expect(@object.escape("some string")).to eq("some%20string")
20
+ expect(@object.escape("another^one")).to eq("another%5Eone")
21
+ expect(@object.escape("bracket[one")).to eq("bracket%5Bone")
22
22
  end
23
23
 
24
- it "escapes slashes" do
25
- @object.escape("some/inner/path").should == "some%2Finner%2Fpath"
24
+ it "should escape slashes" do
25
+ expect(@object.escape("some/inner/path")).to eq("some%2Finner%2Fpath")
26
26
  end
27
27
 
28
- it "converts the bucket or key to a string before escaping" do
29
- @object.escape(125).should == '125'
28
+ it "should convert the bucket or key to a string before escaping" do
29
+ expect(@object.escape(125)).to eq('125')
30
30
  end
31
31
 
32
- it "unescapes escaped strings" do
33
- @object.unescape("some%20string").should == "some string"
34
- @object.unescape("another%5Eone").should == "another^one"
35
- @object.unescape("bracket%5Bone").should == "bracket[one"
36
- @object.unescape("some%2Finner%2Fpath").should == "some/inner/path"
32
+ it "should unescape escaped strings" do
33
+ expect(@object.unescape("some%20string")).to eq("some string")
34
+ expect(@object.unescape("another%5Eone")).to eq("another^one")
35
+ expect(@object.unescape("bracket%5Bone")).to eq("bracket[one")
36
+ expect(@object.unescape("some%2Finner%2Fpath")).to eq("some/inner/path")
37
37
  end
38
38
  end
39
39
 
@@ -41,36 +41,32 @@ describe Riak::Util::Escape do
41
41
  before { @oldesc, Riak.escaper = Riak.escaper, URI }
42
42
  after { Riak.escaper = @oldesc }
43
43
 
44
- it "escapes standard non-safe characters" do
45
- @object.escape("some string").should == "some%20string"
46
- @object.escape("another^one").should == "another%5Eone"
47
- @object.escape("--one+two--").should == "--one%2Btwo--"
44
+ it "should escape standard non-safe characters" do
45
+ expect(@object.escape("some string")).to eq("some%20string")
46
+ expect(@object.escape("another^one")).to eq("another%5Eone")
47
+ expect(@object.escape("--one+two--")).to eq("--one%2Btwo--")
48
48
  end
49
49
 
50
- it "allows URI-safe characters" do
51
- @object.escape("sean@basho").should == "sean@basho"
50
+ it "should allow URI-safe characters" do
51
+ expect(@object.escape("bracket[one")).to eq("bracket[one")
52
+ expect(@object.escape("sean@basho")).to eq("sean@basho")
52
53
  end
53
54
 
54
- it "escapes slashes" do
55
- @object.escape("some/inner/path").should == "some%2Finner%2Fpath"
55
+ it "should escape slashes" do
56
+ expect(@object.escape("some/inner/path")).to eq("some%2Finner%2Fpath")
56
57
  end
57
58
 
58
- it "escapes square brackets" do
59
- @object.escape("bracket[one").should == "bracket%5Bone"
60
- @object.escape("bracket]two").should == "bracket%5Dtwo"
59
+ it "should convert the bucket or key to a string before escaping" do
60
+ expect(@object.escape(125)).to eq('125')
61
61
  end
62
62
 
63
- it "converts the bucket or key to a string before escaping" do
64
- @object.escape(125).should == '125'
65
- end
66
-
67
- it "unescapes escaped strings" do
68
- @object.unescape("some%20string").should == "some string"
69
- @object.unescape("another%5Eone").should == "another^one"
70
- @object.unescape("bracket%5Bone").should == "bracket[one"
71
- @object.unescape("some%2Finner%2Fpath").should == "some/inner/path"
72
- @object.unescape("--one%2Btwo--").should == "--one+two--"
73
- @object.unescape("me%40basho.co").should == "me@basho.co"
63
+ it "should unescape escaped strings" do
64
+ expect(@object.unescape("some%20string")).to eq("some string")
65
+ expect(@object.unescape("another%5Eone")).to eq("another^one")
66
+ expect(@object.unescape("bracket%5Bone")).to eq("bracket[one")
67
+ expect(@object.unescape("some%2Finner%2Fpath")).to eq("some/inner/path")
68
+ expect(@object.unescape("--one%2Btwo--")).to eq("--one+two--")
69
+ expect(@object.unescape("me%40basho.co")).to eq("me@basho.co")
74
70
  end
75
71
  end
76
72
  end
@@ -16,62 +16,62 @@ describe Riak::Client::FeatureDetection do
16
16
  end
17
17
 
18
18
  context "when the Riak version is 0.14.x" do
19
- before { subject.stub!(:get_server_version).and_return("0.14.2") }
20
- it { should_not be_mapred_phaseless }
21
- it { should_not be_pb_indexes }
22
- it { should_not be_pb_search }
23
- it { should_not be_pb_conditionals }
24
- it { should_not be_quorum_controls }
25
- it { should_not be_tombstone_vclocks }
26
- it { should_not be_pb_head }
27
- it { should_not be_http_props_clearable }
19
+ before { allow(subject).to receive(:get_server_version).and_return("0.14.2") }
20
+ it { is_expected.not_to be_mapred_phaseless }
21
+ it { is_expected.not_to be_pb_indexes }
22
+ it { is_expected.not_to be_pb_search }
23
+ it { is_expected.not_to be_pb_conditionals }
24
+ it { is_expected.not_to be_quorum_controls }
25
+ it { is_expected.not_to be_tombstone_vclocks }
26
+ it { is_expected.not_to be_pb_head }
27
+ it { is_expected.not_to be_http_props_clearable }
28
28
  end
29
29
 
30
30
  context "when the Riak version is 1.0.x" do
31
- before { subject.stub!(:get_server_version).and_return("1.0.3") }
32
- it { should_not be_mapred_phaseless }
33
- it { should_not be_pb_indexes }
34
- it { should_not be_pb_search }
35
- it { should be_pb_conditionals }
36
- it { should be_quorum_controls }
37
- it { should be_tombstone_vclocks }
38
- it { should be_pb_head }
39
- it { should_not be_http_props_clearable }
31
+ before { allow(subject).to receive(:get_server_version).and_return("1.0.3") }
32
+ it { is_expected.not_to be_mapred_phaseless }
33
+ it { is_expected.not_to be_pb_indexes }
34
+ it { is_expected.not_to be_pb_search }
35
+ it { is_expected.to be_pb_conditionals }
36
+ it { is_expected.to be_quorum_controls }
37
+ it { is_expected.to be_tombstone_vclocks }
38
+ it { is_expected.to be_pb_head }
39
+ it { is_expected.not_to be_http_props_clearable }
40
40
  end
41
41
 
42
42
  context "when the Riak version is 1.1.x" do
43
- before { subject.stub!(:get_server_version).and_return("1.1.4") }
44
- it { should be_mapred_phaseless }
45
- it { should_not be_pb_indexes }
46
- it { should_not be_pb_search }
47
- it { should be_pb_conditionals }
48
- it { should be_quorum_controls }
49
- it { should be_tombstone_vclocks }
50
- it { should be_pb_head }
51
- it { should_not be_http_props_clearable }
43
+ before { allow(subject).to receive(:get_server_version).and_return("1.1.4") }
44
+ it { is_expected.to be_mapred_phaseless }
45
+ it { is_expected.not_to be_pb_indexes }
46
+ it { is_expected.not_to be_pb_search }
47
+ it { is_expected.to be_pb_conditionals }
48
+ it { is_expected.to be_quorum_controls }
49
+ it { is_expected.to be_tombstone_vclocks }
50
+ it { is_expected.to be_pb_head }
51
+ it { is_expected.not_to be_http_props_clearable }
52
52
  end
53
53
 
54
54
  context "when the Riak version is 1.2.x" do
55
- before { subject.stub!(:get_server_version).and_return("1.2.1") }
56
- it { should be_mapred_phaseless }
57
- it { should be_pb_indexes }
58
- it { should be_pb_search }
59
- it { should be_pb_conditionals }
60
- it { should be_quorum_controls }
61
- it { should be_tombstone_vclocks }
62
- it { should be_pb_head }
63
- it { should_not be_http_props_clearable }
55
+ before { allow(subject).to receive(:get_server_version).and_return("1.2.1") }
56
+ it { is_expected.to be_mapred_phaseless }
57
+ it { is_expected.to be_pb_indexes }
58
+ it { is_expected.to be_pb_search }
59
+ it { is_expected.to be_pb_conditionals }
60
+ it { is_expected.to be_quorum_controls }
61
+ it { is_expected.to be_tombstone_vclocks }
62
+ it { is_expected.to be_pb_head }
63
+ it { is_expected.not_to be_http_props_clearable }
64
64
  end
65
65
 
66
66
  context "when the Riak version is 1.3.x" do
67
- before { subject.stub!(:get_server_version).and_return("1.3.0") }
68
- it { should be_mapred_phaseless }
69
- it { should be_pb_indexes }
70
- it { should be_pb_search }
71
- it { should be_pb_conditionals }
72
- it { should be_quorum_controls }
73
- it { should be_tombstone_vclocks }
74
- it { should be_pb_head }
75
- it { should be_http_props_clearable }
67
+ before { allow(subject).to receive(:get_server_version).and_return("1.3.0") }
68
+ it { is_expected.to be_mapred_phaseless }
69
+ it { is_expected.to be_pb_indexes }
70
+ it { is_expected.to be_pb_search }
71
+ it { is_expected.to be_pb_conditionals }
72
+ it { is_expected.to be_quorum_controls }
73
+ it { is_expected.to be_tombstone_vclocks }
74
+ it { is_expected.to be_pb_head }
75
+ it { is_expected.to be_http_props_clearable }
76
76
  end
77
77
  end