mongoid-scroll 1.0.1 → 2.0.1

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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +26 -7
  3. data/.github/workflows/danger-comment.yml +9 -0
  4. data/.github/workflows/danger.yml +9 -15
  5. data/.gitignore +1 -0
  6. data/.rubocop.yml +5 -0
  7. data/.rubocop_todo.yml +153 -35
  8. data/CHANGELOG.md +22 -5
  9. data/Dangerfile +5 -1
  10. data/Gemfile +16 -8
  11. data/README.md +27 -38
  12. data/RELEASING.md +31 -50
  13. data/Rakefile +3 -3
  14. data/UPGRADING.md +21 -1
  15. data/examples/{mongoid_scroll_feed.rb → feed.rb} +4 -3
  16. data/lib/config/locales/en.yml +4 -1
  17. data/lib/mongoid/criteria/scrollable/fields.rb +6 -0
  18. data/lib/mongoid/criteria/scrollable/iterator.rb +19 -0
  19. data/lib/mongoid/criteria/scrollable.rb +29 -9
  20. data/lib/mongoid/scroll/base64_encoded_cursor.rb +8 -6
  21. data/lib/mongoid/scroll/base_cursor.rb +12 -11
  22. data/lib/mongoid/scroll/cursor.rb +5 -5
  23. data/lib/mongoid/scroll/errors/base.rb +4 -4
  24. data/lib/mongoid/scroll/errors/mismatched_sort_fields_error.rb +1 -3
  25. data/lib/mongoid/scroll/errors/multiple_sort_fields_error.rb +1 -3
  26. data/lib/mongoid/scroll/errors/unsupported_type_error.rb +11 -0
  27. data/lib/mongoid/scroll/errors.rb +1 -0
  28. data/lib/mongoid/scroll/version.rb +1 -1
  29. data/lib/mongoid-scroll.rb +1 -2
  30. data/mongoid-scroll.gemspec +3 -3
  31. data/spec/mongoid/base64_encoded_cursor_spec.rb +148 -77
  32. data/spec/mongoid/criteria_spec.rb +139 -37
  33. data/spec/mongoid/cursor_spec.rb +112 -63
  34. data/spec/mongoid/scroll_spec.rb +1 -1
  35. data/spec/spec_helper.rb +14 -3
  36. data/spec/support/feed/embedded_item.rb +2 -0
  37. data/spec/support/feed/item.rb +1 -1
  38. metadata +13 -26
  39. data/examples/mongo_ruby_driver_scroll_feed.rb +0 -45
  40. data/lib/mongo/scrollable.rb +0 -39
  41. data/spec/mongo/collection_view_spec.rb +0 -143
@@ -3,17 +3,25 @@ require 'spec_helper'
3
3
  describe Mongoid::Scroll::Base64EncodedCursor do
4
4
  context 'new' do
5
5
  context 'an empty cursor' do
6
- let(:base64_string) { 'eyJ2YWx1ZSI6bnVsbCwiZmllbGRfdHlwZSI6IlN0cmluZyIsImZpZWxkX25hbWUiOiJhX3N0cmluZyIsImRpcmVjdGlvbiI6MSwiaW5jbHVkZV9jdXJyZW50IjpmYWxzZSwidGllYnJlYWtfaWQiOm51bGx9' }
7
6
  subject do
8
7
  Mongoid::Scroll::Base64EncodedCursor.new base64_string
9
8
  end
10
- its(:tiebreak_id) { should be_nil }
11
- its(:value) { should be_nil }
12
- its(:criteria) { should eq({}) }
13
- its(:to_s) { should eq(base64_string) }
9
+
10
+ let(:base64_string) { 'eyJ2YWx1ZSI6bnVsbCwiZmllbGRfdHlwZSI6IlN0cmluZyIsImZpZWxkX25hbWUiOiJhX3N0cmluZyIsImRpcmVjdGlvbiI6MSwiaW5jbHVkZV9jdXJyZW50IjpmYWxzZSwidGllYnJlYWtfaWQiOm51bGwsInR5cGUiOiJuZXh0In0=' }
11
+
12
+ its(:tiebreak_id) { is_expected.to be_nil }
13
+ its(:value) { is_expected.to be_nil }
14
+ its(:criteria) { is_expected.to eq({}) }
15
+ its(:type) { is_expected.to eq(:next) }
16
+ its(:to_s) { is_expected.to eq(base64_string) }
14
17
  end
