cuprum-collections 0.2.0 → 0.3.0.rc.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/README.md +255 -8
  4. data/lib/cuprum/collections/basic/collection.rb +13 -0
  5. data/lib/cuprum/collections/basic/commands/destroy_one.rb +4 -3
  6. data/lib/cuprum/collections/basic/commands/find_many.rb +1 -1
  7. data/lib/cuprum/collections/basic/commands/insert_one.rb +4 -3
  8. data/lib/cuprum/collections/basic/commands/update_one.rb +4 -3
  9. data/lib/cuprum/collections/basic/query.rb +3 -3
  10. data/lib/cuprum/collections/commands/abstract_find_many.rb +33 -32
  11. data/lib/cuprum/collections/commands/abstract_find_one.rb +4 -3
  12. data/lib/cuprum/collections/commands/create.rb +60 -0
  13. data/lib/cuprum/collections/commands/find_one_matching.rb +134 -0
  14. data/lib/cuprum/collections/commands/update.rb +74 -0
  15. data/lib/cuprum/collections/commands/upsert.rb +162 -0
  16. data/lib/cuprum/collections/commands.rb +7 -2
  17. data/lib/cuprum/collections/errors/abstract_find_error.rb +210 -0
  18. data/lib/cuprum/collections/errors/already_exists.rb +4 -72
  19. data/lib/cuprum/collections/errors/extra_attributes.rb +8 -18
  20. data/lib/cuprum/collections/errors/failed_validation.rb +5 -18
  21. data/lib/cuprum/collections/errors/invalid_parameters.rb +7 -15
  22. data/lib/cuprum/collections/errors/invalid_query.rb +5 -15
  23. data/lib/cuprum/collections/errors/missing_default_contract.rb +5 -17
  24. data/lib/cuprum/collections/errors/not_found.rb +4 -67
  25. data/lib/cuprum/collections/errors/not_unique.rb +18 -0
  26. data/lib/cuprum/collections/errors/unknown_operator.rb +7 -17
  27. data/lib/cuprum/collections/errors.rb +13 -1
  28. data/lib/cuprum/collections/queries/ordering.rb +2 -2
  29. data/lib/cuprum/collections/repository.rb +23 -10
  30. data/lib/cuprum/collections/rspec/collection_contract.rb +140 -103
  31. data/lib/cuprum/collections/rspec/destroy_one_command_contract.rb +8 -6
  32. data/lib/cuprum/collections/rspec/find_many_command_contract.rb +114 -34
  33. data/lib/cuprum/collections/rspec/find_one_command_contract.rb +12 -9
  34. data/lib/cuprum/collections/rspec/insert_one_command_contract.rb +4 -3
  35. data/lib/cuprum/collections/rspec/query_contract.rb +3 -3
  36. data/lib/cuprum/collections/rspec/querying_contract.rb +2 -2
  37. data/lib/cuprum/collections/rspec/repository_contract.rb +167 -93
  38. data/lib/cuprum/collections/rspec/update_one_command_contract.rb +4 -3
  39. data/lib/cuprum/collections/version.rb +3 -3
  40. data/lib/cuprum/collections.rb +1 -0
  41. metadata +22 -91
@@ -1,153 +1,190 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'rspec/sleeping_king_studios/contract'
4
+
3
5
  require 'cuprum/collections/rspec'
4
6
 
5
7
  module Cuprum::Collections::RSpec
6
8
  # Contract validating the behavior of a Collection.
