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
@@ -24,7 +24,7 @@ describe Cequel::Record::Map do
24
24
 
25
25
  context 'new record' do
26
26
  it 'should save set as-is' do
27
- subject[:likes].should == {'alice' => 1, 'bob' => 2}
27
+ expect(subject[:likes]).to eq({'alice' => 1, 'bob' => 2})
28
28
  end
29
29
  end
30
30
 
@@ -32,13 +32,13 @@ describe Cequel::Record::Map do
32
32
  it 'should overwrite value' do
33
33
  post.likes = {'charlotte' => 3, 'dave' => 4}
34
34
  post.save!
35
- subject[:likes].should == {'charlotte' => 3, 'dave' => 4}
35
+ expect(subject[:likes]).to eq({'charlotte' => 3, 'dave' => 4})
36
36
  end
37
37
 
38
38
  it 'should cast collection before overwriting' do
39
39
  post.likes = [['charlotte', 3], ['dave', 4]]
40
40
  post.save!
41
- subject[:likes].should == {'charlotte' => 3, 'dave' => 4}
41
+ expect(subject[:likes]).to eq({'charlotte' => 3, 'dave' => 4})
42
42
  end
43
43
  end
44
44
 
@@ -49,8 +49,9 @@ describe Cequel::Record::Map do
49
49
  it 'should atomically update' do
50
50
  post.likes['david'] = 4
51
51
  post.save
52
- subject[:likes].should ==
52
+ expect(subject[:likes]).to eq(
53
53
  {'alice' => 1, 'bob' => 2, 'charles' => 3, 'david' => 4}
54
+ )
54
55
  expect(post.likes).to eq({'alice' => 1, 'bob' => 2, 'david' => 4})
55
56
  end
56
57
 
@@ -65,11 +66,13 @@ describe Cequel::Record::Map do
65
66
  end
66
67
 
67
68
  it 'should write without reading' do
68
- max_statements! 2
69
- unloaded_post.likes['david'] = 4
70
- unloaded_post.save
71
- subject[:likes].should ==
69
+ expect_statement_count 1 do
70
+ unloaded_post.likes['david'] = 4
71
+ unloaded_post.save
72
+ end
73
+ expect(subject[:likes]).to eq(
72
74
  {'alice' => 1, 'bob' => 2, 'charles' => 3, 'david' => 4}
75
+ )
73
76
  end
74
77
 
75
78
  it 'should set key value post-hoc' do
@@ -83,20 +86,21 @@ describe Cequel::Record::Map do
83
86
  it 'should atomically clear' do
84
87
  post.likes.clear
85
88
  post.save
86
- subject[:likes].should be_blank
89
+ expect(subject[:likes]).to be_blank
87
90
  expect(post.likes).to eq({})
88
91
  end
89
92
 
90
93
  it 'should clear without reading' do
91
- max_statements! 2
92
- unloaded_post.likes.clear
93
- unloaded_post.save
94
- subject[:likes].should be_blank
94
+ expect_statement_count 1 do
95
+ unloaded_post.likes.clear
96
+ unloaded_post.save
97
+ end
98
+ expect(subject[:likes]).to be_blank
95
99
  end
96
100
 
97
101
  it 'should clear post-hoc' do
98
102
  unloaded_post.likes.clear
99
- unloaded_post.likes.should be_blank
103
+ expect(unloaded_post.likes).to be_blank
100
104
  end
101
105
  end
102
106
 
@@ -104,7 +108,7 @@ describe Cequel::Record::Map do
104
108
  it 'should delete element atomically' do
105
109
  post.likes.delete('bob')
106
110
  post.save
107
- subject[:likes].should == {'alice' => 1, 'charles' => 3}
111
+ expect(subject[:likes]).to eq({'alice' => 1, 'charles' => 3})
108
112
  expect(post.likes).to eq({'alice' => 1})
109
113
  end
110
114
 
@@ -114,10 +118,11 @@ describe Cequel::Record::Map do
114
118
  end
115
119
 
116
120
  it 'should delete without reading' do
117
- max_statements! 2
118
- unloaded_post.likes.delete('bob')
119
- unloaded_post.save
120
- subject[:likes].should == {'alice' => 1, 'charles' => 3}
121
+ expect_statement_count 1 do
122
+ unloaded_post.likes.delete('bob')
123
+ unloaded_post.save
124
+ end
125
+ expect(subject[:likes]).to eq({'alice' => 1, 'charles' => 3})
121
126
  end
122
127
 
