cequel 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/Gemfile.lock +19 -12
  4. data/Rakefile +5 -1
  5. data/lib/cequel/record/data_set_builder.rb +9 -2
  6. data/lib/cequel/record/record_set.rb +16 -2
  7. data/lib/cequel/record/tasks.rb +6 -2
  8. data/lib/cequel/version.rb +1 -1
  9. data/spec/examples/metal/data_set_spec.rb +113 -106
  10. data/spec/examples/metal/keyspace_spec.rb +7 -15
  11. data/spec/examples/record/associations_spec.rb +30 -30
  12. data/spec/examples/record/callbacks_spec.rb +25 -25
  13. data/spec/examples/record/dirty_spec.rb +11 -10
  14. data/spec/examples/record/list_spec.rb +33 -33
  15. data/spec/examples/record/map_spec.rb +57 -41
  16. data/spec/examples/record/mass_assignment_spec.rb +5 -5
  17. data/spec/examples/record/naming_spec.rb +2 -2
  18. data/spec/examples/record/persistence_spec.rb +23 -23
  19. data/spec/examples/record/properties_spec.rb +19 -19
  20. data/spec/examples/record/record_set_spec.rb +155 -151
  21. data/spec/examples/record/schema_spec.rb +7 -7
  22. data/spec/examples/record/scoped_spec.rb +2 -2
  23. data/spec/examples/record/serialization_spec.rb +2 -2
  24. data/spec/examples/record/set_spec.rb +27 -23
  25. data/spec/examples/record/validations_spec.rb +13 -13
  26. data/spec/examples/schema/table_reader_spec.rb +85 -79
  27. data/spec/examples/schema/table_synchronizer_spec.rb +9 -9
  28. data/spec/examples/schema/table_updater_spec.rb +17 -17
  29. data/spec/examples/schema/table_writer_spec.rb +33 -33
  30. data/spec/examples/type_spec.rb +55 -55
  31. data/spec/support/helpers.rb +18 -10
  32. metadata +18 -5
  33. data/spec/shared/readable_dictionary.rb +0 -192
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 72e24f9cd8e2717c595a60f3826bf274f50241cb
4
- data.tar.gz: e1a9ea1d681b534945d96ab4f0d87af7b7a08ef0
3
+ metadata.gz: 972c48841d081a702bd2bb4dd97cc94a7da02f42
4
+ data.tar.gz: 0d75dca1e13d7bb1856e4f0ea6d7af3795a95959
5
5
  SHA512:
6
- metadata.gz: 59a1423af086bf7f369f10efa5f37f0fb5c5c0d5c5235d1dfa7aeca84f60ae41712b89da735d5e59b3bdef4f200c8ea1658ba26b4d939dcd399370b4e7004f02
7
- data.tar.gz: 8e5cf589b91e25dd6533c06241b862723a81b6a738d6f1df31d4a7fc0d71a9693ef995b08c1d5c27eb80c3b7d6b7c51398f59345286a6a03fb94ccc1140c9d3e
6
+ metadata.gz: c58f9ec3bb7cf8c308d38eb091d18535b5051c8301d7b84e33beb8e03abfc01f8ca8ea4711b894980fe6df760055e10b8fba78a9639fa0bdb7dba018cb31624a
7
+ data.tar.gz: e4b13cb2ee0ed6b1971fefbaa5609107289722bd788c0ae4088e663fe37b56d40d094673941ce49b82afdb2b3e40990a48749dba93640cdc3da81a3b71d4082e
@@ -1,3 +1,9 @@
1
+ ## 1.4.3
2
+
3
+ * Make Rake tasks work without Rails
4
+ * `RecordSet#reverse` and `find_in_batches` respect clustering order defined in
5
+ schema
6
+
1
7
  ## 1.4.2
2
8
 
3
9
  * Allow setting a key attribute to what it already is
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cequel (1.4.2)
4
+ cequel (1.4.3)
5
5
  activemodel (>= 3.1, < 5.0)
6
6
  cql-rb (>= 1.2, < 3.0)
7
7
 
@@ -44,7 +44,7 @@ GEM
44
44
  json (1.8.1)
45
45
  json (1.8.1-java)
46
46
  method_source (0.8.2)
47
- minitest (5.4.1)
47
+ minitest (5.4.2)
48
48
  parser (2.1.9)
49
49
  ast (>= 1.1, < 3.0)
50
50
  slop (~> 3.4, >= 3.4.5)
@@ -62,14 +62,21 @@ GEM
62
62
  racc (1.4.12)
63
63
  rainbow (2.0.0)
64
64
  rake (10.3.2)
