cql-rb 1.0.0.pre7 → 1.0.0.pre8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. data/lib/cql/byte_buffer.rb +22 -0
  2. data/lib/cql/client.rb +79 -310
  3. data/lib/cql/client/asynchronous_client.rb +254 -0
  4. data/lib/cql/client/asynchronous_prepared_statement.rb +19 -0
  5. data/lib/cql/client/column_metadata.rb +22 -0
  6. data/lib/cql/client/query_result.rb +34 -0
  7. data/lib/cql/client/result_metadata.rb +31 -0
  8. data/lib/cql/client/synchronous_client.rb +47 -0
  9. data/lib/cql/client/synchronous_prepared_statement.rb +47 -0
  10. data/lib/cql/future.rb +7 -3
  11. data/lib/cql/io.rb +1 -0
  12. data/lib/cql/io/io_reactor.rb +9 -3
  13. data/lib/cql/io/node_connection.rb +2 -2
  14. data/lib/cql/protocol.rb +5 -4
  15. data/lib/cql/protocol/request.rb +23 -0
  16. data/lib/cql/protocol/requests/credentials_request.rb +1 -1
  17. data/lib/cql/protocol/requests/execute_request.rb +13 -84
  18. data/lib/cql/protocol/requests/options_request.rb +1 -1
  19. data/lib/cql/protocol/requests/prepare_request.rb +2 -1
  20. data/lib/cql/protocol/requests/query_request.rb +3 -1
  21. data/lib/cql/protocol/requests/register_request.rb +1 -1
  22. data/lib/cql/protocol/requests/startup_request.rb +1 -2
  23. data/lib/cql/protocol/{response_body.rb → response.rb} +1 -1
  24. data/lib/cql/protocol/responses/authenticate_response.rb +1 -1
  25. data/lib/cql/protocol/responses/error_response.rb +1 -1
  26. data/lib/cql/protocol/responses/ready_response.rb +1 -1
  27. data/lib/cql/protocol/responses/result_response.rb +1 -1
  28. data/lib/cql/protocol/responses/rows_result_response.rb +1 -1
  29. data/lib/cql/protocol/responses/supported_response.rb +1 -1
  30. data/lib/cql/protocol/type_converter.rb +226 -46
  31. data/lib/cql/version.rb +1 -1
  32. data/spec/cql/byte_buffer_spec.rb +38 -0
  33. data/spec/cql/client/asynchronous_client_spec.rb +472 -0
  34. data/spec/cql/client/client_shared.rb +27 -0
  35. data/spec/cql/client/synchronous_client_spec.rb +104 -0
  36. data/spec/cql/client/synchronous_prepared_statement_spec.rb +65 -0
  37. data/spec/cql/future_spec.rb +4 -0
  38. data/spec/cql/io/io_reactor_spec.rb +39 -20
  39. data/spec/cql/protocol/request_spec.rb +17 -0
  40. data/spec/cql/protocol/requests/credentials_request_spec.rb +82 -0
  41. data/spec/cql/protocol/requests/execute_request_spec.rb +174 -0
  42. data/spec/cql/protocol/requests/options_request_spec.rb +24 -0
  43. data/spec/cql/protocol/requests/prepare_request_spec.rb +70 -0
  44. data/spec/cql/protocol/requests/query_request_spec.rb +95 -0
  45. data/spec/cql/protocol/requests/register_request_spec.rb +24 -0
  46. data/spec/cql/protocol/requests/startup_request_spec.rb +29 -0
  47. data/spec/integration/client_spec.rb +26 -19
  48. data/spec/integration/protocol_spec.rb +2 -2
  49. data/spec/integration/regression_spec.rb +1 -1
  50. metadata +35 -9
  51. data/lib/cql/protocol/request_body.rb +0 -15
  52. data/lib/cql/protocol/request_frame.rb +0 -20
  53. data/spec/cql/client_spec.rb +0 -454
  54. data/spec/cql/protocol/request_frame_spec.rb +0 -456