123
128
  it 'should delete post-hoc' do
@@ -130,8 +135,9 @@ describe Cequel::Record::Map do
130
135
  it 'should atomically update' do
131
136
  post.likes.merge!('david' => 4, 'emily' => 5)
132
137
  post.save
133
- subject[:likes].should ==
138
+ expect(subject[:likes]).to eq(
134
139
  {'alice' => 1, 'bob' => 2, 'charles' => 3, 'david' => 4, 'emily' => 5}
140
+ )
135
141
  expect(post.likes).to eq(
136
142
  {'alice' => 1, 'bob' => 2, 'david' => 4, 'emily' => 5})
137
143
  end
@@ -146,18 +152,21 @@ describe Cequel::Record::Map do
146
152
  it 'should cast values before updating' do
147
153
  post.likes.merge!('david' => '4', 'emily' => 5.0)
148
154
  post.save
149
- subject[:likes].should ==
155
+ expect(subject[:likes]).to eq(
150
156
  {'alice' => 1, 'bob' => 2, 'charles' => 3, 'david' => 4, 'emily' => 5}
157
+ )
151
158
  expect(post.likes).to eq(
152
159
  {'alice' => 1, 'bob' => 2, 'david' => 4, 'emily' => 5})
153
160
  end
154
161
 
155
162
  it 'should write without reading' do
156
- max_statements! 2
157
- unloaded_post.likes.merge!('david' => 4, 'emily' => 5)
158
- unloaded_post.save
159
- subject[:likes].should ==
163
+ expect_statement_count 1 do
164
+ unloaded_post.likes.merge!('david' => 4, 'emily' => 5)
165
+ unloaded_post.save
166
+ end
167
+ expect(subject[:likes]).to eq(
160
168
  {'alice' => 1, 'bob' => 2, 'charles' => 3, 'david' => 4, 'emily' => 5}
169
+ )
161
170
  end
162
171
 
163
172
  it 'should merge post-hoc' do
@@ -171,7 +180,7 @@ describe Cequel::Record::Map do
171
180
  it 'should automatically overwrite' do
172
181
  post.likes.replace('david' => 4, 'emily' => 5)
173
182
  post.save
174
- subject[:likes].should == {'david' => 4, 'emily' => 5}
183
+ expect(subject[:likes]).to eq({'david' => 4, 'emily' => 5})
175
184
  expect(post.likes).to eq({'david' => 4, 'emily' => 5})
176
185
  end
177
186
 
@@ -183,15 +192,16 @@ describe Cequel::Record::Map do
183
192
  it 'should cast values before overwriting' do
184
193
  post.likes.replace('david' => '4', 'emily' => 5.0)
185
194
  post.save
186
- subject[:likes].should == {'david' => 4, 'emily' => 5}
195
+ expect(subject[:likes]).to eq({'david' => 4, 'emily' => 5})
187
196
  expect(post.likes).to eq({'david' => 4, 'emily' => 5})
188
197
  end
189
198
 
190
199
  it 'should overwrite without reading' do
191
- max_statements! 2
192
- unloaded_post.likes.replace('david' => 4, 'emily' => 5)
193
- unloaded_post.save
194
- subject[:likes].should == {'david' => 4, 'emily' => 5}
200
+ expect_statement_count 1 do
201
+ unloaded_post.likes.replace('david' => 4, 'emily' => 5)
202
+ unloaded_post.save
203
+ end
204
+ expect(subject[:likes]).to eq({'david' => 4, 'emily' => 5})
195
205
  end
196
206
 
197
207
  it 'should replace post-hoc' do
@@ -204,17 +214,20 @@ describe Cequel::Record::Map do
204
214
  it 'should atomically update' do
205
215
  post.likes.store('david', 4)
206
216
  post.save
207
- subject[:likes].should ==
217
+ expect(subject[:likes]).to eq(
208
218
  {'alice' => 1, 'bob' => 2, 'charles' => 3, 'david' => 4}
219
+ )
209
220
  expect(post.likes).to eq({'alice' => 1, 'bob' => 2, 'david' => 4})
210
221
  end
211
222
 
212
223
  it 'should write without reading' do
213
- max_statements! 2
214
- unloaded_post.likes.store('david', 4)
215
- unloaded_post.save
216
- subject[:likes].should ==
224
+ expect_statement_count 1 do
225
+ unloaded_post.likes.store('david', 4)
226
+ unloaded_post.save
227
+ end
228
+ expect(subject[:likes]).to eq(
217
229
  {'alice' => 1, 'bob' => 2, 'charles' => 3, 'david' => 4}
230
+ )
218
231
  end