65
- rspec (2.99.0)
66
- rspec-core (~> 2.99.0)
67
- rspec-expectations (~> 2.99.0)
68
- rspec-mocks (~> 2.99.0)
69
- rspec-core (2.99.2)
70
- rspec-expectations (2.99.2)
71
- diff-lcs (>= 1.1.3, < 2.0)
72
- rspec-mocks (2.99.2)
65
+ rspec (3.1.0)
66
+ rspec-core (~> 3.1.0)
67
+ rspec-expectations (~> 3.1.0)
68
+ rspec-mocks (~> 3.1.0)
69
+ rspec-core (3.1.5)
70
+ rspec-support (~> 3.1.0)
71
+ rspec-expectations (3.1.2)
72
+ diff-lcs (>= 1.2.0, < 2.0)
73
+ rspec-support (~> 3.1.0)
74
+ rspec-its (1.0.1)
75
+ rspec-core (>= 2.99.0.beta1)
76
+ rspec-expectations (>= 2.99.0.beta1)
77
+ rspec-mocks (3.1.2)
78
+ rspec-support (~> 3.1.0)
79
+ rspec-support (3.1.1)
73
80
  rubocop (0.19.1)
74
81
  json (>= 1.7.7, < 2)
75
82
  parser (~> 2.1.7)
@@ -284,7 +291,6 @@ GEM
284
291
  ffi
285
292
  thor (0.19.1)
286
293
  thread_safe (0.3.4)
287
- thread_safe (0.3.4-java)
288
294
  timecop (0.7.1)
289
295
  tzinfo (1.2.2)
290
296
  thread_safe (~> 0.1)
@@ -304,7 +310,8 @@ DEPENDENCIES
304
310
  psych (~> 2.0)
305
311
  racc (~> 1.4)
306
312
  rake (~> 10.1)
307
- rspec (~> 2.0)
313
+ rspec (~> 3.1)
314
+ rspec-its (~> 1.0)
308
315
  rubocop (~> 0.19.0)
309
316
  rubysl (~> 2.0)