7
- COLLECTION_CONTRACT = lambda do
8
- shared_examples 'should define the command' do |command_name, command_class|
9
- tools = SleepingKingStudios::Tools::Toolbelt.instance
10
- class_name = tools.str.camelize(command_name)
11
-
12
- describe "::#{class_name}" do
13
- let(:constructor_options) { {} }
14
- let(:command) do
15
- collection.const_get(class_name).new(**constructor_options)
16
- end
9
+ module CollectionContract
10
+ extend RSpec::SleepingKingStudios::Contract
11
+
12
+ # @!method apply(example_group)
13
+ # Adds the contract to the example group.
14
+ #
15
+ # @param example_group [RSpec::Core::ExampleGroup] The example group to
16
+ # which the contract is applied.
17
+
18
+ contract do
19
+ shared_examples 'should define the command' \
20
+ do |command_name, command_class|
21
+ tools = SleepingKingStudios::Tools::Toolbelt.instance
22
+ class_name = tools.str.camelize(command_name)
23
+
24
+ describe "::#{class_name}" do
25
+ let(:constructor_options) { {} }
26
+ let(:command) do
27
+ collection.const_get(class_name).new(**constructor_options)
28
+ end
17
29
 
18
- it { expect(collection).to define_constant(class_name) }
30
+ it { expect(collection).to define_constant(class_name) }
19
31
 
20
- it { expect(collection.const_get(class_name)).to be_a Class }
32
+ it { expect(collection.const_get(class_name)).to be_a Class }
21
33
 
22
- it { expect(collection.const_get(class_name)).to be < command_class }
23
-
24
- command_options.each do |option_name|
25
- it "should set the ##{option_name}" do
26
- expect(command.send(option_name))
27
- .to be == collection.send(option_name)
28
- end
29
- end
30
-
31
- describe 'with options' do
32
- let(:constructor_options) do
33
- {
34
- data: [],
35
- member_name: 'tome'
36
- }
37
- end
34
+ it { expect(collection.const_get(class_name)).to be < command_class }
38
35
 
39
36
  command_options.each do |option_name|
40
37
  it "should set the ##{option_name}" do
41
- expect(command.send(option_name)).to(
42
- be == constructor_options.fetch(option_name) do
43
- collection.send(option_name)
44
- end
45
- )
38
+ expect(command.send(option_name))
39
+ .to be == collection.send(option_name)
46
40
  end
47
41
  end
48
- end
49
- end
50
42
 
51
- describe "##{command_name}" do
52
- let(:constructor_options) { {} }
53
- let(:command) do
54
- collection.send(command_name, **constructor_options)
55
- end
43
+ describe 'with options' do
44
+ let(:constructor_options) do
45
+ {
46
+ data: [],
47
+ member_name: 'tome'
48
+ }
49
+ end
56
50
 
57
- it 'should define the command' do
58
- expect(collection)
59
- .to respond_to(command_name)
60
- .with(0).arguments
61
- .and_any_keywords
51
+ command_options.each do |option_name|
52
+ it "should set the ##{option_name}" do
53
+ expect(command.send(option_name)).to(
54
+ be == constructor_options.fetch(option_name) do
55
+ collection.send(option_name)
56
+ end
57
+ )
58
+ end
59
+ end
60
+ end
62
61
  end
63
62
 
64
- it { expect(command).to be_a collection.const_get(class_name) }
65
-
66
- command_options.each do |option_name|
67
- it "should set the ##{option_name}" do
68
- expect(command.send(option_name))
69
- .to be == collection.send(option_name)
63
+ describe "##{command_name}" do
64
+ let(:constructor_options) { {} }
65
+ let(:command) do
66
+ collection.send(command_name, **constructor_options)
70
67
  end
71
- end
72
68
 
73
- describe 'with options' do
74
- let(:constructor_options) do
75
- {
76
- data: [],
77
- member_name: 'tome'
78
- }
69
+ it 'should define the command' do
70
+ expect(collection)
71
+ .to respond_to(command_name)
72
+ .with(0).arguments
73
+ .and_any_keywords
79
74
  end
80
75
 
76
+ it { expect(command).to be_a collection.const_get(class_name) }
77
+
81
78
  command_options.each do |option_name|
82
79
  it "should set the ##{option_name}" do