219
232
 
220
233
  it 'should store post-hoc' do
@@ -228,18 +241,21 @@ describe Cequel::Record::Map do
228
241
  it 'should atomically update' do
229
242
  post.likes.update('david' => 4, 'emily' => 5)
230
243
  post.save
231
- subject[:likes].should ==
244
+ expect(subject[:likes]).to eq(
232
245
  {'alice' => 1, 'bob' => 2, 'charles' => 3, 'david' => 4, 'emily' => 5}
246
+ )
233
247
  expect(post.likes).to eq(
234
248
  {'alice' => 1, 'bob' => 2, 'david' => 4, 'emily' => 5})
235
249
  end
236
250
 
237
251
  it 'should write without reading' do
238
- max_statements! 2
239
- unloaded_post.likes.update('david' => 4, 'emily' => 5)
240
- unloaded_post.save
241
- subject[:likes].should ==
252
+ expect_statement_count 1 do
253
+ unloaded_post.likes.update('david' => 4, 'emily' => 5)
254
+ unloaded_post.save
255
+ end
256
+ expect(subject[:likes]).to eq(
242
257
  {'alice' => 1, 'bob' => 2, 'charles' => 3, 'david' => 4, 'emily' => 5}
258
+ )
243
259
  end
244
260
 
245
261
  it 'should update post-hoc' do
@@ -9,12 +9,12 @@ describe Cequel::Record::MassAssignment do
9
9
  end
10
10
 
11
11
  it 'should allow assignment of vanilla hash' do
12
- Post.new(:title => 'Cequel').title.should == 'Cequel'
12
+ expect(Post.new(:title => 'Cequel').title).to eq('Cequel')
13
13
  end
14
14
 
15
15
  it 'should allow assignment of permitted strong params' do
16
- Post.new(StrongParams.new(true, :title => 'Cequel')).title.
17
- should == 'Cequel'
16
+ expect(Post.new(StrongParams.new(true, :title => 'Cequel')).title).
17
+ to eq('Cequel')
18
18
  end
19
19
 
20
20
  it 'should raise exception when assigned non-permitted strong params' do
@@ -46,11 +46,11 @@ describe Cequel::Record::MassAssignment do
46
46
  let(:post) { Post.new(:title => 'Cequel', :page_views => 1000) }
47
47
 
48
48
  it 'should allow assignment of accessible params' do
49
- post.title.should == 'Cequel'
49
+ expect(post.title).to eq('Cequel')
50
50
  end
51
51
 
52
52
  it 'should not allow assignment of inaccessible params' do
53
- post.page_views.should be_nil
53
+ expect(post.page_views).to be_nil
54
54
  end
55
55
  end
56
56
  end
@@ -8,10 +8,10 @@ describe 'naming' do
8
8
  end
9
9
 
10
10
  it 'should implement model_name' do
11
- Blog.model_name.should == 'Blog'
11
+ expect(Blog.model_name).to eq('Blog')
12
12
  end
13
13
 
14
14
  it 'should implement model_name interpolations' do
15
- Blog.model_name.i18n_key.should == :blog
15
+ expect(Blog.model_name.i18n_key).to eq(:blog)
16
16
  end
17
17
  end
@@ -29,18 +29,18 @@ describe Cequel::Record::Persistence do
29
29
  end
30
30
 
31
31
  describe 'new record' do
32
- specify { Blog.new.should_not be_persisted }
33
- specify { Blog.new.should be_transient }
32
+ specify { expect(Blog.new).not_to be_persisted }
33
+ specify { expect(Blog.new).to be_transient }
34
34
  end
35
35
 
36
36
  describe '#save' do
37
37
  context 'on create' do
38
38
  it 'should save row to database' do
39
- subject[:name].should == 'Cequel'
39
+ expect(subject[:name]).to eq('Cequel')
40
40
  end
41
41
 
42
42
  it 'should mark row persisted' do
43
- blog.should be_persisted
43
+ expect(blog).to be_persisted
44
44
  end
45
45
 
46
46
  it 'should fail fast if keys are missing' do
@@ -85,15 +85,15 @@ describe Cequel::Record::Persistence do
85
85
  end
86
86
 
87
87
  it 'should change existing column value' do
88
- subject[:name].should == 'Cequel 1.0'
88
+ expect(subject[:name]).to eq('Cequel 1.0')
89
89
  end