310
317
  timecop (~> 0.7)
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ task :default => :release
11
11
  task :release => [
12
12
  :verify_changelog,
13
13
  :rubocop,
14
- :wwtd,
14
+ :"test:all",
15
15
  :build,
16
16
  :tag,
17
17
  :update_stable,
@@ -67,6 +67,10 @@ namespace :test do
67
67
  t.rspec_opts = '--fail-fast --format=progress'
68
68
  t.fail_on_error = true
69
69
  end
70
+
71
+ task :all do
72
+ system('bundle', 'exec', 'wwtd', '--parallel')
73
+ end
70
74
  end
71
75
 
72
76
  desc 'Update changelog'
@@ -51,7 +51,7 @@ module Cequel
51
51
  :scoped_key_names, :scoped_key_values,
52
52
  :scoped_indexed_column, :lower_bound,
53
53
  :upper_bound, :reversed?, :order_by_column,
54
- :query_consistency
54
+ :query_consistency, :ascends_by?
55
55
 
56
56
  private
57
57
 
@@ -85,7 +85,10 @@ module Cequel
85
85
  end
86
86
 
87
87
  def add_order
88
- self.data_set = data_set.order(order_by_column => :desc) if reversed?
88
+ column = order_by_column
89
+ if column.present? && reversed?
90
+ self.data_set = data_set.order(column.name => sort_direction)
91
+ end
89
92
  end
90
93
 
91
94
  def set_consistency
@@ -93,6 +96,10 @@ module Cequel
93
96
  self.data_set = data_set.consistency(query_consistency)
94
97
  end
95
98
  end
99
+
100
+ def sort_direction
101
+ ascends_by?(order_by_column) ? :asc : :desc
102
+ end
96
103
  end
97
104
  end
98
105
  end
@@ -656,7 +656,21 @@ module Cequel
656
656
  protected :reversed?
657
657
 
658
658
  def next_batch_from(row)
659
- reversed? ? before(row[range_key_name]) : after(row[range_key_name])
659
+ range_key_value = row[range_key_name]
660
+ if ascends_by?(range_key_column)
661
+ after(range_key_value)
662
+ else
663
+ before(range_key_value)
664
+ end
665
+ end
666
+
667
+ def ascends_by?(column)
668
+ !descends_by?(column)
669
+ end
670
+
671
+ def descends_by?(column)
672
+ column.clustering_column? &&
673
+ (reversed? ^ (column.clustering_order == :desc))
660
674
  end
661
675
 
662
676
  def find_nested_batches_from(row, options, &block)
@@ -837,7 +851,7 @@ module Cequel
837
851
 
838
852
  def order_by_column
839
853
  if target_class.clustering_columns.any?
840
- target_class.clustering_columns.first.name
854
+ target_class.clustering_columns.first
841
855
  end
842
856
  end
843
857
 
@@ -1,4 +1,7 @@
1
1
  # -*- encoding : utf-8 -*-
2
+ task :environment do
3
+ end
4
+
2
5
  namespace :cequel do
3
6
  namespace :keyspace do
4
7
  desc 'Initialize Cassandra keyspace'
@@ -20,8 +23,9 @@ namespace :cequel do
20
23
  watch_stack = ActiveSupport::Dependencies::WatchStack.new
21
24
 
22
25
  migration_table_names = Set[]
23
- models_dir_path = "#{Rails.root.join('app', 'models')}/"
24
- model_files = Dir.glob(Rails.root.join('app', 'models', '**', '*.rb'))
26
+ project_root = defined?(Rails) ? Rails.root : Dir.pwd
27
+ models_dir_path = "#{File.expand_path('app/models', project_root)}/"
28
+ model_files = Dir.glob(File.join(models_dir_path, '**', '*.rb'))
25
29
  model_files.sort.each do |file|
26
30
  watch_namespaces = ["Object"]
27
31
  model_file_name = file.sub(/^#{Regexp.escape(models_dir_path)}/, "")
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module Cequel
3
3
  # The current version of the library
4
- VERSION = '1.4.2'
4
+ VERSION = '1.4.3'
5
5
  end
@@ -49,39 +49,39 @@ describe Cequel::Metal::DataSet do
49
49
 
50
50
  it 'should insert a row' do
51
51
  cequel[:posts].insert(row)
52
- cequel[:posts].where(row_keys).first[:title].should == 'Fun times'
52
+ expect(cequel[:posts].where(row_keys).first[:title]).to eq('Fun times')
53
53
  end
54
54
 
55
55
  it 'should correctly insert a list' do
56
56
  cequel[:posts].insert(row)
57
- cequel[:posts].where(row_keys).first[:categories].
58
- should == ['Fun', 'Profit']
57
+ expect(cequel[:posts].where(row_keys).first[:categories]).
58
+ to eq(['Fun', 'Profit'])
59
59
  end
60
60
 
61
61
  it 'should correctly insert a set' do
62
62
  cequel[:posts].insert(row)
63
- cequel[:posts].where(row_keys).first[:tags].
64
- should == Set['cassandra', 'big-data']
63
+ expect(cequel[:posts].where(row_keys).first[:tags]).
64
+ to eq(Set['cassandra', 'big-data'])
65
65
  end
66
66
 
67
67
  it 'should correctly insert a map' do
68
68
  cequel[:posts].insert(row)
69
- cequel[:posts].where(row_keys).first[:trackbacks].
70
- should == row[:trackbacks]
69
+ expect(cequel[:posts].where(row_keys).first[:trackbacks]).
70
+ to eq(row[:trackbacks])
71
71
  end
72
72
 
73
73
  it 'should include ttl argument' do
74
74
  cequel[:posts].insert(row, :ttl => 10.minutes)
75
- cequel[:posts].select_ttl(:title).where(row_keys).first.ttl(:title).
76
- should be_within(5).of(10.minutes)
75
+ expect(cequel[:posts].select_ttl(:title).where(row_keys).first.ttl(:title)).
76
+ to be_within(5).of(10.minutes)
77
77
  end
78
78
 
79
79
  it 'should include timestamp argument' do
80
80
  cequel.schema.truncate_table(:posts)
81
81
  time = 1.day.ago
82
82
  cequel[:posts].insert(row, :timestamp => time)
83
- cequel[:posts].select_writetime(:title).where(row_keys).
84
- first.writetime(:title).should == (time.to_f * 1_000_000).to_i
83
+ expect(cequel[:posts].select_writetime(:title).where(row_keys).
84
+ first.writetime(:title)).to eq((time.to_f * 1_000_000).to_i)
85
85
  end
86
86
 
87
87
  it 'should insert row with given consistency' do
@@ -96,8 +96,8 @@ describe Cequel::Metal::DataSet do
96
96
  cequel[:posts].insert(row, :ttl => 600, :timestamp => time)
97
97
  result = cequel[:posts].select_ttl(:title).select_writetime(:title).
98
98
  where(row_keys).first
99
- result.writetime(:title).should == (time.to_f * 1_000_000).to_i
100
- result.ttl(:title).should be_within(5).of(10.minutes)
99
+ expect(result.writetime(:title)).to eq((time.to_f * 1_000_000).to_i)
100
+ expect(result.ttl(:title)).to be_within(5).of(10.minutes)
101
101
  end
102
102
  end
103
103
 
@@ -105,8 +105,8 @@ describe Cequel::Metal::DataSet do
105
105
  it 'should send basic update statement' do
106
106
  cequel[:posts].where(row_keys).
107
107
  update(:title => 'Fun times', :body => 'Fun')
108
- cequel[:posts].where(row_keys).
109
- first[:title].should == 'Fun times'
108
+ expect(cequel[:posts].where(row_keys).
109
+ first[:title]).to eq('Fun times')
110
110
  end
111
111
 
112
112
  it 'should send update statement with options' do
@@ -120,8 +120,8 @@ describe Cequel::Metal::DataSet do
120
120
  select_ttl(:title).select_writetime(:title).
121
121
  where(row_keys).first
122
122
 
123
- row.ttl(:title).should be_within(5).of(10.minutes)
124
- row.writetime(:title).should == (time.to_f * 1_000_000).to_i
123
+ expect(row.ttl(:title)).to be_within(5).of(10.minutes)
124
+ expect(row.writetime(:title)).to eq((time.to_f * 1_000_000).to_i)
125
125
  end
126
126
 
127
127
  it 'should send update statement with given consistency' do
@@ -134,14 +134,14 @@ describe Cequel::Metal::DataSet do
134
134
  it 'should overwrite list column' do
135
135
  cequel[:posts].where(row_keys).
136
136
  update(categories: ['Big Data', 'Cassandra'])
137
- cequel[:posts].where(row_keys).first[:categories].
138
- should == ['Big Data', 'Cassandra']
137
+ expect(cequel[:posts].where(row_keys).first[:categories]).
138
+ to eq(['Big Data', 'Cassandra'])
139
139
  end
140
140
 
141
141
  it 'should overwrite set column' do
142
142
  cequel[:posts].where(row_keys).update(tags: Set['big-data', 'nosql'])
143
- cequel[:posts].where(row_keys).first[:tags].
144
- should == Set['big-data', 'nosql']
143
+ expect(cequel[:posts].where(row_keys).first[:tags]).
144
+ to eq(Set['big-data', 'nosql'])
145
145
  end
146
146
 
147
147
  it 'should overwrite map column' do
@@ -149,8 +149,8 @@ describe Cequel::Metal::DataSet do
149
149
  time2 = Time.at(10.minutes.ago.to_i)
150
150
  cequel[:posts].where(row_keys).update(
151
151
  trackbacks: {time1 => 'foo', time2 => 'bar'})
152
- cequel[:posts].where(row_keys).first[:trackbacks].
153
- should == {time1 => 'foo', time2 => 'bar'}
152
+ expect(cequel[:posts].where(row_keys).first[:trackbacks]).
153
+ to eq({time1 => 'foo', time2 => 'bar'})
154
154
  end
155
155
 
156
156
  it 'should perform various types of update in one go' do
@@ -162,9 +162,9 @@ describe Cequel::Metal::DataSet do
162
162
  set(title: 'Bigger Data')
163
163
  list_append(:categories, 'Fault-Tolerance')
164
164
  end
165
- cequel[:posts].where(row_keys).first[:title].should == 'Bigger Data'
166
- cequel[:posts].where(row_keys).first[:categories].
167
- should == %w(Scalability Fault-Tolerance)
165
+ expect(cequel[:posts].where(row_keys).first[:title]).to eq('Bigger Data')
166
+ expect(cequel[:posts].where(row_keys).first[:categories]).
167
+ to eq(%w(Scalability Fault-Tolerance))
168
168
  end
169
169
 
170
170
  it 'should use the last value set for a given column' do
@@ -176,7 +176,7 @@ describe Cequel::Metal::DataSet do
176
176
  set(title: 'Bigger Data')
177
177
  set(title: 'Even Bigger Data')
178
178
  end
179
- cequel[:posts].where(row_keys).first[:title].should == 'Even Bigger Data'
179
+ expect(cequel[:posts].where(row_keys).first[:title]).to eq('Even Bigger Data')
180
180
  end
181
181
  end
182
182
 
@@ -186,8 +186,9 @@ describe Cequel::Metal::DataSet do
186
186
  row_keys.merge(categories: ['Big Data', 'Cassandra']))
187
187
  cequel[:posts].where(row_keys).
188
188
  list_prepend(:categories, 'Scalability')
189
- cequel[:posts].where(row_keys).first[:categories].should ==
189
+ expect(cequel[:posts].where(row_keys).first[:categories]).to eq(
190
190
  ['Scalability', 'Big Data', 'Cassandra']
191
+ )
191
192
  end
192
193
 
193
194
  it 'should prepend multiple elements to list column' do
@@ -195,8 +196,9 @@ describe Cequel::Metal::DataSet do
195
196
  row_keys.merge(categories: ['Big Data', 'Cassandra']))
