File tree Expand file tree Collapse file tree 3 files changed +61
-0
lines changed
spec/mongo/operation/read Expand file tree Collapse file tree 3 files changed +61
-0
lines changed Original file line number Diff line number Diff line change 12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
+ require 'mongo/operation/read/query/result'
16
+
15
17
module Mongo
16
18
module Operation
17
19
module Read
Original file line number Diff line number Diff line change
1
+ # Copyright (C) 2014-2015 MongoDB, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Mongo
16
+ module Operation
17
+ module Read
18
+ class Query
19
+
20
+ # Defines custom behaviour of results for a query.
21
+ #
22
+ # @since 2.1.0
23
+ class Result < Operation ::Result
24
+
25
+ # Determine if the query was a success.
26
+ #
27
+ # @example Was the query successful?
28
+ # result.successful?
29
+ #
30
+ # @return [ true, false ] If the query was successful.
31
+ #
32
+ # @since 2.0.0
33
+ def successful?
34
+ !query_failure? && parser . message . empty?
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
Original file line number Diff line number Diff line change 82
82
op . execute ( primary_context )
83
83
end
84
84
end
85
+
86
+ context "when the document contains an 'ok' field" do
87
+
88
+ before do
89
+ authorized_collection . insert_one ( ok : false )
90
+ end
91
+
92
+ after do
93
+ authorized_collection . delete_many
94
+ end
95
+
96
+ let ( :context ) do
97
+ authorized_client . cluster . next_primary . context
98
+ end
99
+
100
+ it 'does not raise an exception' do
101
+ expect ( op . execute ( context ) ) . to be_a ( Mongo ::Operation ::Read ::Query ::Result )
102
+ end
103
+ end
85
104
end
86
105
end
87
106
You can’t perform that action at this time.
0 commit comments