18
+
15
19
  context 'a string field cursor' do
16
- let(:base64_string) { 'eyJ2YWx1ZSI6ImEgc3RyaW5nIiwiZmllbGRfdHlwZSI6IlN0cmluZyIsImZpZWxkX25hbWUiOiJhX3N0cmluZyIsImRpcmVjdGlvbiI6MSwiaW5jbHVkZV9jdXJyZW50IjpmYWxzZSwidGllYnJlYWtfaWQiOiI2NDA2M2RmODA5NDQzNDE3YzdkMmIxMDIifQ==' }
20
+ subject do
21
+ Mongoid::Scroll::Base64EncodedCursor.new base64_string
22
+ end
23
+
24
+ let(:base64_string) { 'eyJ2YWx1ZSI6ImEgc3RyaW5nIiwiZmllbGRfdHlwZSI6IlN0cmluZyIsImZpZWxkX25hbWUiOiJhX3N0cmluZyIsImRpcmVjdGlvbiI6MSwiaW5jbHVkZV9jdXJyZW50IjpmYWxzZSwidGllYnJlYWtfaWQiOiI2NDA2M2RmODA5NDQzNDE3YzdkMmIxMDIiLCJ0eXBlIjoibmV4dCJ9' }
17
25
  let(:a_value) { 'a string' }
18
26
  let(:tiebreak_id) { BSON::ObjectId.from_string('64063df809443417c7d2b102') }
19
27
  let(:criteria) do
@@ -24,18 +32,24 @@ describe Mongoid::Scroll::Base64EncodedCursor do
24
32
  ]
25
33
  }
26
34
  end
27
- subject do
28
- Mongoid::Scroll::Base64EncodedCursor.new base64_string
29
- end
30
- its(:value) { should eq a_value }
35
+
36
+ its(:value) { is_expected.to eq a_value }
31
37
  its(:tiebreak_id) { tiebreak_id }
32
- its(:value) { should eq a_value }
33
- its(:tiebreak_id) { should eq tiebreak_id }
34
- its(:criteria) { should eq(criteria) }
35
- its(:to_s) { should eq(base64_string) }
38
+ its(:value) { is_expected.to eq a_value }
39
+ its(:tiebreak_id) { is_expected.to eq tiebreak_id }
40
+ its(:criteria) { is_expected.to eq(criteria) }
41
+ its(:type) { is_expected.to eq(:next) }
42
+ its(:to_s) { is_expected.to eq(base64_string) }
36
43
  end
44
+
37
45
  context 'an id field cursor' do
38
- let(:base64_string) { 'eyJ2YWx1ZSI6IjY0MDY0NTg0MDk0NDM0MjgxZmE3MWFiMiIsImZpZWxkX3R5cGUiOiJCU09OOjpPYmplY3RJZCIsImZpZWxkX25hbWUiOiJpZCIsImRpcmVjdGlvbiI6MSwiaW5jbHVkZV9jdXJyZW50IjpmYWxzZSwidGllYnJlYWtfaWQiOiI2NDA2NDU4NDA5NDQzNDI4MWZhNzFhYjIifQ==' }
46
+ subject do
47
+ Mongoid::Scroll::Base64EncodedCursor.new base64_string
48
+ end
49
+
50
+ let(:base64_string) do
51
+ 'eyJ2YWx1ZSI6IjY0MDY0NTg0MDk0NDM0MjgxZmE3MWFiMiIsImZpZWxkX3R5cGUiOiJCU09OOjpPYmplY3RJZCIsImZpZWxkX25hbWUiOiJpZCIsImRpcmVjdGlvbiI6MSwiaW5jbHVkZV9jdXJyZW50IjpmYWxzZSwidGllYnJlYWtfaWQiOiI2NDA2NDU4NDA5NDQzNDI4MWZhNzFhYjIiLCJ0eXBlIjoibmV4dCJ9'
52
+ end
39
53
  let(:a_value) { BSON::ObjectId('64064584094434281fa71ab2') }
40
54
  let(:tiebreak_id) { a_value }
41
55
  let(:criteria) do
@@ -46,16 +60,20 @@ describe Mongoid::Scroll::Base64EncodedCursor do
46
60
  ]
47
61
  }
48
62
  end