196
197
  cequel[:posts].where(row_keys).
197
198
  list_prepend(:categories, ['Scalability', 'Partition Tolerance'])
198
- cequel[:posts].where(row_keys).first[:categories].should ==
199
+ expect(cequel[:posts].where(row_keys).first[:categories]).to eq(
199
200
  ['Partition Tolerance', 'Scalability', 'Big Data', 'Cassandra']
201
+ )
200
202
  end
201
203
  end
202
204
 
@@ -206,8 +208,9 @@ describe Cequel::Metal::DataSet do
206
208
  row_keys.merge(categories: ['Big Data', 'Cassandra']))
207
209
  cequel[:posts].where(row_keys).
208
210
  list_append(:categories, 'Scalability')
209
- cequel[:posts].where(row_keys).first[:categories].should ==
211
+ expect(cequel[:posts].where(row_keys).first[:categories]).to eq(
210
212
  ['Big Data', 'Cassandra', 'Scalability']
213
+ )
211
214
  end
212
215
 
213
216
  it 'should append multiple elements to list column' do
@@ -215,8 +218,9 @@ describe Cequel::Metal::DataSet do
215
218
  row_keys.merge(categories: ['Big Data', 'Cassandra']))
216
219
  cequel[:posts].where(row_keys).
217
220
  list_append(:categories, ['Scalability', 'Partition Tolerance'])
218
- cequel[:posts].where(row_keys).first[:categories].should ==
221
+ expect(cequel[:posts].where(row_keys).first[:categories]).to eq(
219
222
  ['Big Data', 'Cassandra', 'Scalability', 'Partition Tolerance']
223
+ )
220
224
  end
