mongo 2.1.2 → 2.2.0.rc0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.md +10 -3
  5. data/Rakefile +1 -7
  6. data/lib/csasl/csasl.bundle +0 -0
  7. data/lib/mongo/auth/user/view.rb +1 -1
  8. data/lib/mongo/bulk_write.rb +7 -1
  9. data/lib/mongo/client.rb +17 -15
  10. data/lib/mongo/cluster.rb +4 -2
  11. data/lib/mongo/collection.rb +36 -2
  12. data/lib/mongo/collection/view.rb +24 -21
  13. data/lib/mongo/collection/view/aggregation.rb +5 -42
  14. data/lib/mongo/collection/view/builder.rb +20 -0
  15. data/lib/mongo/collection/view/builder/aggregation.rb +98 -0
  16. data/lib/mongo/collection/view/builder/find_command.rb +111 -0
  17. data/lib/mongo/collection/view/builder/flags.rb +62 -0
  18. data/lib/mongo/collection/view/builder/map_reduce.rb +134 -0
  19. data/lib/mongo/collection/view/builder/modifiers.rb +80 -0
  20. data/lib/mongo/collection/view/builder/op_query.rb +83 -0
  21. data/lib/mongo/collection/view/explainable.rb +15 -0
  22. data/lib/mongo/collection/view/immutable.rb +5 -12
  23. data/lib/mongo/collection/view/iterable.rb +24 -2
  24. data/lib/mongo/collection/view/map_reduce.rb +18 -27
  25. data/lib/mongo/collection/view/readable.rb +70 -112
  26. data/lib/mongo/collection/view/writable.rb +23 -7
  27. data/lib/mongo/cursor.rb +76 -25
  28. data/lib/mongo/cursor/builder.rb +18 -0
  29. data/lib/mongo/cursor/builder/get_more_command.rb +71 -0
  30. data/lib/mongo/cursor/builder/kill_cursors_command.rb +62 -0
  31. data/lib/mongo/cursor/builder/op_get_more.rb +61 -0
  32. data/lib/mongo/cursor/builder/op_kill_cursors.rb +56 -0
  33. data/lib/mongo/database.rb +2 -2
  34. data/lib/mongo/database/view.rb +9 -5
  35. data/lib/mongo/dbref.rb +3 -3
  36. data/lib/mongo/error.rb +1 -0
  37. data/lib/mongo/error/invalid_write_concern.rb +35 -0
  38. data/lib/mongo/grid/file/chunk.rb +2 -2
  39. data/lib/mongo/index/view.rb +5 -2
  40. data/lib/mongo/operation.rb +1 -0
  41. data/lib/mongo/operation/commands.rb +2 -0
  42. data/lib/mongo/operation/commands/aggregate.rb +39 -45
  43. data/lib/mongo/operation/commands/aggregate/result.rb +54 -68
  44. data/lib/mongo/operation/commands/collections_info.rb +38 -36
  45. data/lib/mongo/operation/commands/collections_info/result.rb +17 -15
  46. data/lib/mongo/operation/commands/command.rb +24 -22
  47. data/lib/mongo/operation/commands/find.rb +27 -0
  48. data/lib/mongo/operation/commands/find/result.rb +62 -0
  49. data/lib/mongo/operation/commands/get_more.rb +27 -0
  50. data/lib/mongo/operation/commands/get_more/result.rb +62 -0
  51. data/lib/mongo/operation/commands/indexes.rb +41 -39
  52. data/lib/mongo/operation/commands/list_collections.rb +25 -31
  53. data/lib/mongo/operation/commands/list_collections/result.rb +63 -81
  54. data/lib/mongo/operation/commands/list_indexes.rb +27 -35
  55. data/lib/mongo/operation/commands/list_indexes/result.rb +67 -85
  56. data/lib/mongo/operation/commands/map_reduce.rb +29 -37
  57. data/lib/mongo/operation/commands/map_reduce/result.rb +85 -88
  58. data/lib/mongo/operation/commands/parallel_scan.rb +29 -33
  59. data/lib/mongo/operation/commands/parallel_scan/result.rb +34 -42
  60. data/lib/mongo/operation/commands/user_query.rb +40 -38
  61. data/lib/mongo/operation/commands/users_info.rb +24 -29
  62. data/lib/mongo/operation/commands/users_info/result.rb +13 -11
  63. data/lib/mongo/operation/object_id_generator.rb +36 -0
  64. data/lib/mongo/operation/result.rb +30 -0
  65. data/lib/mongo/operation/specifiable.rb +35 -1
  66. data/lib/mongo/operation/write/bulk/bulkable.rb +4 -3
  67. data/lib/mongo/operation/write/bulk/delete/result.rb +18 -25
  68. data/lib/mongo/operation/write/bulk/legacy_mergable.rb +2 -2
  69. data/lib/mongo/operation/write/command/delete.rb +3 -2
  70. data/lib/mongo/operation/write/command/insert.rb +4 -2
  71. data/lib/mongo/operation/write/command/update.rb +6 -3
  72. data/lib/mongo/operation/write/gle.rb +2 -1
  73. data/lib/mongo/operation/write/idable.rb +19 -2
  74. data/lib/mongo/options/mapper.rb +22 -0
  75. data/lib/mongo/protocol/bit_vector.rb +3 -3
  76. data/lib/mongo/protocol/delete.rb +15 -5
  77. data/lib/mongo/protocol/get_more.rb +10 -5
  78. data/lib/mongo/protocol/insert.rb +1 -6
  79. data/lib/mongo/protocol/kill_cursors.rb +14 -1
  80. data/lib/mongo/protocol/message.rb +32 -8
  81. data/lib/mongo/protocol/serializers.rb +15 -16
  82. data/lib/mongo/protocol/update.rb +35 -12
  83. data/lib/mongo/server/connectable.rb +3 -1
  84. data/lib/mongo/server/connection.rb +5 -5
  85. data/lib/mongo/server/description.rb +8 -2
  86. data/lib/mongo/server/description/features.rb +2 -1
  87. data/lib/mongo/server/monitor.rb +1 -12
  88. data/lib/mongo/server/monitor/connection.rb +30 -26
  89. data/lib/mongo/server_selector/selectable.rb +21 -4
  90. data/lib/mongo/uri.rb +2 -0
  91. data/lib/mongo/version.rb +1 -1
  92. data/lib/mongo/write_concern.rb +21 -6
  93. data/mongo.gemspec +1 -2
  94. data/spec/mongo/bulk_write/ordered_combiner_spec.rb +13 -0
  95. data/spec/mongo/bulk_write_spec.rb +58 -0
  96. data/spec/mongo/client_spec.rb +6 -4
  97. data/spec/mongo/collection/view/builder/find_command_spec.rb +167 -0
  98. data/spec/mongo/collection/view/builder/flags_spec.rb +106 -0
  99. data/spec/mongo/collection/view/builder/modifiers_spec.rb +210 -0
  100. data/spec/mongo/collection/view/builder/op_query_spec.rb +154 -0
  101. data/spec/mongo/collection/view/explainable_spec.rb +1 -2
  102. data/spec/mongo/collection/view/immutable_spec.rb +3 -52
  103. data/spec/mongo/collection/view/map_reduce_spec.rb +12 -12
  104. data/spec/mongo/collection/view/readable_spec.rb +86 -80
  105. data/spec/mongo/collection/view_spec.rb +109 -703
  106. data/spec/mongo/collection_spec.rb +594 -11
  107. data/spec/mongo/command_monitoring_spec.rb +40 -27
  108. data/spec/mongo/cursor/builder/get_more_command_spec.rb +160 -0
  109. data/spec/mongo/cursor/builder/op_get_more_spec.rb +52 -0
  110. data/spec/mongo/cursor_spec.rb +10 -60
  111. data/spec/mongo/database_spec.rb +24 -3
  112. data/spec/mongo/dbref_spec.rb +4 -4
  113. data/spec/mongo/grid/file/chunk_spec.rb +1 -1
  114. data/spec/mongo/grid/fs_bucket_spec.rb +3 -3
  115. data/spec/mongo/index/view_spec.rb +41 -0
  116. data/spec/mongo/operation/{aggregate → commands/aggregate}/result_spec.rb +1 -1
  117. data/spec/mongo/operation/commands/aggregate_spec.rb +1 -1
  118. data/spec/mongo/operation/commands/collections_info_spec.rb +1 -1
  119. data/spec/mongo/operation/commands/command_spec.rb +1 -1
  120. data/spec/mongo/operation/commands/indexes_spec.rb +1 -1
  121. data/spec/mongo/operation/commands/map_reduce_spec.rb +1 -1
  122. data/spec/mongo/operation/write/command/delete_spec.rb +25 -0
  123. data/spec/mongo/operation/write/command/insert_spec.rb +25 -0
  124. data/spec/mongo/operation/write/command/update_spec.rb +25 -0
  125. data/spec/mongo/protocol/delete_spec.rb +4 -4
  126. data/spec/mongo/protocol/get_more_spec.rb +4 -4
  127. data/spec/mongo/protocol/insert_spec.rb +3 -3
  128. data/spec/mongo/protocol/kill_cursors_spec.rb +3 -3
  129. data/spec/mongo/protocol/query_spec.rb +7 -7
  130. data/spec/mongo/protocol/update_spec.rb +5 -5
  131. data/spec/mongo/server/description/features_spec.rb +25 -0
  132. data/spec/mongo/write_concern_spec.rb +126 -0
  133. data/spec/spec_helper.rb +9 -19
  134. data/spec/support/command_monitoring.rb +8 -0
  135. data/spec/support/command_monitoring/find.yml +53 -4
  136. data/spec/support/matchers.rb +1 -1
  137. data/spec/support/shared/protocol.rb +5 -5
  138. data/spec/support/travis.rb +1 -1
  139. metadata +43 -10
  140. metadata.gz.sig +0 -0