90
90
 
91
91
  it 'should add new column value' do
92
- subject[:owner_id].should == owner_id
92
+ expect(subject[:owner_id]).to eq(owner_id)
93
93
  end
94
94
 
95
95
  it 'should remove old column values' do
96
- subject[:description].should be_nil
96
+ expect(subject[:description]).to be_nil
97
97
  end
98
98
 
99
99
  it 'should not allow changing key values' do
@@ -147,7 +147,7 @@ describe Cequel::Record::Persistence do
147
147
  end
148
148
  end
149
149
  blog.save
150
- subject[:name].should == 'Pizza'
150
+ expect(subject[:name]).to eq('Pizza')
151
151
  end
152
152
  end
153
153
  end
@@ -164,11 +164,11 @@ describe Cequel::Record::Persistence do
164
164
  end
165
165
 
166
166
  it 'should initialize with block' do
167
- blog.name.should == 'Big Data'
167
+ expect(blog.name).to eq('Big Data')
168
168
  end
169
169
 
170
170
  it 'should save instance' do
171
- Blog.find(blog.subdomain).name.should == 'Big Data'
171
+ expect(Blog.find(blog.subdomain).name).to eq('Big Data')
172
172
  end
173
173
 
174
174
  it 'should fail fast if keys are missing' do
@@ -186,11 +186,11 @@ describe Cequel::Record::Persistence do
186
186
  end
187
187
 
188
188
  it 'should initialize with block' do
189
- blog.name.should == 'Big Data'
189
+ expect(blog.name).to eq('Big Data')
190
190
  end
191
191
 
192
192
  it 'should save instance' do
193
- Blog.find(blog.subdomain).name.should == 'Big Data'
193
+ expect(Blog.find(blog.subdomain).name).to eq('Big Data')
194
194
  end
195
195
 
196
196
  it 'should fail fast if keys are missing' do
@@ -209,11 +209,11 @@ describe Cequel::Record::Persistence do
209
209
  before { blog.update_attributes(:name => 'The Big Data Blog') }
210
210
 
211
211
  it 'should update instance in memory' do
212
- blog.name.should == 'The Big Data Blog'
212
+ expect(blog.name).to eq('The Big Data Blog')
213
213
  end
214
214
 
215
215
  it 'should save instance' do
216
- Blog.find(blog.subdomain).name.should == 'The Big Data Blog'
216
+ expect(Blog.find(blog.subdomain).name).to eq('The Big Data Blog')
217
217
  end
218
218
 
219
219
  it 'should not allow updating key values' do
@@ -226,11 +226,11 @@ describe Cequel::Record::Persistence do
226
226
  before { blog.destroy }
227
227
 
228
228
  it 'should delete entire row' do
229
- subject.should be_nil
229
+ expect(subject).to be_nil
230
230
  end
231
231
 
232
232
  it 'should mark record transient' do
233
- blog.should be_transient
233
+ expect(blog).to be_transient
234
234
  end
235
235
 
236
236
  it 'should destroy with specified consistency' do
@@ -266,11 +266,11 @@ describe Cequel::Record::Persistence do
266
266
  describe '#save' do
267
267
  context 'on create' do
268
268
  it 'should save row to database' do
269
- subject[:title].should == 'Cequel'
269
+ expect(subject[:title]).to eq('Cequel')
270
270
  end
271
271
 
272
272
  it 'should mark row persisted' do
273
- post.should be_persisted
273
+ expect(post).to be_persisted
274
274
  end
275
275
 
276
276
  it 'should fail fast if parent keys are missing' do
@@ -303,15 +303,15 @@ describe Cequel::Record::Persistence do
303
303
  end
304
304
 
305
305
  it 'should change existing column value' do
306
- subject[:title].should == 'Cequel 1.0'
306
+ expect(subject[:title]).to eq('Cequel 1.0')
307
307
  end
308
308
 
309
309
  it 'should add new column value' do
310
- subject[:author_id].should == author_id
310
+ expect(subject[:author_id]).to eq(author_id)
311
311
  end
312
312
 
313
313
  it 'should remove old column values' do
314
- subject[:body].should be_nil
314
+ expect(subject[:body]).to be_nil
315
315
  end
316
316
 
317
317
  it 'should not allow changing parent key values' do
@@ -334,11 +334,11 @@ describe Cequel::Record::Persistence do
334
334
  before { post.destroy }
335
335
 
336
336
  it 'should delete entire row' do
337
- subject.should be_nil
337
+ expect(subject).to be_nil
338
338
  end