221
225
  end
222
226
 
@@ -226,8 +230,9 @@ describe Cequel::Metal::DataSet do
226
230
  row_keys.merge(categories: ['Big Data', 'Cassandra', 'Scalability']))
227
231
  cequel[:posts].where(row_keys).
228
232
  list_replace(:categories, 1, 'C*')
229
- cequel[:posts].where(row_keys).first[:categories].should ==
233
+ expect(cequel[:posts].where(row_keys).first[:categories]).to eq(
230
234
  ['Big Data', 'C*', 'Scalability']
235
+ )
231
236
  end
232
237
  end
233
238
 
@@ -237,8 +242,9 @@ describe Cequel::Metal::DataSet do
237
242
  row_keys.merge(categories: ['Big Data', 'Cassandra', 'Scalability']))
238
243
  cequel[:posts].where(row_keys).
239
244
  list_remove(:categories, 'Cassandra')
240
- cequel[:posts].where(row_keys).first[:categories].should ==
245
+ expect(cequel[:posts].where(row_keys).first[:categories]).to eq(
241
246
  ['Big Data', 'Scalability']
247
+ )
242
248
  end
243
249
 
244
250
  it 'should remove from list by multiple values' do
@@ -246,8 +252,9 @@ describe Cequel::Metal::DataSet do
246
252
  row_keys.merge(categories: ['Big Data', 'Cassandra', 'Scalability']))
247
253
  cequel[:posts].where(row_keys).
248
254
  list_remove(:categories, ['Big Data', 'Cassandra'])
249
- cequel[:posts].where(row_keys).first[:categories].should ==
255
+ expect(cequel[:posts].where(row_keys).first[:categories]).to eq(
250
256
  ['Scalability']
257
+ )
251
258
  end
252
259
  end
253
260
 
@@ -256,16 +263,16 @@ describe Cequel::Metal::DataSet do
256
263
  cequel[:posts].insert(
257
264
  row_keys.merge(tags: Set['big-data', 'nosql']))
258
265
  cequel[:posts].where(row_keys).set_add(:tags, 'cassandra')
259
- cequel[:posts].where(row_keys).first[:tags].
260
- should == Set['big-data', 'nosql', 'cassandra']
266
+ expect(cequel[:posts].where(row_keys).first[:tags]).
267
+ to eq(Set['big-data', 'nosql', 'cassandra'])
261
268
  end
262
269
 
263
270
  it 'should add multiple elements to set' do
264
271
  cequel[:posts].insert(
265
272
  row_keys.merge(tags: Set['big-data', 'nosql']))
266
273
  cequel[:posts].where(row_keys).set_add(:tags, 'cassandra')
267
- cequel[:posts].where(row_keys).first[:tags].
268
- should == Set['big-data', 'nosql', 'cassandra']
274
+ expect(cequel[:posts].where(row_keys).first[:tags]).
275
+ to eq(Set['big-data', 'nosql', 'cassandra'])
269
276
  end
270
277
  end
271
278
 
@@ -274,8 +281,8 @@ describe Cequel::Metal::DataSet do
274
281
  cequel[:posts].insert(
275
282
  row_keys.merge(tags: Set['big-data', 'nosql', 'cassandra']))
276
283
  cequel[:posts].where(row_keys).set_remove(:tags, 'cassandra')
277
- cequel[:posts].where(row_keys).first[:tags].
278
- should == Set['big-data', 'nosql']
284
+ expect(cequel[:posts].where(row_keys).first[:tags]).
285
+ to eq(Set['big-data', 'nosql'])
279
286
  end
280
287
 
281
288
  it 'should remove multiple elements from set' do
@@ -283,8 +290,8 @@ describe Cequel::Metal::DataSet do
283
290
  row_keys.merge(tags: Set['big-data', 'nosql', 'cassandra']))
284
291
  cequel[:posts].where(row_keys).
285
292
  set_remove(:tags, Set['nosql', 'cassandra'])
286
- cequel[:posts].where(row_keys).first[:tags].
287
- should == Set['big-data']
293
+ expect(cequel[:posts].where(row_keys).first[:tags]).
294
+ to eq(Set['big-data'])
288
295
  end
289
296
  end
290
297
 
@@ -296,8 +303,8 @@ describe Cequel::Metal::DataSet do
296
303
  cequel[:posts].insert(row_keys.merge(
297
304
  trackbacks: {time1 => 'foo', time2 => 'bar'}))
298
305
  cequel[:posts].where(row_keys).map_update(:trackbacks, time3 => 'baz')
299
- cequel[:posts].where(row_keys).first[:trackbacks].
300
- should == {time1 => 'foo', time2 => 'bar', time3 => 'baz'}
306
+ expect(cequel[:posts].where(row_keys).first[:trackbacks]).
307
+ to eq({time1 => 'foo', time2 => 'bar', time3 => 'baz'})
301
308
  end
302
309
 
303
310
  it 'should update specified map key with multiple values' do