63
+
64
+ its(:value) { is_expected.to eq a_value }
65
+ its(:tiebreak_id) { is_expected.to eq tiebreak_id }
66
+ its(:criteria) { is_expected.to eq(criteria) }
67
+ its(:type) { is_expected.to eq(:next) }
68
+ its(:to_s) { is_expected.to eq(base64_string) }
69
+ end
70
+
71
+ context 'an integer field cursor' do
49
72
  subject do
50
73
  Mongoid::Scroll::Base64EncodedCursor.new base64_string
51
74
  end
52
- its(:value) { should eq a_value }
53
- its(:tiebreak_id) { should eq tiebreak_id }
54
- its(:criteria) { should eq(criteria) }
55
- its(:to_s) { should eq(base64_string) }
56
- end
57
- context 'an integer field cursor' do
58
- let(:base64_string) { 'eyJ2YWx1ZSI6MTAsImZpZWxkX3R5cGUiOiJJbnRlZ2VyIiwiZmllbGRfbmFtZSI6ImFfaW50ZWdlciIsImRpcmVjdGlvbiI6MSwiaW5jbHVkZV9jdXJyZW50IjpmYWxzZSwidGllYnJlYWtfaWQiOiI2NDA2M2RmODA5NDQzNDE3YzdkMmIxMDgifQ==' }
75
+
76
+ let(:base64_string) { 'eyJ2YWx1ZSI6MTAsImZpZWxkX3R5cGUiOiJJbnRlZ2VyIiwiZmllbGRfbmFtZSI6ImFfaW50ZWdlciIsImRpcmVjdGlvbiI6MSwiaW5jbHVkZV9jdXJyZW50IjpmYWxzZSwidGllYnJlYWtfaWQiOiI2NDA2M2RmODA5NDQzNDE3YzdkMmIxMDgiLCJ0eXBlIjoibmV4dCJ9' }
59
77
  let(:a_value) { 10 }
60
78
  let(:tiebreak_id) { BSON::ObjectId('64063df809443417c7d2b108') }
61
79
  let(:criteria) do
@@ -66,18 +84,22 @@ describe Mongoid::Scroll::Base64EncodedCursor do
66
84
  ]
67
85
  }
68
86
  end
69
- subject do
70
- Mongoid::Scroll::Base64EncodedCursor.new base64_string
71
- end
72
- its(:value) { should eq a_value }
87
+
88
+ its(:value) { is_expected.to eq a_value }
73
89
  its(:tiebreak_id) { tiebreak_id }
74
- its(:value) { should eq a_value }
75
- its(:tiebreak_id) { should eq tiebreak_id }
76
- its(:criteria) { should eq(criteria) }
77
- its(:to_s) { should eq(base64_string) }
90
+ its(:value) { is_expected.to eq a_value }
91
+ its(:tiebreak_id) { is_expected.to eq tiebreak_id }
92
+ its(:criteria) { is_expected.to eq(criteria) }
93
+ its(:type) { is_expected.to eq(:next) }
94
+ its(:to_s) { is_expected.to eq(base64_string) }
78
95
  end
96
+
79
97
  context 'a date/time field cursor' do
80
- let(:base64_string) { 'eyJ2YWx1ZSI6MTM4NzU5MDEyMy4wLCJmaWVsZF90eXBlIjoiRGF0ZVRpbWUiLCJmaWVsZF9uYW1lIjoiYV9kYXRldGltZSIsImRpcmVjdGlvbiI6MSwiaW5jbHVkZV9jdXJyZW50IjpmYWxzZSwidGllYnJlYWtfaWQiOiI2NDA2NDNhNzA5NDQzNDIzOWYyZGJmODYifQ==' }
98
+ subject do
99
+ Mongoid::Scroll::Base64EncodedCursor.new base64_string
100
+ end
101
+
102
+ let(:base64_string) { 'eyJ2YWx1ZSI6MTM4NzU5MDEyMy4wLCJmaWVsZF90eXBlIjoiRGF0ZVRpbWUiLCJmaWVsZF9uYW1lIjoiYV9kYXRldGltZSIsImRpcmVjdGlvbiI6MSwiaW5jbHVkZV9jdXJyZW50IjpmYWxzZSwidGllYnJlYWtfaWQiOiI2NDA2NDNhNzA5NDQzNDIzOWYyZGJmODYiLCJ0eXBlIjoibmV4dCJ9' }
81
103
  let(:a_value) { DateTime.new(2013, 12, 21, 1, 42, 3, 'UTC') }