83
- expect(command.send(option_name)).to(
84
- be == constructor_options.fetch(option_name) do
85
- collection.send(option_name)
86
- end
87
- )
80
+ expect(command.send(option_name))
81
+ .to be == collection.send(option_name)
82
+ end
83
+ end
84
+
85
+ describe 'with options' do
86
+ let(:constructor_options) do
87
+ {
88
+ data: [],
89
+ member_name: 'tome'
90
+ }
91
+ end
92
+
93
+ command_options.each do |option_name|
94
+ it "should set the ##{option_name}" do
95
+ expect(command.send(option_name)).to(
96
+ be == constructor_options.fetch(option_name) do
97
+ collection.send(option_name)
98
+ end
99
+ )
100
+ end
88
101
  end
89
102
  end
90
103
  end
91
104
  end
92
- end
93
105
 
94
- include_examples 'should define the command',
95
- :assign_one,
96
- commands_namespace::AssignOne
106
+ include_examples 'should define the command',
107
+ :assign_one,
108
+ commands_namespace::AssignOne
109
+
110
+ include_examples 'should define the command',
111
+ :build_one,
112
+ commands_namespace::BuildOne
97
113
 
98
- include_examples 'should define the command',
99
- :build_one,
100
- commands_namespace::BuildOne
114
+ include_examples 'should define the command',
115
+ :destroy_one,
116
+ commands_namespace::DestroyOne
101
117
 
102
- include_examples 'should define the command',
103
- :destroy_one,
104
- commands_namespace::DestroyOne
118
+ include_examples 'should define the command',
119
+ :find_many,
120
+ commands_namespace::FindMany
105
121
 
106
- include_examples 'should define the command',
107
- :find_many,
108
- commands_namespace::FindMany
122
+ include_examples 'should define the command',
123
+ :find_matching,
124
+ commands_namespace::FindMatching
109
125
 
110
- include_examples 'should define the command',
111
- :find_matching,
112
- commands_namespace::FindMatching
126
+ include_examples 'should define the command',
127
+ :find_one,
128
+ commands_namespace::FindOne
113
129
 
114
- include_examples 'should define the command',
115
- :find_one,
116
- commands_namespace::FindOne
130
+ include_examples 'should define the command',
131
+ :insert_one,
132
+ commands_namespace::InsertOne
117
133
 
118
- include_examples 'should define the command',
119
- :insert_one,
120
- commands_namespace::InsertOne
134
+ include_examples 'should define the command',
135
+ :update_one,
136
+ commands_namespace::UpdateOne
121
137
 
122
- include_examples 'should define the command',
123
- :update_one,
124
- commands_namespace::UpdateOne
138
+ include_examples 'should define the command',
139
+ :validate_one,
140
+ commands_namespace::ValidateOne
125
141
 
126
- include_examples 'should define the command',
127
- :validate_one,
128
- commands_namespace::ValidateOne
142
+ describe '#collection_name' do
143
+ include_examples 'should define reader',
144
+ :collection_name,
145
+ -> { an_instance_of(String) }
146
+ end
129
147
 
130
- describe '#query' do
131
- let(:default_order) { defined?(super()) ? super() : {} }
132
- let(:query) { collection.query }
148
+ describe '#count' do
149
+ it { expect(collection).to respond_to(:count).with(0).arguments }
133
150
 
134
- it { expect(collection).to respond_to(:query).with(0).arguments }
151
+ it { expect(collection).to have_aliased_method(:count).as(:size) }
135
152
 
136
- it { expect(collection.query).to be_a query_class }
153
+ it { expect(collection.count).to be 0 }
137
154
 
138
- it 'should set the query options' do
139
- query_options.each do |option, value|
140
- expect(collection.query.send option).to be == value
155
+ wrap_context 'when the collection has many items' do
156
+ it { expect(collection.count).to be items.count }
141
157
  end
142
158
  end
143
159
 