@@ -308,8 +315,8 @@ describe Cequel::Metal::DataSet do
308
315
  trackbacks: {time1 => 'foo', time2 => 'bar'}))
309
316
  cequel[:posts].where(row_keys).
310
317
  map_update(:trackbacks, time1 => 'FOO', time3 => 'baz')
311
- cequel[:posts].where(row_keys).first[:trackbacks].
312
- should == {time1 => 'FOO', time2 => 'bar', time3 => 'baz'}
318
+ expect(cequel[:posts].where(row_keys).first[:trackbacks]).
319
+ to eq({time1 => 'FOO', time2 => 'bar', time3 => 'baz'})
313
320
  end
314
321
  end
315
322
 
@@ -323,8 +330,8 @@ describe Cequel::Metal::DataSet do
323
330
 
324
331
  row = cequel[:post_activity].where(row_keys).first
325
332
 
326
- row[:visits].should == 1
327
- row[:tweets].should == 2
333
+ expect(row[:visits]).to eq(1)
334
+ expect(row[:tweets]).to eq(2)
328
335
  end
329
336
  end
330
337
 
@@ -336,8 +343,8 @@ describe Cequel::Metal::DataSet do
336
343
  decrement(visits: 1, tweets: 2)
337
344
 
338
345
  row = cequel[:post_activity].where(row_keys).first
339
- row[:visits].should == -1
340
- row[:tweets].should == -2
346
+ expect(row[:visits]).to eq(-1)
347
+ expect(row[:tweets]).to eq(-2)
341
348
  end
342
349
  end
343
350
 
@@ -349,14 +356,14 @@ describe Cequel::Metal::DataSet do
349
356
 
350
357
  it 'should send basic delete statement' do
351
358
  cequel[:posts].where(row_keys).delete
352
- cequel[:posts].where(row_keys).first.should be_nil
359
+ expect(cequel[:posts].where(row_keys).first).to be_nil
353
360
  end
354
361
 
355
362
  it 'should send delete statement for specified columns' do
356
363
  cequel[:posts].where(row_keys).delete(:body)
357
364
  row = cequel[:posts].where(row_keys).first
358
- row[:body].should be_nil
359
- row[:title].should == 'Big Data'
365
+ expect(row[:body]).to be_nil
366
+ expect(row[:title]).to eq('Big Data')
360
367
  end
361
368
 
362
369
  it 'should send delete statement with writetime option' do
@@ -366,7 +373,7 @@ describe Cequel::Metal::DataSet do
366
373
  :body, :timestamp => time
367
374
  )
368
375
  row = cequel[:posts].select(:body).where(row_keys).first
369
- row[:body].should == 'It\'s big.'
376
+ expect(row[:body]).to eq('It\'s big.')
370
377
  # This means timestamp is working, since the earlier timestamp would cause
371
378
  # Cassandra to ignore the deletion
372
379
  end
@@ -383,16 +390,16 @@ describe Cequel::Metal::DataSet do
383
390
  cequel[:posts].
384
391
  insert(row_keys.merge(categories: ['Big Data', 'NoSQL', 'Cassandra']))
385
392
  cequel[:posts].where(row_keys).list_remove_at(:categories, 1)
386
- cequel[:posts].where(row_keys).first[:categories].
387
- should == ['Big Data', 'Cassandra']
393
+ expect(cequel[:posts].where(row_keys).first[:categories]).
394
+ to eq(['Big Data', 'Cassandra'])
388
395
  end
389
396
 
390
397
  it 'should remove element at specified positions from list' do
391
398
  cequel[:posts].
392
399
  insert(row_keys.merge(categories: ['Big Data', 'NoSQL', 'Cassandra']))
393
400
  cequel[:posts].where(row_keys).list_remove_at(:categories, 0, 2)
394
- cequel[:posts].where(row_keys).first[:categories].
395
- should == ['NoSQL']
401
+ expect(cequel[:posts].where(row_keys).first[:categories]).
402
+ to eq(['NoSQL'])
396
403
  end
397
404
  end
398
405
 
@@ -404,8 +411,8 @@ describe Cequel::Metal::DataSet do
404
411
  cequel[:posts].insert(row_keys.merge(
405
412
  trackbacks: {time1 => 'foo', time2 => 'bar', time3 => 'baz'}))
406
413
  cequel[:posts].where(row_keys).map_remove(:trackbacks, time2)
407
- cequel[:posts].where(row_keys).first[:trackbacks].
408
- should == {time1 => 'foo', time3 => 'baz'}
414
+ expect(cequel[:posts].where(row_keys).first[:trackbacks]).
415
+ to eq({time1 => 'foo', time3 => 'baz'})
409
416
  end
410
417
 
411
418
  it 'should remove multiple elements from a map' do
@@ -415,14 +422,14 @@ describe Cequel::Metal::DataSet do
415
422
  cequel[:posts].insert(row_keys.merge(
416
423
  trackbacks: {time1 => 'foo', time2 => 'bar', time3 => 'baz'}))
417
424
  cequel[:posts].where(row_keys).map_remove(:trackbacks, time1, time3)