82
104
  let(:tiebreak_id) { BSON::ObjectId('640643a7094434239f2dbf86') }
83
105
  let(:criteria) do
@@ -88,16 +110,20 @@ describe Mongoid::Scroll::Base64EncodedCursor do
88
110
  ]
89
111
  }
90
112
  end
113
+
114
+ its(:value) { is_expected.to eq a_value }
115
+ its(:tiebreak_id) { is_expected.to eq tiebreak_id }
116
+ its(:criteria) { is_expected.to eq(criteria) }
117
+ its(:type) { is_expected.to eq(:next) }
118
+ its(:to_s) { is_expected.to eq(base64_string) }
119
+ end
120
+
121
+ context 'a date field cursor' do
91
122
  subject do
92
123
  Mongoid::Scroll::Base64EncodedCursor.new base64_string
93
124
  end
94
- its(:value) { should eq a_value }
95
- its(:tiebreak_id) { should eq tiebreak_id }
96
- its(:criteria) { should eq(criteria) }
97
- its(:to_s) { should eq(base64_string) }
98
- end
99
- context 'a date field cursor' do
100
- let(:base64_string) { 'eyJ2YWx1ZSI6MTM4NzU4NDAwMCwiZmllbGRfdHlwZSI6IkRhdGUiLCJmaWVsZF9uYW1lIjoiYV9kYXRlIiwiZGlyZWN0aW9uIjoxLCJpbmNsdWRlX2N1cnJlbnQiOmZhbHNlLCJ0aWVicmVha19pZCI6IjY0MDY0MmM5MDk0NDM0MjEyYzRkNDQyMCJ9' }
125
+
126
+ let(:base64_string) { 'eyJ2YWx1ZSI6MTM4NzU4NDAwMCwiZmllbGRfdHlwZSI6IkRhdGUiLCJmaWVsZF9uYW1lIjoiYV9kYXRlIiwiZGlyZWN0aW9uIjoxLCJpbmNsdWRlX2N1cnJlbnQiOmZhbHNlLCJ0aWVicmVha19pZCI6IjY0MDY0MmM5MDk0NDM0MjEyYzRkNDQyMCIsInR5cGUiOiJuZXh0In0=' }
101
127
  let(:tiebreak_id) { BSON::ObjectId('640642c9094434212c4d4420') }
102
128
  let(:a_value) { Date.new(2013, 12, 21) }
103
129
  let(:criteria) do
@@ -108,16 +134,20 @@ describe Mongoid::Scroll::Base64EncodedCursor do
108
134
  ]
109
135
  }
110
136
  end
137
+
138
+ its(:value) { is_expected.to eq a_value }
139
+ its(:tiebreak_id) { is_expected.to eq tiebreak_id }
140
+ its(:criteria) { is_expected.to eq(criteria) }
141
+ its(:type) { is_expected.to eq(:next) }
142
+ its(:to_s) { is_expected.to eq(base64_string) }
143
+ end
144
+
145
+ context 'a time field cursor' do
111
146
  subject do
112
147
  Mongoid::Scroll::Base64EncodedCursor.new base64_string
113
148
  end
114
- its(:value) { should eq a_value }
115
- its(:tiebreak_id) { should eq tiebreak_id }
116
- its(:criteria) { should eq(criteria) }
117
- its(:to_s) { should eq(base64_string) }
118
- end
119
- context 'a time field cursor' do
120
- let(:base64_string) { 'eyJ2YWx1ZSI6MTM4NzYwNTcyMy4wLCJmaWVsZF90eXBlIjoiVGltZSIsImZpZWxkX25hbWUiOiJhX3RpbWUiLCJkaXJlY3Rpb24iOjEsImluY2x1ZGVfY3VycmVudCI6ZmFsc2UsInRpZWJyZWFrX2lkIjoiNjQwNjNkNGEwOTQ0MzQxNjZiZDA1M2VkIn0=' }
149
+
150
+ let(:base64_string) { 'eyJ2YWx1ZSI6MTM4NzYwNTcyMy4wLCJmaWVsZF90eXBlIjoiVGltZSIsImZpZWxkX25hbWUiOiJhX3RpbWUiLCJkaXJlY3Rpb24iOjEsImluY2x1ZGVfY3VycmVudCI6ZmFsc2UsInRpZWJyZWFrX2lkIjoiNjQwNjNkNGEwOTQ0MzQxNjZiZDA1M2VkIiwidHlwZSI6Im5leHQifQ==' }
121
151
  let(:item_id) { BSON::ObjectId('640636f209443407333b46d4') }