144
- it { expect(query.criteria).to be == [] }
160
+ describe '#qualified_name' do
161
+ include_examples 'should define reader',
162
+ :qualified_name,
163
+ -> { an_instance_of(String) }
164
+ end
145
165
 
146
- it { expect(query.limit).to be nil }
166
+ describe '#query' do
167
+ let(:default_order) { defined?(super()) ? super() : {} }
168
+ let(:query) { collection.query }
147
169
 
148
- it { expect(query.offset).to be nil }
170
+ it { expect(collection).to respond_to(:query).with(0).arguments }
149
171
 
150
- it { expect(query.order).to be == default_order }
172
+ it { expect(collection.query).to be_a query_class }
173
+
174
+ it 'should set the query options' do
175
+ query_options.each do |option, value|
176
+ expect(collection.query.send option).to be == value
177
+ end
178
+ end
179
+
180
+ it { expect(query.criteria).to be == [] }
181
+
182
+ it { expect(query.limit).to be nil }
183
+
184
+ it { expect(query.offset).to be nil }
185
+
186
+ it { expect(query.order).to be == default_order }
187
+ end
151
188
  end
152
189
  end
153
190
  end
@@ -28,9 +28,10 @@ module Cuprum::Collections::RSpec
28
28
  let(:primary_key) { invalid_primary_key_value }
29
29
  let(:expected_error) do
30
30
  Cuprum::Collections::Errors::NotFound.new(
31
- collection_name: command.collection_name,
32
- primary_key_name: primary_key_name,
33
- primary_key_values: primary_key
31
+ attribute_name: primary_key_name,
32
+ attribute_value: primary_key,
33
+ collection_name: collection_name,
34
+ primary_key: true
34
35
  )
35
36
  end
36
37
 
@@ -59,9 +60,10 @@ module Cuprum::Collections::RSpec
59
60
  let(:primary_key) { invalid_primary_key_value }
60
61
  let(:expected_error) do
61
62
  Cuprum::Collections::Errors::NotFound.new(
62
- collection_name: command.collection_name,
63
- primary_key_name: primary_key_name,
64
- primary_key_values: primary_key
63
+ attribute_name: primary_key_name,
64
+ attribute_value: primary_key,
65
+ collection_name: collection_name,
66
+ primary_key: true
65
67
  )
66
68
  end
67
69
 
@@ -58,10 +58,15 @@ module Cuprum::Collections::RSpec
58
58
  describe 'with an array of invalid primary keys' do
59
59
  let(:primary_keys) { invalid_primary_key_values }
60
60
  let(:expected_error) do
