|
85 | 85 |
|
86 | 86 | describe ".===" do
|
87 | 87 |
|
88 |
| - context "when comparable is an instance of this document" do |
| 88 | + context "when legacy_triple_equals is set" do |
| 89 | + config_override :legacy_triple_equals, true |
| 90 | + |
| 91 | + context "when comparable is an instance of this document" do |
89 | 92 |
|
90 |
| - with_config_values :legacy_triple_equals, false, true do |
91 | 93 | it "returns true" do
|
92 | 94 | expect(klass === person).to be true
|
93 | 95 | end
|
94 | 96 | end
|
95 |
| - end |
96 | 97 |
|
97 |
| - context "when comparable is a relation of this document" do |
| 98 | + context "when comparable is a relation of this document" do |
98 | 99 |
|
99 |
| - let(:relation) do |
100 |
| - Post.new(person: person).person |
101 |
| - end |
| 100 | + let(:relation) do |
| 101 | + Post.new(person: person).person |
| 102 | + end |
102 | 103 |
|
103 |
| - with_config_values :legacy_triple_equals, false, true do |
104 | 104 | it "returns true" do
|
105 | 105 | expect(klass === relation).to be true
|
106 | 106 | end
|
107 | 107 | end
|
108 |
| - end |
109 | 108 |
|
110 |
| - context "when comparable is the same class" do |
111 |
| - |
112 |
| - context "when legacy_triple_equals is not set" do |
113 |
| - config_override :legacy_triple_equals, false |
| 109 | + context "when comparable is the same class" do |
114 | 110 |
|
115 | 111 | it "returns false" do
|
116 | 112 | expect(klass === Person).to be false
|
117 | 113 | end
|
118 | 114 | end
|
119 | 115 |
|
120 |
| - context "when legacy_triple_equals is set" do |
121 |
| - config_override :legacy_triple_equals, true |
122 |
| - |
123 |
| - it "returns true" do |
124 |
| - expect(klass === Person).to be true |
125 |
| - end |
126 |
| - end |
127 |
| - end |
128 |
| - |
129 |
| - context "when the comparable is a subclass" do |
| 116 | + context "when the comparable is a subclass" do |
130 | 117 |
|
131 |
| - with_config_values :legacy_triple_equals, false, true do |
132 | 118 | it "returns false" do
|
133 | 119 | expect(Person === Doctor).to be false
|
134 | 120 | end
|
135 | 121 | end
|
136 |
| - end |
137 | 122 |
|
138 |
| - context "when the comparable is an instance of a subclass" do |
| 123 | + context "when the comparable is an instance of a subclass" do |
139 | 124 |
|
140 |
| - with_config_values :legacy_triple_equals, false, true do |
141 | 125 | it "returns true" do
|
142 | 126 | expect(Person === Doctor.new).to be true
|
143 | 127 | end
|
144 | 128 | end
|
145 | 129 | end
|
146 | 130 |
|
147 |
| - context "when comparing to a class" do |
148 |
| - |
149 |
| - context "when legacy_triple_equals is not set" do |
150 |
| - config_override :legacy_triple_equals, false |
| 131 | + context "when legacy_triple_equals is not set" do |
| 132 | + config_override :legacy_triple_equals, false |
151 | 133 |
|
152 |
| - context "when the class is the same" do |
| 134 | + context "when comparable is an instance of this document" do |
153 | 135 |
|
154 |
| - it "returns false" do |
155 |
| - expect(Person === Person).to be false |
156 |
| - end |
| 136 | + it "returns true" do |
| 137 | + expect(klass === person).to be true |
157 | 138 | end
|
| 139 | + end |
158 | 140 |
|
159 |
| - context "when the class is a subclass" do |
| 141 | + context "when comparable is a relation of this document" do |
160 | 142 |
|
161 |
| - it "returns false" do |
162 |
| - expect(Person === Doctor).to be false |
163 |
| - end |
| 143 | + let(:relation) do |
| 144 | + Post.new(person: person).person |
164 | 145 | end
|
165 | 146 |
|
166 |
| - context "when the class is a superclass" do |
167 |
| - |
168 |
| - it "returns false" do |
169 |
| - expect(Doctor === Person).to be false |
170 |
| - end |
| 147 | + it "returns true" do |
| 148 | + expect(klass === relation).to be true |
171 | 149 | end
|
172 | 150 | end
|
173 | 151 |
|
174 |
| - context "when legacy_triple_equals is set" do |
175 |
| - config_override :legacy_triple_equals, true |
| 152 | + context "when comparable is the same class" do |
176 | 153 |
|
177 |
| - context "when the class is the same" do |
178 |
| - |
179 |
| - it "returns true" do |
180 |
| - expect(Person === Person).to be true |
181 |
| - end |
| 154 | + it "returns true" do |
| 155 | + expect(klass === Person).to be true |
182 | 156 | end
|
| 157 | + end |
183 | 158 |
|
184 |
| - context "when the class is a subclass" do |
| 159 | + context "when the comparable is a subclass" do |
185 | 160 |
|
186 |
| - it "returns false" do |
187 |
| - expect(Person === Doctor).to be false |
188 |
| - end |
| 161 | + it "returns false" do |
| 162 | + expect(Person === Doctor).to be false |
189 | 163 | end
|
| 164 | + end |
190 | 165 |
|
191 |
| - context "when the class is a superclass" do |
| 166 | + context "when the comparable is an instance of a subclass" do |
192 | 167 |
|
193 |
| - it "returns true" do |
194 |
| - expect(Doctor === Person).to be true |
195 |
| - end |
| 168 | + it "returns true" do |
| 169 | + expect(Person === Doctor.new).to be true |
196 | 170 | end
|
197 | 171 | end
|
198 | 172 | end
|
199 | 173 | end
|
200 | 174 |
|
201 | 175 | describe "#===" do
|
202 | 176 |
|
203 |
| - context "when comparable is the same type" do |
| 177 | + context "when legacy_triple_equals is set" do |
| 178 | + config_override :legacy_triple_equals, true |
204 | 179 |
|
205 |
| - context "when the instance is different" do |
| 180 | + context "when comparable is the same type" do |
206 | 181 |
|
207 |
| - it "returns false" do |
208 |
| - expect(person === Person.new).to be false |
| 182 | + context "when the instance is different" do |
| 183 | + |
| 184 | + it "returns false" do |
| 185 | + expect(person === Person.new).to be false |
| 186 | + end |
209 | 187 | end
|
210 |
| - end |
211 | 188 |
|
212 |
| - context "when the instance is the same" do |
| 189 | + context "when the instance is the same" do |
213 | 190 |
|
214 |
| - it "returns true" do |
215 |
| - expect(person === person).to be true |
| 191 | + it "returns true" do |
| 192 | + expect(person === person).to be true |
| 193 | + end |
216 | 194 | end
|
217 | 195 | end
|
218 |
| - end |
219 | 196 |
|
220 |
| - context "when the comparable is a subclass" do |
| 197 | + context "when the comparable is a subclass" do |
221 | 198 |
|
222 |
| - with_config_values :legacy_triple_equals, false, true do |
223 | 199 | it "returns false" do
|
224 | 200 | expect(person === Doctor.new).to be false
|
225 | 201 | end
|
226 | 202 | end
|
227 |
| - end |
228 |
| - |
229 |
| - context "when comparing to a class" do |
230 | 203 |
|
231 |
| - context "when legacy_triple_equals is not set" do |
232 |
| - config_override :legacy_triple_equals, false |
| 204 | + context "when comparing to a class" do |
233 | 205 |
|
234 | 206 | context "when the class is the same" do
|
235 | 207 |
|
|
252 | 224 | end
|
253 | 225 | end
|
254 | 226 | end
|
| 227 | + end |
| 228 | + |
| 229 | + context "when legacy_triple_equals is not set" do |
| 230 | + config_override :legacy_triple_equals, false |
| 231 | + |
| 232 | + context "when comparable is the same type" do |
| 233 | + |
| 234 | + context "when the instance is different" do |
| 235 | + |
| 236 | + it "returns false" do |
| 237 | + expect(person === Person.new).to be false |
| 238 | + end |
| 239 | + end |
255 | 240 |
|
256 |
| - context "when legacy_triple_equals is set" do |
257 |
| - config_override :legacy_triple_equals, true |
| 241 | + context "when the instance is the same" do |
| 242 | + |
| 243 | + it "returns true" do |
| 244 | + expect(person === person).to be true |
| 245 | + end |
| 246 | + end |
| 247 | + end |
| 248 | + |
| 249 | + context "when the comparable is a subclass" do |
| 250 | + |
| 251 | + it "returns false" do |
| 252 | + expect(person === Doctor.new).to be false |
| 253 | + end |
| 254 | + end |
258 | 255 |
|
| 256 | + context "when comparing to a class" do |
259 | 257 | context "when the class is the same" do
|
260 | 258 |
|
261 | 259 | it "returns true" do
|
|
0 commit comments