418
- cequel[:posts].where(row_keys).first[:trackbacks].
419
- should == {time2 => 'bar'}
425
+ expect(cequel[:posts].where(row_keys).first[:trackbacks]).
426
+ to eq({time2 => 'bar'})
420
427
  end
421
428
  end
422
429
 
423
430
  describe '#cql' do
424
431
  it 'should generate select statement with all columns' do
425
- cequel[:posts].cql.should == ['SELECT * FROM posts']
432
+ expect(cequel[:posts].cql).to eq(['SELECT * FROM posts'])
426
433
  end
427
434
  end
428
435
 
@@ -436,18 +443,18 @@ describe Cequel::Metal::DataSet do
436
443
  end
437
444
 
438
445
  it 'should generate select statement with given columns' do
439
- cequel[:posts].select(:title, :body).where(row_keys).first.
440
- keys.should == %w(title body)
446
+ expect(cequel[:posts].select(:title, :body).where(row_keys).first.
447
+ keys).to eq(%w(title body))
441
448
  end
442
449
 
443
450
  it 'should accept array argument' do
444
- cequel[:posts].select([:title, :body]).where(row_keys).first.
445
- keys.should == %w(title body)
451
+ expect(cequel[:posts].select([:title, :body]).where(row_keys).first.
452
+ keys).to eq(%w(title body))
446
453
  end
447
454
 
448
455
  it 'should combine multiple selects' do
449
- cequel[:posts].select(:title).select(:body).where(row_keys).first.
450
- keys.should == %w(title body)
456
+ expect(cequel[:posts].select(:title).select(:body).where(row_keys).first.
457
+ keys).to eq(%w(title body))
451
458
  end
452
459
  end
453
460
 
@@ -461,8 +468,8 @@ describe Cequel::Metal::DataSet do
461
468
  end
462
469
 
463
470
  it 'should override select statement with given columns' do
464
- cequel[:posts].select(:title, :body).select!(:published_at).
465
- where(row_keys).first.keys.should == %w(published_at)
471
+ expect(cequel[:posts].select(:title, :body).select!(:published_at).
472
+ where(row_keys).first.keys).to eq(%w(published_at))
466
473
  end
467
474
  end
468
475
 
@@ -476,15 +483,15 @@ describe Cequel::Metal::DataSet do
476
483
  end
477
484
 
478
485
  it 'should build WHERE statement from hash' do
479
- cequel[:posts].where(blog_subdomain: row_keys[:blog_subdomain]).
480
- first[:title].should == 'Big Data'
481
- cequel[:posts].where(blog_subdomain: 'foo').first.should be_nil
486
+ expect(cequel[:posts].where(blog_subdomain: row_keys[:blog_subdomain]).
487
+ first[:title]).to eq('Big Data')
488
+ expect(cequel[:posts].where(blog_subdomain: 'foo').first).to be_nil
482
489
  end
483
490
 
484
491
  it 'should build WHERE statement from multi-element hash' do
485
- cequel[:posts].where(row_keys).first[:title].should == 'Big Data'
486
- cequel[:posts].where(row_keys.merge(:permalink => 'foo')).
487
- first.should be_nil
492
+ expect(cequel[:posts].where(row_keys).first[:title]).to eq('Big Data')
493
+ expect(cequel[:posts].where(row_keys.merge(:permalink => 'foo')).
494
+ first).to be_nil
488
495
  end
489
496
 
490
497
  it 'should build WHERE statement with IN' do
@@ -496,32 +503,32 @@ describe Cequel::Metal::DataSet do
496
503
  blog_subdomain: 'bogus-blog',
497
504
  title: 'Bogus Post',
498
505
  ))
499
- cequel[:posts].where(
506
+ expect(cequel[:posts].where(
500
507
  :blog_subdomain => %w(cassandra big-data-weekly),
501
508
  :permalink => 'big-data'
502
- ).map { |row| row[:title] }.should == ['Big Data', 'Cassandra']
509
+ ).map { |row| row[:title] }).to eq(['Big Data', 'Cassandra'])
503
510
  end
504
511
 
505
512
  it 'should use = if provided one-element array' do
506
- cequel[:posts].
513
+ expect(cequel[:posts].
507
514
  where(row_keys.merge(blog_subdomain: [row_keys[:blog_subdomain]])).
508
- first[:title].should == 'Big Data'
515
+ first[:title]).to eq('Big Data')
509
516
  end
510
517
 
511
518
  it 'should build WHERE statement from CQL string' do
512
- cequel[:posts].where("blog_subdomain = '#{row_keys[:blog_subdomain]}'").
513
- first[:title].should == 'Big Data'
519
+ expect(cequel[:posts].where("blog_subdomain = '#{row_keys[:blog_subdomain]}'").
520
+ first[:title]).to eq('Big Data')
514
521
  end
515
522
 
516
523
  it 'should build WHERE statement from CQL string with bind variables' do
517
- cequel[:posts].where("blog_subdomain = ?", row_keys[:blog_subdomain]).
518
- first[:title].should == 'Big Data'
524
+ expect(cequel[:posts].where("blog_subdomain = ?", row_keys[:blog_subdomain]).
525
+ first[:title]).to eq('Big Data')
519
526
  end