@@ -69,7 +69,7 @@ describe Mongo::DBRef do
69
69
  end
70
70
 
71
71
  it 'converts the underlying document to bson' do
72
- expect(dbref.to_bson).to eq(dbref.as_json.to_bson)
72
+ expect(dbref.to_bson.to_s).to eq(dbref.as_json.to_bson.to_s)
73
73
  end
74
74
  end
75
75
 
@@ -100,12 +100,12 @@ describe Mongo::DBRef do
100
100
 
101
101
  describe '#from_bson' do
102
102
 
103
- let(:bson) do
104
- StringIO.new(dbref.to_bson)
103
+ let(:buffer) do
104
+ dbref.to_bson
105
105
  end
106
106
 
107
107
  let(:decoded) do
108
- BSON::Document.from_bson(bson)
108
+ BSON::Document.from_bson(BSON::ByteBuffer.new(buffer.to_s))
109
109
  end
110
110
 
111
111
  context 'when a database exists' do
@@ -140,7 +140,7 @@ describe Mongo::Grid::File::Chunk do
140
140
  end
141
141
 
142
142
  it 'returns the document as bson' do
143
- expect(chunk.to_bson).to eq(document.to_bson)
143
+ expect(chunk.to_bson.to_s).to eq(document.to_bson.to_s)
144
144
  end