122
152
  let(:a_value) { Time.new(2013, 12, 21, 6, 2, 3, '+00:00').utc }
123
153
  let(:tiebreak_id) { BSON::ObjectId('64063d4a094434166bd053ed') }
@@ -129,15 +159,15 @@ describe Mongoid::Scroll::Base64EncodedCursor do
129
159
  ]
130
160
  }
131
161
  end
132
- subject do
133
- Mongoid::Scroll::Base64EncodedCursor.new base64_string
134
- end
135
- its(:value) { should eq a_value }
162
+
163
+ its(:value) { is_expected.to eq a_value }
136
164
  its(:tiebreak_id) { tiebreak_id }
137
- its(:tiebreak_id) { should eq tiebreak_id }
138
- its(:criteria) { should eq(criteria) }
139
- its(:to_s) { should eq(base64_string) }
165
+ its(:tiebreak_id) { is_expected.to eq tiebreak_id }
166
+ its(:criteria) { is_expected.to eq(criteria) }
167
+ its(:type) { is_expected.to eq(:next) }
168
+ its(:to_s) { is_expected.to eq(base64_string) }
140
169
  end
170
+
141
171
  context 'an invalid field cursor' do
142
172
  it 'raises ArgumentError' do
143
173
  expect do
@@ -145,6 +175,7 @@ describe Mongoid::Scroll::Base64EncodedCursor do
145
175
  end.to raise_error Mongoid::Scroll::Errors::InvalidBase64CursorError
146
176
  end
147
177
  end
178
+
148
179
  context 'an invalid cursor' do
149
180
  it 'raises a Mongoid::Scroll::Errors::InvalidBase64CursorError with an invalid Base64 string' do
150
181
  expect { Mongoid::Scroll::Base64EncodedCursor.new 'invalid' }.to raise_error Mongoid::Scroll::Errors::InvalidBase64CursorError, /The cursor supplied is invalid: invalid./
@@ -155,79 +186,119 @@ describe Mongoid::Scroll::Base64EncodedCursor do
155
186
  end
156
187
  end
157
188
  end
189
+
158
190
  context 'from_record' do
159
191
  context 'a string field cursor' do
192
+ subject do
193
+ Mongoid::Scroll::Base64EncodedCursor.from_record feed_item, field_name: field_name, field_type: field_type
194
+ end
195
+
160
196
  let(:field_type) { String }
161
197
  let(:field_value) { 'a string' }
162
198
  let(:field_name) { 'a_string' }
163
199
  let(:feed_item) { Feed::Item.create!(field_name => field_value) }
200
+
201
+ its(:value) { is_expected.to eq field_value }
202
+ its(:field_name) { is_expected.to eq field_name }
203
+ its(:field_type) { is_expected.to eq field_type.to_s }
204
+ end
205
+
206
+ context 'an id field cursor' do
164
207
  subject do
165
208
  Mongoid::Scroll::Base64EncodedCursor.from_record feed_item, field_name: field_name, field_type: field_type
166
209
  end
167
- its(:value) { should eq field_value }
168
- its(:field_name) { should eq field_name }
169
- its(:field_type) { should eq field_type.to_s }
170
- end
171
- context 'an id field cursor' do
210
+
172
211
  let(:field_type) { BSON::ObjectId }
173
212
  let(:field_name) { 'id' }
174
213
  let(:feed_item) { Feed::Item.create! }
214
+
215
+ its(:value) { is_expected.to eq feed_item._id }
216
+ its(:field_type) { is_expected.to eq field_type.to_s }
217
+ end
218
+
219
+ context 'an integer field cursor' do
175
220
  subject do
176
221
  Mongoid::Scroll::Base64EncodedCursor.from_record feed_item, field_name: field_name, field_type: field_type
177
222
  end
178
- its(:value) { should eq feed_item._id }
179
- its(:field_type) { should eq field_type.to_s }
180
- end
181
- context 'an integer field cursor' do
223
+
182
224
  let(:field_type) { Integer }
183
225
  let(:field_value) { 10 }
184
226
  let(:field_name) { 'a_integer' }
185
227
  let(:feed_item) { Feed::Item.create!(field_name => field_value) }