520
527
 
521
528
  it 'should aggregate multiple WHERE statements' do
522
- cequel[:posts].where(:blog_subdomain => row_keys[:blog_subdomain]).
529
+ expect(cequel[:posts].where(:blog_subdomain => row_keys[:blog_subdomain]).
523
530
  where('permalink = ?', row_keys[:permalink]).
524
- first[:title].should == 'Big Data'
531
+ first[:title]).to eq('Big Data')
525
532
  end
526
533
 
527
534
  end
@@ -536,9 +543,9 @@ describe Cequel::Metal::DataSet do
536
543
  end
537
544
 
538
545
  it 'should override chained conditions' do
539
- cequel[:posts].where(:permalink => 'bogus').
546
+ expect(cequel[:posts].where(:permalink => 'bogus').
540
547
  where!(:blog_subdomain => row_keys[:blog_subdomain]).
541
- first[:title].should == 'Big Data'
548
+ first[:title]).to eq('Big Data')
542
549
  end
543
550
  end
544
551
 
@@ -552,8 +559,8 @@ describe Cequel::Metal::DataSet do
552
559
  end
553
560
 
554
561
  it 'should add LIMIT' do
555
- cequel[:posts].where(row_keys.slice(:blog_subdomain)).limit(2).
556
- map { |row| row[:title] }.should == ['Big Data', 'Marshmallows']
562
+ expect(cequel[:posts].where(row_keys.slice(:blog_subdomain)).limit(2).
563
+ map { |row| row[:title] }).to eq(['Big Data', 'Marshmallows'])
557
564
  end
558
565
  end
559
566
 
@@ -567,9 +574,9 @@ describe Cequel::Metal::DataSet do
567
574
  end
568
575
 
569
576
  it 'should add order' do
570
- cequel[:posts].where(row_keys.slice(:blog_subdomain)).
571
- order(permalink: 'desc').map { |row| row[:title] }.
572
- should == ['ZZ Top', 'Marshmallows', 'Big Data']
577
+ expect(cequel[:posts].where(row_keys.slice(:blog_subdomain)).
578
+ order(permalink: 'desc').map { |row| row[:title] }).
579
+ to eq(['ZZ Top', 'Marshmallows', 'Big Data'])
573
580
  end
574
581
  end
575
582
 
@@ -655,13 +662,13 @@ describe Cequel::Metal::DataSet do
655
662
  end
656
663
 
657
664
  it 'should enumerate over results' do
658
- cequel[:posts].to_a.map { |row| row.select { |k, v| v }}.
659
- should == [row.stringify_keys]
665
+ expect(cequel[:posts].to_a.map { |row| row.select { |k, v| v }}).
666
+ to eq([row.stringify_keys])
660
667
  end
661
668
 
662
669
  it 'should provide results with indifferent access' do
663
- cequel[:posts].to_a.first[:blog_permalink].
664
- should == row_keys[:blog_permalink]
670
+ expect(cequel[:posts].to_a.first[:blog_permalink]).
671
+ to eq(row_keys[:blog_permalink])
665
672
  end
666
673
 
667
674
  it 'should not run query if no block given to #each' do
@@ -669,9 +676,9 @@ describe Cequel::Metal::DataSet do
669
676
  end
670
677
 
671
678
  it 'should return Enumerator if no block given to #each' do
672
- cequel[:posts].each.each_with_index.
673
- map { |row, i| [row[:blog_permalink], i] }.
674
- should == [[row[:blog_permalink], 0]]
679
+ expect(cequel[:posts].each.each_with_index.
680
+ map { |row, i| [row[:blog_permalink], i] }).
681
+ to eq([[row[:blog_permalink], 0]])
675
682
  end
676
683
  end
677
684
 
@@ -685,7 +692,7 @@ describe Cequel::Metal::DataSet do
685
692
  end
686
693
 
687
694
  it 'should run a query with LIMIT 1 and return first row' do
688
- cequel[:posts].first.select { |k, v| v }.should == row.stringify_keys
695
+ expect(cequel[:posts].first.select { |k, v| v }).to eq(row.stringify_keys)
689
696
  end
690
697
  end
691
698
 
@@ -698,16 +705,16 @@ describe Cequel::Metal::DataSet do
698
705
  end
699
706
 
700
707
  it 'should run a count query and return count' do
701
- cequel[:posts].count.should == 4
708
+ expect(cequel[:posts].count).to eq(4)
702
709
  end
703
710
 
704
711
  it 'should use where clause if specified' do
705
- cequel[:posts].where(row_keys.merge(permalink: 'post-1')).
706
- count.should == 1
712
+ expect(cequel[:posts].where(row_keys.merge(permalink: 'post-1')).
713
+ count).to eq(1)
707
714
  end
708
715
 
709
716
  it 'should use limit if specified' do
710
- cequel[:posts].limit(2).count.should == 2
717
+ expect(cequel[:posts].limit(2).count).to eq(2)
711
718
  end
712
719
  end
713
720