145
145
  end
146
146
 
@@ -124,14 +124,14 @@ describe Mongo::Grid::FSBucket do
124
124
  end
125
125
  end
126
126
 
127
- context 'when provided a selector' do
127
+ context 'when provided a filter' do
128
128
 
129
129
  let(:view) do
130
130
  fs.find(filename: 'test.txt')
131
131
  end
132
132
 
133
- it 'returns a collection view for the selector' do
134
- expect(view.selector).to eq(filename: 'test.txt')
133
+ it 'returns a collection view for the filter' do
134
+ expect(view.filter).to eq('filename' => 'test.txt')
135
135
  end
136
136
  end
137
137
 
@@ -196,6 +196,47 @@ describe Mongo::Index::View do
196
196
  expect(view.get('random_name')).to_not be_nil
197
197
  end
198
198
  end
199
+
200
+ context 'when providing an invalid partial index filter', if: find_command_enabled? do
201
+
202
+ it 'raises an exception' do
203
+ expect {
204
+ view.create_one({'x' => 1}, partial_filter_expression: 5)
205
+ }.to raise_error(Mongo::Error::OperationFailure)
206
+ end
207
+ end
208
+
209
+ context 'when providing a valid partial index filter', if: find_command_enabled? do
210
+
211
+ let(:expression) do
212
+ {'a' => {'$lte' => 1.5}}
213
+ end
214
+
215
+ let!(:result) do
216
+ view.create_one({'x' => 1}, partial_filter_expression: expression)
217
+ end
218
+
219
+ let(:indexes) do
220
+ authorized_collection.indexes.get('x_1')
221
+ end
222
+
223
+ after do
224
+ view.drop_one('x_1')
225
+ end
226
+
227
+ it 'returns ok' do
228
+ expect(result).to be_successful
229
+ end
230
+
231
+ it 'creates an index' do
232
+ expect(indexes).to_not be_nil
233
+ end
234
+
235
+ it 'passes partialFilterExpression correctly' do
236
+ expect(indexes[:partialFilterExpression]).to eq(expression)
237
+ end
238
+
239
+ end
199
240
  end