228
+
229
+ its(:value) { is_expected.to eq field_value }
230
+ its(:field_type) { is_expected.to eq field_type.to_s }
231
+ end
232
+
233
+ context 'a date/time field cursor' do
186
234
  subject do
187
235
  Mongoid::Scroll::Base64EncodedCursor.from_record feed_item, field_name: field_name, field_type: field_type
188
236
  end
189
- its(:value) { should eq field_value }
190
- its(:field_type) { should eq field_type.to_s }
191
- end
192
- context 'a date/time field cursor' do
237
+
193
238
  let(:field_type) { DateTime }
194
239
  let(:field_value) { DateTime.new(2013, 12, 21, 1, 42, 3, 'UTC') }
195
240
  let(:field_name) { 'a_datetime' }
196
241
  let(:feed_item) { Feed::Item.create!(field_name => field_value) }
242
+
243
+ its(:value) { is_expected.to eq field_value }
244
+ its(:field_type) { is_expected.to eq field_type.to_s }
245
+ end
246
+
247
+ context 'a date field cursor' do
197
248
  subject do
198
249
  Mongoid::Scroll::Base64EncodedCursor.from_record feed_item, field_name: field_name, field_type: field_type
199
250
  end
200
- its(:value) { should eq field_value }
201
- its(:field_type) { should eq field_type.to_s }
202
- end
203
- context 'a date field cursor' do
251
+
204
252
  let(:field_type) { Date }
205
253
  let(:field_value) { Date.new(2013, 12, 21) }
206
254
  let(:field_name) { 'a_date' }
207
255
  let(:feed_item) { Feed::Item.create!(field_name => field_value) }
256
+
257
+ its(:value) { is_expected.to eq field_value }
258
+ end
259
+
260
+ context 'a time field cursor' do
208
261
  subject do
209
262
  Mongoid::Scroll::Base64EncodedCursor.from_record feed_item, field_name: field_name, field_type: field_type
210
263
  end
211
- its(:value) { should eq field_value }
212
- end
213
- context 'a time field cursor' do
264
+
214
265
  let(:field_type) { Time }
215
266
  let(:field_value) { Time.new(2013, 12, 21, 1, 2, 3) }
216
267
  let(:field_name) { 'a_time' }
217
268
  let(:feed_item) { Feed::Item.create!(field_name => field_value) }
218
- subject do
219
- Mongoid::Scroll::Base64EncodedCursor.from_record feed_item, field_name: field_name, field_type: field_type
220
- end
221
- its(:value) { should eq field_value }
222
- its(:field_type) { should eq field_type.to_s }
269
+
270
+ its(:value) { is_expected.to eq field_value }
271
+ its(:field_type) { is_expected.to eq field_type.to_s }
223
272
  end
273
+
224
274
  context 'an array field cursor' do
225
275
  let(:feed_item) { Feed::Item.create!(a_array: %w[x y]) }
276
+
226
277
  it 'is not supported' do
227
278
  expect do
228
279
  Mongoid::Scroll::Base64EncodedCursor.from_record feed_item, field_name: 'a_array', field_type: Array
229
280
  end.to raise_error Mongoid::Scroll::Errors::UnsupportedFieldTypeError, /The type of the field 'a_array' is not supported: Array./
230
281
  end
231
282
  end
283
+
284
+ it 'encode and decode type option' do
285
+ feed_item = Feed::Item.create!
286
+ cursor = Mongoid::Scroll::Base64EncodedCursor.from_record feed_item, field_name: 'id', field_type: BSON::ObjectId, type: :previous
287
+ expect(Mongoid::Scroll::Base64EncodedCursor.new(cursor.to_s).type).to eq(:previous)
288
+ end
289
+
290
+ context 'a cursor with previous set to true' do
291
+ subject do
292
+ Mongoid::Scroll::Base64EncodedCursor.from_record feed_item, field_name: field_name, field_type: field_type, type: :previous
293
+ end
294
+
295
+ let(:field_type) { BSON::ObjectId }
296
+ let(:field_name) { 'id' }
297
+ let(:feed_item) { Feed::Item.create! }
298
+
299
+ its(:value) { is_expected.to eq feed_item._id }
300
+ its(:field_type) { is_expected.to eq field_type.to_s }
301
+ its(:type) { is_expected.to eq(:previous) }
302
+ end
232
303
  end
233
304
  end