339
339
 
340
340
  it 'should mark record transient' do
341
- post.should be_transient
341
+ expect(post).to be_transient
342
342
  end
343
343
  end
344
344
  end
@@ -17,44 +17,44 @@ describe Cequel::Record::Properties do
17
17
  end
18
18
 
19
19
  it 'should provide accessor for key' do
20
- Post.new { |post| post.permalink = 'big-data' }.permalink.
21
- should == 'big-data'
20
+ expect(Post.new { |post| post.permalink = 'big-data' }.permalink).
21
+ to eq('big-data')
22
22
  end
23
23
 
24
24
  it 'should cast key to correct value' do
25
- Post.new { |post| post.permalink = 44 }.permalink.
26
- should == '44'
25
+ expect(Post.new { |post| post.permalink = 44 }.permalink).
26
+ to eq('44')
27
27
  end
28
28
 
29
29
  it 'should have nil key if unset' do
30
- Post.new.permalink.should be_nil
30
+ expect(Post.new.permalink).to be_nil
31
31
  end
32
32
 
33
33
  it 'should provide accessor for data column' do
34
- Post.new { |post| post.title = 'Big Data' }.title.should == 'Big Data'
34
+ expect(Post.new { |post| post.title = 'Big Data' }.title).to eq('Big Data')
35
35
  end
36
36
 
37
37
  it 'should cast data column to correct value' do
38
- Post.new { |post| post.title = 'Big Data'.force_encoding('US-ASCII') }.
39
- title.encoding.name.should == 'UTF-8'
38
+ expect(Post.new { |post| post.title = 'Big Data'.force_encoding('US-ASCII') }.
39
+ title.encoding.name).to eq('UTF-8')
40
40
  end
41
41
 
42
42
  it 'should have nil data column value if unset' do
43
- Post.new.title.should be_nil
43
+ expect(Post.new.title).to be_nil
44
44
  end
45
45
 
46
46
  it 'should allow setting attributes via #attributes=' do
47
- Post.new.tap { |post| post.attributes = {:title => 'Big Data' }}.
48
- title.should == 'Big Data'
47
+ expect(Post.new.tap { |post| post.attributes = {:title => 'Big Data' }}.
48
+ title).to eq('Big Data')
49
49
  end
50
50
 
51
51
  it 'should use writers when setting attributes' do
52
- Post.new.tap { |post| post.attributes = {:downcased_title => 'big data' }}.
53
- title.should == 'Big Data'
52
+ expect(Post.new.tap { |post| post.attributes = {:downcased_title => 'big data' }}.
53
+ title).to eq('Big Data')
54
54
  end
55
55
 
56
56
  it 'should take attribute arguments to ::new' do
57
- Post.new(:downcased_title => 'big data').title.should == 'Big Data'
57
+ expect(Post.new(:downcased_title => 'big data').title).to eq('Big Data')
58
58
  end
59
59
 
60
60
  it 'should provide accessor for list column' do
@@ -145,11 +145,11 @@ describe Cequel::Record::Properties do
145
145
  end
146
146
 
147
147
  it 'should respect default for keys' do
148
- Post.new.permalink.should == 'new_permalink'
148
+ expect(Post.new.permalink).to eq('new_permalink')
149
149
  end
150
150
 
151
151
  it 'should respect default for data column' do
152
- Post.new.title.should == 'New Post'
152
+ expect(Post.new.title).to eq('New Post')
153
153
  end
154
154
 
155
155
  it 'should respect default for list column' do
@@ -173,7 +173,7 @@ describe Cequel::Record::Properties do
173
173
  end
174
174
 
175
175
  it 'should auto-generate UUID key' do
176
- Cequel.uuid?(Post.new.id).should be_true
176
+ expect(Cequel.uuid?(Post.new.id)).to eq(true)
177
177
  end
178
178
 
179
179
  it 'should raise ArgumentError if auto specified for non-UUID' do
@@ -186,11 +186,11 @@ describe Cequel::Record::Properties do
186
186
  end
187
187
 
188
188
  it 'should run default proc on keys' do
189
- Post.new.subid.should == "subid #{1+1}"
189
+ expect(Post.new.subid).to eq("subid #{1+1}")
190
190
  end
191
191
 
192
192
  it 'should run default proc' do
193
- Post.new.title.should == "Post #{Date.today}"
193
+ expect(Post.new.title).to eq("Post #{Date.today}")
194
194
  end
195
195
  end
196
196
  end