200
241
 
201
242
  describe '#get' do
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Mongo::Operation::Aggregate::Result do
3
+ describe Mongo::Operation::Commands::Aggregate::Result do
4
4
 
5
5
  let(:result) do
6
6
  described_class.new(reply)
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Mongo::Operation::Aggregate do
3
+ describe Mongo::Operation::Commands::Aggregate do
4
4
  include_context 'operation'
5
5
 
6
6
  let(:selector) do
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Mongo::Operation::CollectionsInfo do
3
+ describe Mongo::Operation::Commands::CollectionsInfo do
4
4
 
5
5
  let(:spec) do
6
6
  { :db_name => TEST_DB }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Mongo::Operation::Command do
3
+ describe Mongo::Operation::Commands::Command do
4
4
 
5
5
  let(:selector) { { :ismaster => 1 } }
6
6
  let(:options) { { :limit => -1 } }
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Mongo::Operation::Indexes do
3
+ describe Mongo::Operation::Commands::Indexes do
4
4
 
5
5
  describe '#execute' do
6
6
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Mongo::Operation::MapReduce do
3
+ describe Mongo::Operation::Commands::MapReduce do
4
4
 
5
5
  let(:map) do
6
6
  %Q{
@@ -56,6 +56,31 @@ describe Mongo::Operation::Write::Command::Delete do
56
56
  end
57
57
  end
58
58
 
59
+ describe 'write concern' do
60
+
61
+ context 'when write concern is not specified' do
62
+
63
+ let(:spec) do
64
+ { :deletes => deletes,
65
+ :db_name => db_name,
66
+ :coll_name => coll_name,
67
+ :ordered => true
68
+ }
69
+ end
70
+
71
+ it 'does not include write concern in the selector' do
72
+ expect(op.send(:selector)[:writeConcern]).to be_nil
73
+ end
74
+ end
75
+
76
+ context 'when write concern is specified' do
77
+
78
+ it 'includes write concern in the selector' do
79
+ expect(op.send(:selector)[:writeConcern]).to eq(write_concern.options)
80
+ end
81
+ end
82
+ end
83
+
59
84
  describe '#execute' do
60
85
 
61
86
  context 'server' do
@@ -56,6 +56,31 @@ describe Mongo::Operation::Write::Command::Insert do
56
56
  end
57
57
  end
58
58
 
59
+ describe 'write concern' do
60
+
61
+ context 'when write concern is not specified' do
62
+
63
+ let(:spec) do
64
+ { :documents => documents,
65
+ :db_name => db_name,
66
+ :coll_name => coll_name,
67
+ :ordered => true
68
+ }
69
+ end
70
+
71
+ it 'does not include write concern in the selector' do
72
+ expect(op.send(:selector)[:writeConcern]).to be_nil
73
+ end
74
+ end
75
+
76
+ context 'when write concern is specified' do
77
+
78
+ it 'includes write concern in the selector' do
79
+ expect(op.send(:selector)[:writeConcern]).to eq(write_concern.options)
80
+ end
81
+ end
82
+ end
83
+
59
84
  describe '#execute' do
60
85
 
61
86
  context 'server' do
@@ -62,6 +62,31 @@ describe Mongo::Operation::Write::Command::Update do
62
62
  end
63
63
  end
64
64
 
65
+ describe 'write concern' do
66
+
67
+ context 'when write concern is not specified' do
68
+
69
+ let(:spec) do
70
+ { :updates => updates,
71
+ :db_name => db_name,
72
+ :coll_name => coll_name,
73
+ :ordered => true
74
+ }
75
+ end
76
+
77
+ it 'does not include write concern in the selector' do
78
+ expect(op.send(:selector)[:writeConcern]).to be_nil
79
+ end
80
+ end
81
+
82
+ context 'when write concern is specified' do
83
+
84
+ it 'includes write concern in the selector' do
85
+ expect(op.send(:selector)[:writeConcern]).to eq(write_concern.options)
86
+ end
87
+ end
88
+ end
89
+
65
90
  describe '#execute' do
66
91
 
67
92
  context 'server' do
@@ -122,7 +122,7 @@ describe Mongo::Protocol::Delete do
122
122
  include_examples 'message with a header'
123
123
 
124
124
  describe 'zero' do
125
- let(:field) { bytes[16..19] }
125
+ let(:field) { bytes.to_s[16..19] }
126
126
 
127
127
  it 'serializes a zero' do
128
128
  expect(field).to be_int32(0)
@@ -130,14 +130,14 @@ describe Mongo::Protocol::Delete do
130
130
  end
131
131
 
132
132
  describe 'namespace' do
133
- let(:field) { bytes[20..36] }
133
+ let(:field) { bytes.to_s[20..36] }
134
134
  it 'serializes the namespace' do
135
135
  expect(field).to be_cstring(ns)
136
136
  end
137
137
  end
138
138
 
139
139
  describe 'flags' do
140
- let(:field) { bytes[37..40] }
140
+ let(:field) { bytes.to_s[37..40] }
141
141
 
142
142
  context 'when no flags are provided' do
143
143
  it 'does not set any bits' do
@@ -158,7 +158,7 @@ describe Mongo::Protocol::Delete do
158
158
  end
159
159
 
160
160
  describe 'selector' do
161
- let(:field) { bytes[41..-1] }
161
+ let(:field) { bytes.to_s[41..-1] }
162
162
  it 'serializes the selector' do
163
163
  expect(field).to be_bson(selector)
164
164
  end
@@ -115,7 +115,7 @@ describe Mongo::Protocol::GetMore do
115
115
  include_examples 'message with a header'
116
116
 
117
117
  describe 'zero' do
118
- let(:field) { bytes[16..19] }
118
+ let(:field) { bytes.to_s[16..19] }
119
119
 
120
120
  it 'does not set any bits' do
121
121
  expect(field).to be_int32(0)
@@ -123,21 +123,21 @@ describe Mongo::Protocol::GetMore do
123
123
  end
124
124
 
125
125
  describe 'namespace' do
126
- let(:field) { bytes[20..36] }
126
+ let(:field) { bytes.to_s[20..36] }
127
127
  it 'serializes the namespace' do
128
128
  expect(field).to be_cstring(ns)
129
129
  end
130
130
  end
131
131
 
132
132
  describe 'number to return' do
133
- let(:field) { bytes[37..40] }
133
+ let(:field) { bytes.to_s[37..40] }
134
134
  it 'serializes the number to return' do
135
135
  expect(field).to be_int32(limit)
136
136
  end
137
137
  end
138
138
 
139
139
  describe 'cursor id' do
140
- let(:field) { bytes[41..48] }
140
+ let(:field) { bytes.to_s[41..48] }
141
141
  it 'serializes the cursor id' do
142
142
  expect(field).to be_int64(cursor_id)
143
143
  end
@@ -124,7 +124,7 @@ describe Mongo::Protocol::Insert do
124
124
  include_examples 'message with a header'
125
125
 
126
126
  describe 'flags' do
127
- let(:field) { bytes[16..19] }
127
+ let(:field) { bytes.to_s[16..19] }
128
128
 
129
129
  context 'when no flags are provided' do
130
130
  it 'does not set any bits' do
@@ -145,14 +145,14 @@ describe Mongo::Protocol::Insert do
145
145
  end
146
146
 
147
147
  describe 'namespace' do
148
- let(:field) { bytes[20..36] }
148
+ let(:field) { bytes.to_s[20..36] }
149
149
  it 'serializes the namespace' do
150
150
  expect(field).to be_cstring(ns)
151
151
  end
152
152
  end
153
153
 
154
154
  describe 'documents' do
155
- let(:field) { bytes[37..-1] }
155
+ let(:field) { bytes.to_s[37..-1] }
156
156
  it 'serializes the documents' do
157
157
  expect(field).to be_bson_sequence(docs)
158
158
  end
@@ -79,7 +79,7 @@ describe Mongo::Protocol::KillCursors do
79
79
  include_examples 'message with a header'
80
80
 
81
81
  describe 'zero' do
82
- let(:field) { bytes[16..19] }
82
+ let(:field) { bytes.to_s[16..19] }
83
83
 
84
84
  it 'serializes a zero' do
85
85
  expect(field).to be_int32(0)
@@ -87,14 +87,14 @@ describe Mongo::Protocol::KillCursors do
87
87
  end
88
88
 
89
89
  describe 'number of cursors' do
90
- let(:field) { bytes[20..23] }
90
+ let(:field) { bytes.to_s[20..23] }
91
91
  it 'serializes the cursor count' do
92
92
  expect(field).to be_int32(id_count)
93
93
  end
94
94
  end
95
95
 
96
96
  describe 'cursor ids' do
97
- let(:field) { bytes[24..-1] }
97
+ let(:field) { bytes.to_s[24..-1] }
98
98
  it 'serializes the selector' do
99
99
  expect(field).to be_int64_sequence(cursor_ids)
100
100
  end
@@ -147,7 +147,7 @@ describe Mongo::Protocol::Query do
147
147
  include_examples 'message with a header'
148
148
 
149
149
  describe 'flags' do
150
- let(:field) { bytes[16..19] }
150
+ let(:field) { bytes.to_s[16..19] }
151
151
 
152
152
  context 'when no flags are provided' do
153
153
  it 'does not set any bits' do
@@ -217,13 +217,13 @@ describe Mongo::Protocol::Query do
217
217
  end
218
218
 
219
219
  describe 'namespace' do
220
- let(:field) { bytes[20..36] }
220
+ let(:field) { bytes.to_s[20..36] }
221
221
  it 'serializes the namespace' do
222
222
  expect(field).to be_cstring(ns)
223
223
  end
224
224
 
225
225
  context 'when the namespace contains unicode characters' do
226
- let(:field) { bytes[20..40] }
226
+ let(:field) { bytes.to_s[20..40] }
227
227
 
228
228
  let(:coll) do
229
229
  'områder'
@@ -237,7 +237,7 @@ describe Mongo::Protocol::Query do
237
237
  end
238
238
 
239
239
  describe 'skip' do
240
- let(:field) { bytes[37..40] }
240
+ let(:field) { bytes.to_s[37..40] }
241
241
 
242
242
  context 'when no skip is provided' do
243
243
  it 'serializes a zero' do
@@ -255,7 +255,7 @@ describe Mongo::Protocol::Query do
255
255
  end
256
256
 
257
257
  describe 'limit' do
258
- let(:field) { bytes[41..44] }
258
+ let(:field) { bytes.to_s[41..44] }
259
259
 
260
260
  context 'when no limit is provided' do
261
261
  it 'serializes a zero' do
@@ -272,14 +272,14 @@ describe Mongo::Protocol::Query do
272
272
  end
273
273
 
274
274
  describe 'selector' do
275
- let(:field) { bytes[45..65] }
275
+ let(:field) { bytes.to_s[45..65] }
276
276
  it 'serializes the selector' do
277
277
  expect(field).to be_bson(selector)
278
278
  end
279
279
  end
280
280
 
281
281
  describe 'project' do
282
- let(:field) { bytes[66..-1] }
282
+ let(:field) { bytes.to_s[66..-1] }
283
283
  context 'when no projection is provided' do
284
284
  it 'does not serialize a projection' do
285
285
  expect(field).to be_empty
@@ -127,7 +127,7 @@ describe Mongo::Protocol::Update do
127
127
  include_examples 'message with a header'
128
128
 
129
129
  describe 'zero' do
130
- let(:field) { bytes[16..19] }
130
+ let(:field) { bytes.to_s[16..19] }
131
131
 
132
132
  it 'serializes a zero' do
133
133
  expect(field).to be_int32(0)
@@ -135,14 +135,14 @@ describe Mongo::Protocol::Update do
135
135
  end
136
136
 
137
137
  describe 'namespace' do
138
- let(:field) { bytes[20..36] }
138
+ let(:field) { bytes.to_s[20..36] }
139
139
  it 'serializes the namespace' do
140
140
  expect(field).to be_cstring(ns)
141
141
  end
142
142
  end
143
143
 
144
144
  describe 'flags' do
145
- let(:field) { bytes[37..40] }
145
+ let(:field) { bytes.to_s[37..40] }
146
146
 
147
147
  context 'when no flags are provided' do
148
148
  it 'does not set any bits' do
@@ -170,14 +170,14 @@ describe Mongo::Protocol::Update do
170
170
  end
171
171
 
172
172
  describe 'selector' do
173
- let(:field) { bytes[41..61] }
173
+ let(:field) { bytes.to_s[41..61] }
174
174
  it 'serializes the selector' do
175
175
  expect(field).to be_bson(selector)
176
176
  end
177
177
  end
178
178
 
179
179
  describe 'update' do
180
- let(:field) { bytes[62..80] }
180
+ let(:field) { bytes.to_s[62..80] }
181
181
  it 'serializes the update' do
182
182
  expect(field).to be_bson(update_doc)
183
183
  end