@@ -1,456 +0,0 @@
1
- # encoding: ascii-8bit
2
-
3
- require 'spec_helper'
4
-
5
-
6
- module Cql
7
- module Protocol
8
- describe RequestFrame do
9
- context 'with CREDENTIALS requests' do
10
- it 'encodes a CREDENTIALS request' do
11
- bytes = RequestFrame.new(CredentialsRequest.new('username' => 'cassandra', 'password' => 'ardnassac')).write('')
12
- bytes.should == (
13
- "\x01\x00\x00\04" +
14
- "\x00\x00\x00\x2c" +
15
- "\x00\x02" +
16
- "\x00\x08username" +
17
- "\x00\x09cassandra" +
18
- "\x00\x08password" +
19
- "\x00\x09ardnassac"
20
- )
21
- end
22
- end
23
-
24
- context 'with OPTIONS requests' do
25
- it 'encodes an OPTIONS request' do
26
- bytes = RequestFrame.new(OptionsRequest.new).write('')
27
- bytes.should == "\x01\x00\x00\x05\x00\x00\x00\x00"
28
- end
29
- end
30
-
31
- context 'with STARTUP requests' do
32
- it 'encodes the request' do
33
- bytes = RequestFrame.new(StartupRequest.new('3.0.0', 'snappy')).write('')
34
- bytes.should == "\x01\x00\x00\x01\x00\x00\x00\x2b\x00\x02\x00\x0bCQL_VERSION\x00\x053.0.0\x00\x0bCOMPRESSION\x00\x06snappy"
35
- end
36
-
37
- it 'defaults to CQL 3.0.0 and no compression' do
38
- bytes = RequestFrame.new(StartupRequest.new).write('')
39
- bytes.should == "\x01\x00\x00\x01\x00\x00\x00\x16\x00\x01\x00\x0bCQL_VERSION\x00\x053.0.0"
40
- end
41
- end
42
-
43
- context 'with REGISTER requests' do
44
- it 'encodes the request' do
45
- bytes = RequestFrame.new(RegisterRequest.new('TOPOLOGY_CHANGE', 'STATUS_CHANGE')).write('')
46
- bytes.should == "\x01\x00\x00\x0b\x00\x00\x00\x22\x00\x02\x00\x0fTOPOLOGY_CHANGE\x00\x0dSTATUS_CHANGE"
47
- end
48
- end
49
-
50
- context 'with QUERY requests' do
51
- it 'encodes the request' do
52
- bytes = RequestFrame.new(QueryRequest.new('USE system', :all)).write('')
53
- bytes.should == "\x01\x00\x00\x07\x00\x00\x00\x10\x00\x00\x00\x0aUSE system\x00\x05"
54
- end
55
-
56
- it 'correctly encodes queries with multibyte characters' do
57
- bytes = RequestFrame.new(QueryRequest.new("INSERT INTO users (user_id, first, last, age) VALUES ('test', 'ümlaut', 'test', 1)", :all)).write(ByteBuffer.new)
58
- bytes.should eql_bytes("\x01\x00\x00\a\x00\x00\x00Y\x00\x00\x00SINSERT INTO users (user_id, first, last, age) VALUES ('test', '\xC3\xBCmlaut', 'test', 1)\x00\x05")
59
- end
60
- end
61
-
62
- context 'with PREPARE requests' do
63
- it 'encodes the request' do
64
- bytes = RequestFrame.new(PrepareRequest.new('UPDATE users SET email = ? WHERE user_name = ?')).write('')
65
- bytes.should == "\x01\x00\x00\x09\x00\x00\x00\x32\x00\x00\x00\x2eUPDATE users SET email = ? WHERE user_name = ?"
66
- end
67
- end
68
-
69
- context 'with EXECUTE requests' do
70
- let :id do
71
- "\xCAH\x7F\x1Ez\x82\xD2<N\x8A\xF35Qq\xA5/"
72
- end
73
-
74
- let :column_metadata do
75
- [['ks', 'tbl', 'col1', :varchar], ['ks', 'tbl', 'col2', :int], ['ks', 'tbl', 'col3', :varchar]]
76
- end
77
-
78
- it 'encodes the request' do
79
- bytes = RequestFrame.new(ExecuteRequest.new(id, column_metadata, ['hello', 42, 'foo'], :each_quorum)).write('')
80
- bytes.should == "\x01\x00\x00\x0a\x00\x00\x00\x2e\x00\x10\xCAH\x7F\x1Ez\x82\xD2<N\x8A\xF35Qq\xA5/\x00\x03\x00\x00\x00\x05hello\x00\x00\x00\x04\x00\x00\x00\x2a\x00\x00\x00\x03foo\x00\x07"
81
- end
82
-
83
- specs = [
84
- [:ascii, 'test', "test"],
85
- [:bigint, 1012312312414123, "\x00\x03\x98\xB1S\xC8\x7F\xAB"],
86
- [:blob, "\xab\xcd", "\xab\xcd"],
87
- [:boolean, false, "\x00"],
88
- [:boolean, true, "\x01"],
89
- [:decimal, BigDecimal.new('1042342234234.123423435647768234'), "\x00\x00\x00\x12\r'\xFDI\xAD\x80f\x11g\xDCfV\xAA"],
90
- [:double, 10000.123123123, "@\xC3\x88\x0F\xC2\x7F\x9DU"],
91
- [:float, 12.13, "AB\x14{"],
92
- [:inet, IPAddr.new('8.8.8.8'), "\x08\x08\x08\x08"],
93
- [:inet, IPAddr.new('::1'), "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"],
94
- [:int, 12348098, "\x00\xBCj\xC2"],
95
- [:text, 'FOOBAR', 'FOOBAR'],
96
- [:timestamp, Time.at(1358013521.123), "\x00\x00\x01</\xE9\xDC\xE3"],
97
- [:timeuuid, Uuid.new('a4a70900-24e1-11df-8924-001ff3591711'), "\xA4\xA7\t\x00$\xE1\x11\xDF\x89$\x00\x1F\xF3Y\x17\x11"],
98
- [:uuid, Uuid.new('cfd66ccc-d857-4e90-b1e5-df98a3d40cd6'), "\xCF\xD6l\xCC\xD8WN\x90\xB1\xE5\xDF\x98\xA3\xD4\f\xD6"],
99
- [:varchar, 'hello', 'hello'],
100
- [:varint, 1231312312331283012830129382342342412123, "\x03\x9EV \x15\f\x03\x9DK\x18\xCDI\\$?\a["],
101
- [:varint, -234234234234, "\xC9v\x8D:\x86"],
102
- [[:list, :timestamp], [Time.at(1358013521.123)], "\x00\x01" + "\x00\x08\x00\x00\x01</\xE9\xDC\xE3"],
103
- [[:list, :boolean], [true, false, true, true], "\x00\x04" + "\x00\x01\x01" + "\x00\x01\x00" + "\x00\x01\x01" + "\x00\x01\x01"],
104
- [[:map, :uuid, :int], {Uuid.new('cfd66ccc-d857-4e90-b1e5-df98a3d40cd6') => 45345, Uuid.new('a4a70900-24e1-11df-8924-001ff3591711') => 98765}, "\x00\x02" + "\x00\x10\xCF\xD6l\xCC\xD8WN\x90\xB1\xE5\xDF\x98\xA3\xD4\f\xD6" + "\x00\x04\x00\x00\xb1\x21" + "\x00\x10\xA4\xA7\t\x00$\xE1\x11\xDF\x89$\x00\x1F\xF3Y\x17\x11" + "\x00\x04\x00\x01\x81\xcd"],
105
- [[:map, :ascii, :blob], {'hello' => 'world', 'one' => "\x01", 'two' => "\x02"}, "\x00\x03" + "\x00\x05hello" + "\x00\x05world" + "\x00\x03one" + "\x00\x01\x01" + "\x00\x03two" + "\x00\x01\x02"],
106
- [[:set, :int], Set.new([13, 3453, 456456, 123, 768678]), "\x00\x05" + "\x00\x04\x00\x00\x00\x0d" + "\x00\x04\x00\x00\x0d\x7d" + "\x00\x04\x00\x06\xf7\x08" + "\x00\x04\x00\x00\x00\x7b" + "\x00\x04\x00\x0b\xba\xa6"],
107
- [[:set, :varchar], Set.new(['foo', 'bar', 'baz']), "\x00\x03" + "\x00\x03foo" + "\x00\x03bar" + "\x00\x03baz"],
108
- [[:set, :int], [13, 3453, 456456, 123, 768678], "\x00\x05" + "\x00\x04\x00\x00\x00\x0d" + "\x00\x04\x00\x00\x0d\x7d" + "\x00\x04\x00\x06\xf7\x08" + "\x00\x04\x00\x00\x00\x7b" + "\x00\x04\x00\x0b\xba\xa6"],
109
- [[:set, :varchar], ['foo', 'bar', 'baz'], "\x00\x03" + "\x00\x03foo" + "\x00\x03bar" + "\x00\x03baz"]
110
- ]
111
- specs.each do |type, value, expected_bytes|
112
- it "encodes #{type} values" do
113
- metadata = [['ks', 'tbl', 'id_column', type]]
114
- buffer = RequestFrame.new(ExecuteRequest.new(id, metadata, [value], :one)).write(ByteBuffer.new)
115
- buffer.discard(8 + 2 + 16 + 2)
116
- length = buffer.read_int
117
- result_bytes = buffer.read(length)
118
- result_bytes.should eql_bytes(expected_bytes)
119
- end
120
- end
121
-
122
- it 'raises an error when the metadata and values don\'t have the same size' do
123
- expect { ExecuteRequest.new(id, column_metadata, ['hello', 42], :each_quorum) }.to raise_error(ArgumentError)
124
- end
125
-
126
- it 'raises an error for unsupported column types' do
127
- column_metadata[2][3] = :imaginary
128
- expect { RequestFrame.new(ExecuteRequest.new(id, column_metadata, ['hello', 42, 'foo'], :each_quorum)).write('') }.to raise_error(UnsupportedColumnTypeError)
129
- end
130
-
131
- it 'raises an error for unsupported column collection types' do
132
- column_metadata[2][3] = [:imaginary, :varchar]
133
- expect { RequestFrame.new(ExecuteRequest.new(id, column_metadata, ['hello', 42, ['foo']], :each_quorum)).write('') }.to raise_error(UnsupportedColumnTypeError)
134
- end
135
-
136
- it 'raises an error when collection values are not enumerable' do
137
- column_metadata[2][3] = [:set, :varchar]
138
- expect { RequestFrame.new(ExecuteRequest.new(id, column_metadata, ['hello', 42, 'foo'], :each_quorum)).write('') }.to raise_error(InvalidValueError)
139
- end
140
-
141
- it 'raises an error when it cannot encode the argument' do
142
- expect { ExecuteRequest.new(id, column_metadata, ['hello', 'not an int', 'foo'], :each_quorum).write('') }.to raise_error(TypeError, /cannot be encoded as INT/)
143
- end
144
- end
145
-
146
- context 'with a stream ID' do
147
- it 'encodes the stream ID in the header' do
148
- bytes = RequestFrame.new(QueryRequest.new('USE system', :all), 42).write('')
149
- bytes[2].should == "\x2a"
150
- end
151
-
152
- it 'defaults to zero' do
153
- bytes = RequestFrame.new(QueryRequest.new('USE system', :all)).write('')
154
- bytes[2].should == "\x00"
155
- end
156
-
157
- it 'raises an exception if the stream ID is outside of 0..127' do
158
- expect { RequestFrame.new(QueryRequest.new('USE system', :all), -1) }.to raise_error(InvalidStreamIdError)
159
- expect { RequestFrame.new(QueryRequest.new('USE system', :all), 128) }.to raise_error(InvalidStreamIdError)
160
- expect { RequestFrame.new(QueryRequest.new('USE system', :all), 99999999) }.to raise_error(InvalidStreamIdError)
161
- end
162
- end
163
-
164
- describe StartupRequest do
165
- describe '#to_s' do
166
- it 'returns a pretty string' do
167
- request = StartupRequest.new
168
- request.to_s.should == 'STARTUP {"CQL_VERSION"=>"3.0.0"}'
169
- end
170
- end
171
- end
172
-
173
- describe CredentialsRequest do
174
- describe '#to_s' do
175
- it 'returns a pretty string' do
176
- request = CredentialsRequest.new('foo' => 'bar', 'hello' => 'world')
177
- request.to_s.should == 'CREDENTIALS {"foo"=>"bar", "hello"=>"world"}'
178
- end
179
- end
180
-
181
- describe '#eql?' do
182
- it 'returns when the credentials are the same' do
183
- c1 = CredentialsRequest.new('username' => 'foo', 'password' => 'bar')
184
- c2 = CredentialsRequest.new('username' => 'foo', 'password' => 'bar')
185
- c2.should eql(c2)
186
- end
187
-
188
- it 'returns when the credentials are equivalent' do
189
- pending 'this would be nice, but is hardly necessary' do
190
- c1 = CredentialsRequest.new(:username => 'foo', :password => 'bar')
191
- c2 = CredentialsRequest.new('username' => 'foo', 'password' => 'bar')
192
- c1.should eql(c2)
193
- end
194
- end
195
-
196
- it 'returns false when the credentials are different' do
197
- c1 = CredentialsRequest.new('username' => 'foo', 'password' => 'world')
198
- c2 = CredentialsRequest.new('username' => 'foo', 'hello' => 'world')
199
- c1.should_not eql(c2)
200
- end
201
-
202
- it 'is aliased as ==' do
203
- c1 = CredentialsRequest.new('username' => 'foo', 'password' => 'bar')
204
- c2 = CredentialsRequest.new('username' => 'foo', 'password' => 'bar')
205
- c1.should == c2
206
- end
207
- end
208
-
209
- describe '#hash' do
210
- it 'has the same hash code as another identical object' do
211
- c1 = CredentialsRequest.new('username' => 'foo', 'password' => 'bar')
212
- c2 = CredentialsRequest.new('username' => 'foo', 'password' => 'bar')
213
- c1.hash.should == c2.hash
214
- end
215
-
216
- it 'has the same hash code as another object with equivalent credentials' do
217
- pending 'this would be nice, but is hardly necessary' do
218
- c1 = CredentialsRequest.new(:username => 'foo', :password => 'bar')
219
- c2 = CredentialsRequest.new('username' => 'foo', 'password' => 'bar')
220
- c1.hash.should == c2.hash
221
- end
222
- end
223
-
224
- it 'does not have the same hash code when the credentials are different' do
225
- c1 = CredentialsRequest.new('username' => 'foo', 'password' => 'world')
226
- c2 = CredentialsRequest.new('username' => 'foo', 'hello' => 'world')
227
- c1.hash.should_not == c2.hash
228
- end
229
- end
230
- end
231
-
232
- describe OptionsRequest do
233
- describe '#to_s' do
234
- it 'returns a pretty string' do
235
- request = OptionsRequest.new
236
- request.to_s.should == 'OPTIONS'
237
- end
238
- end
239
- end
240
-
241
- describe RegisterRequest do
242
- describe '#to_s' do
243
- it 'returns a pretty string' do
244
- request = RegisterRequest.new('TOPOLOGY_CHANGE', 'STATUS_CHANGE')
245
- request.to_s.should == 'REGISTER ["TOPOLOGY_CHANGE", "STATUS_CHANGE"]'
246
- end
247
- end
248
- end
249
-
250
- describe QueryRequest do
251
- describe '#to_s' do
252
- it 'returns a pretty string' do
253
- request = QueryRequest.new('SELECT * FROM system.peers', :local_quorum)
254
- request.to_s.should == 'QUERY "SELECT * FROM system.peers" LOCAL_QUORUM'
255
- end
256
- end
257
-
258
- describe '#eql?' do
259
- it 'returns true when the CQL and consistency are the same' do
260
- q1 = QueryRequest.new('SELECT * FROM system.peers', :two)
261
- q2 = QueryRequest.new('SELECT * FROM system.peers', :two)
262
- q2.should eql(q2)
263
- end
264
-
265
- it 'returns false when the consistency is different' do
266
- q1 = QueryRequest.new('SELECT * FROM system.peers', :two)
267
- q2 = QueryRequest.new('SELECT * FROM system.peers', :three)
268
- q1.should_not eql(q2)
269
- end
270
-
271
- it 'returns false when the CQL is different' do
272
- q1 = QueryRequest.new('SELECT * FROM system.peers', :two)
273
- q2 = QueryRequest.new('SELECT * FROM peers', :two)
274
- q1.should_not eql(q2)
275
- end
276
-
277
- it 'does not know about CQL syntax' do
278
- q1 = QueryRequest.new('SELECT * FROM system.peers', :two)
279
- q2 = QueryRequest.new('SELECT * FROM system.peers', :two)
280
- q1.should_not eql(q2)
281
- end
282
-
283
- it 'is aliased as ==' do
284
- q1 = QueryRequest.new('SELECT * FROM system.peers', :two)
285
- q2 = QueryRequest.new('SELECT * FROM system.peers', :two)
286
- q1.should == q2
287
- end
288
- end
289
-
290
- describe '#hash' do
291
- it 'has the same hash code as another identical object' do
292
- q1 = QueryRequest.new('SELECT * FROM system.peers', :two)
293
- q2 = QueryRequest.new('SELECT * FROM system.peers', :two)
294
- q1.hash.should == q2.hash
295
- end
296
-
297
- it 'does not have the same hash code when the consistency is different' do
298
- q1 = QueryRequest.new('SELECT * FROM system.peers', :two)
299
- q2 = QueryRequest.new('SELECT * FROM system.peers', :three)
300
- q1.hash.should_not == q2.hash
301
- end
302
-
303
- it 'does not have the same hash code when the CQL is different' do
304
- q1 = QueryRequest.new('SELECT * FROM system.peers', :two)
305
- q2 = QueryRequest.new('SELECT * FROM peers', :two)
306
- q1.hash.should_not == q2.hash
307
- end
308
- end
309
- end
310
-
311
- describe PrepareRequest do
312
- describe '#to_s' do
313
- it 'returns a pretty string' do
314
- request = PrepareRequest.new('UPDATE users SET email = ? WHERE user_name = ?')
315
- request.to_s.should == 'PREPARE "UPDATE users SET email = ? WHERE user_name = ?"'
316
- end
317
- end
318
-
319
- describe '#eql?' do
320
- it 'returns true when the CQL is the same' do
321
- p1 = PrepareRequest.new('SELECT * FROM system.peers')
322
- p2 = PrepareRequest.new('SELECT * FROM system.peers')
323
- p1.should eql(p2)
324
- end
325
-
326
- it 'returns false when the CQL is different' do
327
- p1 = PrepareRequest.new('SELECT * FROM system.peers')
328
- p2 = PrepareRequest.new('SELECT * FROM peers')
329
- p1.should_not eql(p2)
330
- end
331
-
332
- it 'does not know about CQL syntax' do
333
- p1 = PrepareRequest.new('SELECT * FROM system.peers')
334
- p2 = PrepareRequest.new('SELECT * FROM system.peers')
335
- p1.should_not eql(p2)
336
- end
337
-
338
- it 'is aliased as ==' do
339
- p1 = PrepareRequest.new('SELECT * FROM system.peers')
340
- p2 = PrepareRequest.new('SELECT * FROM system.peers')
341
- p1.should == p2
342
- end
343
- end
344
-
345
- describe '#hash' do
346
- it 'has the same hash code as another identical object' do
347
- p1 = PrepareRequest.new('SELECT * FROM system.peers')
348
- p2 = PrepareRequest.new('SELECT * FROM system.peers')
349
- p1.hash.should == p2.hash
350
- end
351
-
352
- it 'does not have the same hash code when the CQL is different' do
353
- p1 = PrepareRequest.new('SELECT * FROM system.peers')
354
- p2 = PrepareRequest.new('SELECT * FROM peers')
355
- p1.hash.should_not == p2.hash
356
- end
357
- end
358
- end
359
-
360
- describe ExecuteRequest do
361
- let :id do
362
- "\xCAH\x7F\x1Ez\x82\xD2<N\x8A\xF35Qq\xA5/"
363
- end
364
-
365
- let :metadata do
366
- [
367
- ['ks', 'tbl', 'col1', :varchar],
368
- ['ks', 'tbl', 'col2', :int],
369
- ['ks', 'tbl', 'col3', :varchar]
370
- ]
371
- end
372
-
373
- let :values do
374
- ['hello', 42, 'foo']
375
- end
376
-
377
- describe '#to_s' do
378
- it 'returns a pretty string' do
379
- request = ExecuteRequest.new(id, metadata, values, :each_quorum)
380
- request.to_s.should == 'EXECUTE ca487f1e7a82d23c4e8af3355171a52f ["hello", 42, "foo"] EACH_QUORUM'
381
- end
382
- end
383
-
384
- describe '#eql?' do
385
- it 'returns true when the ID, metadata, values and consistency are the same' do
386
- e1 = ExecuteRequest.new(id, metadata, values, :one)
387
- e2 = ExecuteRequest.new(id, metadata, values, :one)
388
- e1.should eql(e2)
389
- end
390
-
391
- it 'returns false when the ID is different' do
392
- e1 = ExecuteRequest.new(id, metadata, values, :one)
393
- e2 = ExecuteRequest.new(id.reverse, metadata, values, :one)
394
- e1.should_not eql(e2)
395
- end
396
-
397
- it 'returns false when the metadata is different' do
398
- e1 = ExecuteRequest.new(id, metadata, values, :one)
399
- e2 = ExecuteRequest.new(id, metadata.reverse, values, :one)
400
- e1.should_not eql(e2)
401
- end
402
-
403
- it 'returns false when the values are different' do
404
- e1 = ExecuteRequest.new(id, metadata, values, :one)
405
- e2 = ExecuteRequest.new(id, metadata, values.reverse, :one)
406
- e1.should_not eql(e2)
407
- end
408
-
409
- it 'returns false when the consistency is different' do
410
- e1 = ExecuteRequest.new(id, metadata, values, :one)
411
- e2 = ExecuteRequest.new(id, metadata, values, :two)
412
- e1.should_not eql(e2)
413
- end
414
-
415
- it 'is aliased as ==' do
416
- e1 = ExecuteRequest.new(id, metadata, values, :one)
417
- e2 = ExecuteRequest.new(id, metadata, values, :one)
418
- e1.should == e2
419
- end
420
- end
421
-
422
- describe '#hash' do
423
- it 'has the same hash code as another identical object' do
424
- e1 = ExecuteRequest.new(id, metadata, values, :one)
425
- e2 = ExecuteRequest.new(id, metadata, values, :one)
426
- e1.hash.should == e2.hash
427
- end
428
-
429
- it 'does not have the same hash code when the ID is different' do
430
- e1 = ExecuteRequest.new(id, metadata, values, :one)
431
- e2 = ExecuteRequest.new(id.reverse, metadata, values, :one)
432
- e1.hash.should_not == e2.hash
433
- end
434
-
435
- it 'does not have the same hash code when the metadata is different' do
436
- e1 = ExecuteRequest.new(id, metadata, values, :one)
437
- e2 = ExecuteRequest.new(id, metadata.reverse, values, :one)
438
- e1.hash.should_not == e2.hash
439
- end
440
-
441
- it 'does not have the same hash code when the values are different' do
442
- e1 = ExecuteRequest.new(id, metadata, values, :one)
443
- e2 = ExecuteRequest.new(id, metadata, values.reverse, :one)
444
- e1.hash.should_not == e2.hash
445
- end
446
-
447
- it 'does not have the same hash code when the consistency is different' do
448
- e1 = ExecuteRequest.new(id, metadata, values, :one)
449
- e2 = ExecuteRequest.new(id, metadata, values, :two)
450
- e1.hash.should_not == e2.hash
451
- end
452
- end
453
- end
454
- end
455
- end
456
- end