61
- Cuprum::Collections::Errors::NotFound.new(
62
- collection_name: command.collection_name,
63
- primary_key_name: primary_key_name,
64
- primary_key_values: primary_keys
61
+ Cuprum::Errors::MultipleErrors.new(
62
+ errors: primary_keys.map do |primary_key|
63
+ Cuprum::Collections::Errors::NotFound.new(
64
+ attribute_name: primary_key_name,
65
+ attribute_value: primary_key,
66
+ collection_name: command.collection_name,
67
+ primary_key: true
68
+ )
69
+ end
65
70
  )
66
71
  end
67
72
 
@@ -79,7 +84,6 @@ module Cuprum::Collections::RSpec
79
84
  .map do |key|
80
85
  mapped_data.find { |item| item[primary_key_name.to_s] == key }
81
86
  end
82
- .compact
83
87
  end
84
88
  let(:expected_data) do
85
89
  defined?(super()) ? super() : matching_data
@@ -88,10 +92,15 @@ module Cuprum::Collections::RSpec
88
92
  describe 'with an array of invalid primary keys' do
89
93
  let(:primary_keys) { invalid_primary_key_values }
90
94
  let(:expected_error) do
91
- Cuprum::Collections::Errors::NotFound.new(
92
- collection_name: command.collection_name,
93
- primary_key_name: primary_key_name,
94
- primary_key_values: primary_keys
95
+ Cuprum::Errors::MultipleErrors.new(
96
+ errors: primary_keys.map do |primary_key|
97
+ Cuprum::Collections::Errors::NotFound.new(
98
+ attribute_name: primary_key_name,
99
+ attribute_value: primary_key,
100
+ collection_name: command.collection_name,
101
+ primary_key: true
102
+ )
103
+ end
95
104
  )
96
105
  end
97
106
 
@@ -107,10 +116,17 @@ module Cuprum::Collections::RSpec
107
116
  invalid_primary_key_values + valid_primary_key_values
108
117
  end
109
118
  let(:expected_error) do
110
- Cuprum::Collections::Errors::NotFound.new(
111
- collection_name: command.collection_name,
112
- primary_key_name: primary_key_name,
113
- primary_key_values: invalid_primary_key_values
119
+ Cuprum::Errors::MultipleErrors.new(
120
+ errors: primary_keys.map do |primary_key|
121
+ next nil unless invalid_primary_key_values.include?(primary_key)
122
+
123
+ Cuprum::Collections::Errors::NotFound.new(
124
+ attribute_name: primary_key_name,
125
+ attribute_value: primary_key,
126
+ collection_name: command.collection_name,
127
+ primary_key: true
128
+ )
129
+ end
114
130
  )
115
131
  end
116
132
 
@@ -145,10 +161,15 @@ module Cuprum::Collections::RSpec
145
161
  describe 'with an array of invalid primary keys' do
146
162
  let(:primary_keys) { invalid_primary_key_values }
147
163
  let(:expected_error) do
148
- Cuprum::Collections::Errors::NotFound.new(
149
- collection_name: command.collection_name,
150
- primary_key_name: primary_key_name,
151
- primary_key_values: primary_keys
164
+ Cuprum::Errors::MultipleErrors.new(
165
+ errors: invalid_primary_key_values.map do |primary_key|
166
+ Cuprum::Collections::Errors::NotFound.new(
167
+ attribute_name: primary_key_name,
168
+ attribute_value: primary_key,
169
+ collection_name: command.collection_name,
170
+ primary_key: true
171
+ )
172
+ end
152
173
  )
153
174
  end
154
175
 
@@ -163,6 +184,22 @@ module Cuprum::Collections::RSpec
163
184
  let(:primary_keys) do
164
185
  invalid_primary_key_values + valid_primary_key_values
165
186
  end
187
+ let(:expected_error) do
188
+ Cuprum::Errors::MultipleErrors.new(
189
+ errors: primary_keys.map do |primary_key|
190
+ unless invalid_primary_key_values.include?(primary_key)
191
+ next nil
192
+ end
193
+
194
+ Cuprum::Collections::Errors::NotFound.new(
195
+ attribute_name: primary_key_name,
196
+ attribute_value: primary_key,
197
+ collection_name: command.collection_name,
198
+ primary_key: true
199
+ )
200
+ end
201
+ )
202
+ end
166
203
 
167
204
  it 'should return a passing result' do
168
205
  expect(
@@ -170,6 +207,7 @@ module Cuprum::Collections::RSpec
170
207
  )
171
208
  .to be_a_passing_result
172
209
  .with_value(expected_data)
210
+ .and_error(expected_error)
173
211
  end
174
212
  end
175
213
 
@@ -226,10 +264,15 @@ module Cuprum::Collections::RSpec
226
264
  describe 'with an array of invalid primary keys' do
227
265
  let(:primary_keys) { invalid_primary_key_values }
228
266
  let(:expected_error) do
229
- Cuprum::Collections::Errors::NotFound.new(
230
- collection_name: command.collection_name,
231
- primary_key_name: primary_key_name,
232
- primary_key_values: primary_keys
267
+ Cuprum::Errors::MultipleErrors.new(
268
+ errors: primary_keys.map do |primary_key|
269
+ Cuprum::Collections::Errors::NotFound.new(
270
+ attribute_name: primary_key_name,
271
+ attribute_value: primary_key,
272
+ collection_name: command.collection_name,
273
+ primary_key: true
274
+ )
275
+ end
233
276
  )
234
277
  end
235
278
 
@@ -246,10 +289,15 @@ module Cuprum::Collections::RSpec
246
289
  describe 'with a valid array of primary keys' do
247
290
  let(:primary_keys) { valid_primary_key_values }
248
291
  let(:expected_error) do
249
- Cuprum::Collections::Errors::NotFound.new(
250
- collection_name: command.collection_name,
251
- primary_key_name: primary_key_name,
252
- primary_key_values: primary_keys
292
+ Cuprum::Errors::MultipleErrors.new(
293
+ errors: primary_keys.map do |primary_key|
294
+ Cuprum::Collections::Errors::NotFound.new(
295
+ attribute_name: primary_key_name,
296
+ attribute_value: primary_key,
297
+ collection_name: command.collection_name,
298
+ primary_key: true
299
+ )
300
+ end
253
301
  )
254
302
  end
255
303
 
@@ -264,20 +312,32 @@ module Cuprum::Collections::RSpec
264
312
  describe 'with a scope that matches some keys' do
265
313
  let(:scope_filter) { -> { { series: nil } } }
266
314
  let(:matching_data) do
267
- super().select { |item| item['series'].nil? }
315
+ super().map do |item|
316
+ next nil unless item['series'].nil?
317
+
318
+ item
319
+ end
268
320
  end
269
321
 
270
322
  describe 'with a valid array of primary keys' do
271
323
  let(:primary_keys) { valid_primary_key_values }
272
324
  let(:expected_error) do
273
- found_keys =
274
- matching_data.map { |item| item[primary_key_name.to_s] }
275
- missing_keys = primary_keys - found_keys
276
-
277
- Cuprum::Collections::Errors::NotFound.new(
278
- collection_name: command.collection_name,
279
- primary_key_name: primary_key_name,
280
- primary_key_values: missing_keys
325
+ found_keys =
326
+ matching_data
327
+ .compact
328
+ .map { |item| item[primary_key_name.to_s] }
329
+
330
+ Cuprum::Errors::MultipleErrors.new(
331
+ errors: primary_keys.map do |primary_key|
332
+ next if found_keys.include?(primary_key)
333
+
334
+ Cuprum::Collections::Errors::NotFound.new(
335
+ attribute_name: primary_key_name,
336
+ attribute_value: primary_key,
337
+ collection_name: command.collection_name,
338
+ primary_key: true
339
+ )
340
+ end
281
341
  )
282
342
  end
283
343
 
@@ -291,6 +351,25 @@ module Cuprum::Collections::RSpec
291
351
  describe 'with allow_partial: true' do
292
352
  describe 'with a valid array of primary keys' do
293
353
  let(:primary_keys) { valid_primary_key_values }
354
+ let(:expected_error) do
355
+ found_keys =
356
+ matching_data
357
+ .compact
358
+ .map { |item| item[primary_key_name.to_s] }
359
+
360
+ Cuprum::Errors::MultipleErrors.new(
361
+ errors: primary_keys.map do |primary_key|
362
+ next if found_keys.include?(primary_key)
363
+
364
+ Cuprum::Collections::Errors::NotFound.new(
365
+ attribute_name: primary_key_name,
366
+ attribute_value: primary_key,
367
+ collection_name: command.collection_name,
368
+ primary_key: true
369
+ )
370
+ end
371
+ )
372
+ end
294
373
 
295
374
  it 'should return a passing result' do
296
375
  expect(
@@ -302,6 +381,7 @@ module Cuprum::Collections::RSpec
302
381
  )
303
382
  .to be_a_passing_result
304
383
  .with_value(expected_data)
384
+ .and_error(expected_error)
305
385
  end
306
386
  end
307
387
  end
@@ -47,9 +47,10 @@ module Cuprum::Collections::RSpec
47
47
  let(:primary_key) { invalid_primary_key_value }
48
48
  let(:expected_error) do
49
49
  Cuprum::Collections::Errors::NotFound.new(
50
- collection_name: command.collection_name,
51
- primary_key_name: primary_key_name,
52
- primary_key_values: primary_key
50
+ attribute_name: primary_key_name,
51
+ attribute_value: primary_key,
52
+ collection_name: command.collection_name,
53
+ primary_key: true
53
54
  )
54
55
  end
55
56
 
@@ -73,9 +74,10 @@ module Cuprum::Collections::RSpec
73
74
  let(:primary_key) { invalid_primary_key_value }
74
75
  let(:expected_error) do
75
76
  Cuprum::Collections::Errors::NotFound.new(
76
- collection_name: command.collection_name,
77
- primary_key_name: primary_key_name,
78
- primary_key_values: primary_key
77
+ attribute_name: primary_key_name,
78
+ attribute_value: primary_key,
79
+ collection_name: command.collection_name,
80
+ primary_key: true
79
81
  )
80
82
  end
81
83
 
@@ -120,9 +122,10 @@ module Cuprum::Collections::RSpec
120
122
  let(:primary_key) { valid_primary_key_value }
121
123
  let(:expected_error) do
122
124
  Cuprum::Collections::Errors::NotFound.new(
123
- collection_name: command.collection_name,
124
- primary_key_name: primary_key_name,
125
- primary_key_values: primary_key
125
+ attribute_name: primary_key_name,
126
+ attribute_value: primary_key,
127
+ collection_name: command.collection_name,
128
+ primary_key: true
126
129
  )
127
130
  end
128
131
 
@@ -61,9 +61,10 @@ module Cuprum::Collections::RSpec
61
61
  let(:data) { fixtures_data }
62
62
  let(:expected_error) do
63
63
  Cuprum::Collections::Errors::AlreadyExists.new(
64
- collection_name: collection_name,
65
- primary_key_name: primary_key_name,
66
- primary_key_values: attributes[primary_key_name]
64
+ attribute_name: primary_key_name,
65
+ attribute_value: attributes[primary_key_name],
66
+ collection_name: collection_name,
67
+ primary_key: true
67
68
  )
68
69
  end
69
70
 
@@ -386,8 +386,8 @@ module Cuprum::Collections::RSpec # rubocop:disable Style/Documentation
386
386
  describe '#order' do
387
387
  let(:default_order) { defined?(super()) ? super() : {} }
388
388
  let(:error_message) do
389
- 'order must be a list of attribute names and/or a hash of attribute' \
390
- ' names with values :asc or :desc'
389
+ 'order must be a list of attribute names and/or a hash of attribute ' \
390
+ 'names with values :asc or :desc'
391
391
  end
392
392
 
393
393
  it 'should define the method' do
@@ -397,7 +397,7 @@ module Cuprum::Collections::RSpec # rubocop:disable Style/Documentation
397
397
  .and_unlimited_arguments
398
398
  end
399
399
 
400
- it { expect(query).to alias_method(:order).as(:order_by) }
400
+ it { expect(query).to have_aliased_method(:order).as(:order_by) }
401
401
 
402
402
  describe 'with no arguments' do
403
403
  it { expect(query.order).to be == default_order }
@@ -76,8 +76,8 @@ module Cuprum::Collections::RSpec
76
76
  end
77
77
  end
78
78
 
79
- shared_context 'when the query has where: a greater_than_or_equal_to' \
80
- ' filter' \
79
+ shared_context 'when the query has where: a greater_than_or_equal_to ' \
80
+ 'filter' \
81
81
  do
82
82
  let(:filter) do
83
83
  -> { { published_at: greater_than_or_equal_to('1970-12-01') } }