summaryrefslogtreecommitdiff
path: root/dev-ruby/nokogiri-diff/files/nokogiri-diff-0.2.0-rspec3.patch
blob: c47bda03ec1185cc9e947c7018938ddce1d11bbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
From 4683f35469dbb69fa291ea35be4e7a74090a8b24 Mon Sep 17 00:00:00 2001
From: Balasankar C <balasankarc@autistici.org>
Date: Sat, 28 Nov 2015 17:55:09 +0530
Subject: [PATCH] Port tests to RSpec 3

---
 Rakefile            |   2 +-
 gemspec.yml         |   2 +-
 spec/diff_spec.rb   | 226 ++++++++++++++++++++++----------------------
 spec/spec_helper.rb |   2 +-
 4 files changed, 116 insertions(+), 116 deletions(-)

diff --git a/Rakefile b/Rakefile
index 1b8a92d..7fb967c 100644
--- a/Rakefile
+++ b/Rakefile
@@ -12,7 +12,7 @@ rescue LoadError => e
 end
 
 begin
-  gem 'rspec', '~> 2.4'
+  gem 'rspec', '~> 3.0'
   require 'rspec/core/rake_task'
 
   RSpec::Core::RakeTask.new
diff --git a/gemspec.yml b/gemspec.yml
index 5ae611d..d775248 100644
--- a/gemspec.yml
+++ b/gemspec.yml
@@ -18,5 +18,5 @@ dependencies:
 
 development_dependencies:
   rubygems-tasks: ~> 0.1
-  rspec: ~> 2.4
+  rspec: ~> 3.0
   yard: ~> 0.7
diff --git a/spec/diff_spec.rb b/spec/diff_spec.rb
index 6450c49..adfaaa8 100644
--- a/spec/diff_spec.rb
+++ b/spec/diff_spec.rb
@@ -21,197 +21,197 @@
   let(:removed_attr)    { Nokogiri::XML('<div><p>one</p></div>') }
 
   it "should add #diff to Nokogiri::XML::Docuemnt" do
-    doc.should respond_to(:diff)
+    expect(doc).to respond_to(:diff)
   end
 
   it "should add #diff to Nokogiri::XML::Element" do
-    added_element.at('div').should respond_to(:diff)
+    expect(added_element.at('div')).to respond_to(:diff)
   end
 
   it "should add #diff to Nokogiri::XML::Text" do
-    added_text.at('p/text()').should respond_to(:diff)
+    expect(added_text.at('p/text()')).to respond_to(:diff)
   end
 
   it "should add #diff to Nokogiri::XML::Attr" do
-    added_attr.at('p/@id').should respond_to(:diff)
+    expect(added_attr.at('p/@id')).to respond_to(:diff)
   end
 
   it "should not compare the Document objects" do
     change = doc.diff(doc).first
 
-    change[0].should == ' '
-    change[1].should == doc.root
+    expect(change[0]).to eq(' ')
+    expect(change[1]).to eq(doc.root)
   end
 
   it "should determine when two different documents are identical" do
-    doc.diff(Nokogiri::XML(contents)).all? { |change,node|
+    expect(doc.diff(Nokogiri::XML(contents)).all? { |change,node|
       change == ' '
-    }.should == true
+    }).to eq(true)
   end
 
   it "should search down within Nokogiri::XML::Document objects" do
-    doc.diff(changed_text).any? { |change,node|
+    expect(doc.diff(changed_text).any? { |change,node|
       change != ' '
-    }.should == true
+    }).to eq(true)
   end
 
   it "should determine when text nodes are added" do
     changes = doc.at('div').diff(added_text.at('div')).to_a
 
-    changes.length.should == 4
+    expect(changes.length).to eq(4)
 
-    changes[0][0].should == ' '
-    changes[0][1].should == doc.at('div')
+    expect(changes[0][0]).to eq(' ')
+    expect(changes[0][1]).to eq(doc.at('div'))
 
-    changes[1][0].should == ' '
-    changes[1][1].should == doc.at('//p')
+    expect(changes[1][0]).to eq(' ')
+    expect(changes[1][1]).to eq(doc.at('//p'))
 
-    changes[2][0].should == '+'
-    changes[2][1].should == added_text.at('//div/text()')
+    expect(changes[2][0]).to eq('+')
+    expect(changes[2][1]).to eq(added_text.at('//div/text()'))
 
-    changes[3][0].should == ' '
-    changes[3][1].should == doc.at('//p/text()')
+    expect(changes[3][0]).to eq(' ')
+    expect(changes[3][1]).to eq(doc.at('//p/text()'))
   end
 
   it "should determine when elements are added" do
     changes = doc.at('div').diff(added_element.at('div')).to_a
 
-    changes.length.should == 5
+    expect(changes.length).to eq(5)
 
-    changes[0][0].should == ' '
-    changes[0][1].should == doc.at('div')
+    expect(changes[0][0]).to eq(' ')
+    expect(changes[0][1]).to eq(doc.at('div'))
 
-    changes[1][0].should == '+'
-    changes[1][1].should == added_element.at('//p[1]')
+    expect(changes[1][0]).to eq('+')
+    expect(changes[1][1]).to eq(added_element.at('//p[1]'))
 
-    changes[2][0].should == ' '
-    changes[2][1].should == doc.at('//p')
+    expect(changes[2][0]).to eq(' ')
+    expect(changes[2][1]).to eq(doc.at('//p'))
 
-    changes[3][0].should == '-'
-    changes[3][1].should == doc.at('//p/text()')
+    expect(changes[3][0]).to eq('-')
+    expect(changes[3][1]).to eq(doc.at('//p/text()'))
 
-    changes[4][0].should == '+'
-    changes[4][1].should == added_element.at('//p[2]/text()')
+    expect(changes[4][0]).to eq('+')
+    expect(changes[4][1]).to eq(added_element.at('//p[2]/text()'))
   end
 
   it "should ignore when attribute order changes" do
     changes = added_attrs.at('p').diff(changed_attr_order.at('p')).to_a
 
-    changes.all? { |change| change[0] == ' ' }.should be_true
+    expect(changes.all? { |change| change[0] == ' ' }).to be_truthy
   end
 
   it "should determine when attributes are added" do
     changes = doc.at('p').diff(added_attr.at('p')).to_a
 
-    changes.length.should == 3
+    expect(changes.length).to eq(3)
 
-    changes[0][0].should == ' '
-    changes[0][1].should == doc.at('p')
+    expect(changes[0][0]).to eq(' ')
+    expect(changes[0][1]).to eq(doc.at('p'))
 
-    changes[1][0].should == '+'
-    changes[1][1].should == added_attr.at('//p/@id')
+    expect(changes[1][0]).to eq('+')
+    expect(changes[1][1]).to eq(added_attr.at('//p/@id'))
 
-    changes[2][0].should == ' '
-    changes[2][1].should == doc.at('//p/text()')
+    expect(changes[2][0]).to eq(' ')
+    expect(changes[2][1]).to eq(doc.at('//p/text()'))
   end
 
   it "should determine when text nodes differ" do
     changes = doc.at('p').diff(changed_text.at('p')).to_a
 
-    changes.length.should == 3
+    expect(changes.length).to eq(3)
 
-    changes[0][0].should == ' '
-    changes[0][1].should == doc.at('p')
+    expect(changes[0][0]).to eq(' ')
+    expect(changes[0][1]).to eq(doc.at('p'))
 
-    changes[1][0].should == '-'
-    changes[1][1].should == doc.at('//p/text()')
+    expect(changes[1][0]).to eq('-')
+    expect(changes[1][1]).to eq(doc.at('//p/text()'))
 
-    changes[2][0].should == '+'
-    changes[2][1].should == changed_text.at('//p/text()')
+    expect(changes[2][0]).to eq('+')
+    expect(changes[2][1]).to eq(changed_text.at('//p/text()'))
   end
 
   it "should determine when element names differ" do
     changes = doc.at('div').diff(changed_element.at('div')).to_a
 
-    changes.length.should == 3
+    expect(changes.length).to eq(3)
 
-    changes[0][0].should == ' '
-    changes[0][1].should == doc.at('div')
+    expect(changes[0][0]).to eq(' ')
+    expect(changes[0][1]).to eq(doc.at('div'))
 
-    changes[1][0].should == '-'
-    changes[1][1].should == doc.at('p')
+    expect(changes[1][0]).to eq('-')
+    expect(changes[1][1]).to eq(doc.at('p'))
 
-    changes[2][0].should == '+'
-    changes[2][1].should == changed_element.at('span')
+    expect(changes[2][0]).to eq('+')
+    expect(changes[2][1]).to eq(changed_element.at('span'))
   end
 
   it "should determine when attribute names differ" do
     changes = added_attr.at('p').diff(changed_attr_name.at('p')).to_a
 
-    changes.length.should == 4
+    expect(changes.length).to eq(4)
 
-    changes[0][0].should == ' '
-    changes[0][1].should == added_attr.at('p')
+    expect(changes[0][0]).to eq(' ')
+    expect(changes[0][1]).to eq(added_attr.at('p'))
 
-    changes[1][0].should == '-'
-    changes[1][1].should == added_attr.at('//p/@id')
+    expect(changes[1][0]).to eq('-')
+    expect(changes[1][1]).to eq(added_attr.at('//p/@id'))
 
-    changes[2][0].should == '+'
-    changes[2][1].should == changed_attr_name.at('//p/@i')
+    expect(changes[2][0]).to eq('+')
+    expect(changes[2][1]).to eq(changed_attr_name.at('//p/@i'))
 
-    changes[3][0].should == ' '
-    changes[3][1].should == added_attr.at('//p/text()')
+    expect(changes[3][0]).to eq(' ')
+    expect(changes[3][1]).to eq(added_attr.at('//p/text()'))
   end
 
   it "should determine when attribute values differ" do
     changes = added_attr.at('p').diff(changed_attr_value.at('p')).to_a
 
-    changes.length.should == 4
+    expect(changes.length).to eq(4)
 
-    changes[0][0].should == ' '
-    changes[0][1].should == added_attr.at('p')
+    expect(changes[0][0]).to eq(' ')
+    expect(changes[0][1]).to eq(added_attr.at('p'))
 
-    changes[1][0].should == '-'
-    changes[1][1].should == added_attr.at('//p/@id')
+    expect(changes[1][0]).to eq('-')
+    expect(changes[1][1]).to eq(added_attr.at('//p/@id'))
 
-    changes[2][0].should == '+'
-    changes[2][1].should == changed_attr_value.at('//p/@id')
+    expect(changes[2][0]).to eq('+')
+    expect(changes[2][1]).to eq(changed_attr_value.at('//p/@id'))
 
-    changes[3][0].should == ' '
-    changes[3][1].should == added_attr.at('//p/text()')
+    expect(changes[3][0]).to eq(' ')
+    expect(changes[3][1]).to eq(added_attr.at('//p/text()'))
   end
 
   it "should determine when text nodes are removed" do
     changes = added_text.at('div').diff(removed_text.at('div')).to_a
 
-    changes.length.should == 4
+    expect(changes.length).to eq(4)
 
-    changes[0][0].should == ' '
-    changes[0][1].should == added_text.at('div')
+    expect(changes[0][0]).to eq(' ')
+    expect(changes[0][1]).to eq(added_text.at('div'))
 
-    changes[1][0].should == ' '
-    changes[1][1].should == added_text.at('p')
+    expect(changes[1][0]).to eq(' ')
+    expect(changes[1][1]).to eq(added_text.at('p'))
 
-    changes[2][0].should == ' '
-    changes[2][1].should == added_text.at('//div/text()')
+    expect(changes[2][0]).to eq(' ')
+    expect(changes[2][1]).to eq(added_text.at('//div/text()'))
 
-    changes[3][0].should == '-'
-    changes[3][1].should == added_text.at('//p/text()')
+    expect(changes[3][0]).to eq('-')
+    expect(changes[3][1]).to eq(added_text.at('//p/text()'))
   end
 
   it "should determine when elements are removed" do
     changes = added_element.at('div').diff(removed_element.at('div')).to_a
 
-    changes.length.should == 3
+    expect(changes.length).to eq(3)
 
-    changes[0][0].should == ' '
-    changes[0][1].should == added_element.at('div')
+    expect(changes[0][0]).to eq(' ')
+    expect(changes[0][1]).to eq(added_element.at('div'))
 
-    changes[1][0].should == '-'
-    changes[1][1].should == added_element.at('//p[1]')
+    expect(changes[1][0]).to eq('-')
+    expect(changes[1][1]).to eq(added_element.at('//p[1]'))
 
-    changes[2][0].should == '-'
-    changes[2][1].should == added_element.at('//p[2]')
+    expect(changes[2][0]).to eq('-')
+    expect(changes[2][1]).to eq(added_element.at('//p[2]'))
   end
 
   it "should ignore when attributes change order" do
@@ -220,47 +220,47 @@
   it "should determine when attributes are removed" do
     changes = added_attr.at('div').diff(removed_attr.at('div')).to_a
 
-    changes.length.should == 4
+    expect(changes.length).to eq(4)
 
-    changes[0][0].should == ' '
-    changes[0][1].should == added_attr.at('div')
+    expect(changes[0][0]).to eq(' ')
+    expect(changes[0][1]).to eq(added_attr.at('div'))
 
-    changes[1][0].should == ' '
-    changes[1][1].should == added_attr.at('p')
+    expect(changes[1][0]).to eq(' ')
+    expect(changes[1][1]).to eq(added_attr.at('p'))
 
-    changes[2][0].should == '-'
-    changes[2][1].should == added_attr.at('//p/@id')
+    expect(changes[2][0]).to eq('-')
+    expect(changes[2][1]).to eq(added_attr.at('//p/@id'))
 
-    changes[3][0].should == ' '
-    changes[3][1].should == added_attr.at('//p/text()')
+    expect(changes[3][0]).to eq(' ')
+    expect(changes[3][1]).to eq(added_attr.at('//p/text()'))
   end
 
   context ":added" do
     it "should determine only when text nodes are added" do
       changes = doc.at('div').diff(added_text.at('div'), :added => true).to_a
 
-      changes.length.should == 1
+      expect(changes.length).to eq(1)
 
-      changes[0][0].should == '+'
-      changes[0][1].should == added_text.at('//div/text()')
+      expect(changes[0][0]).to eq('+')
+      expect(changes[0][1]).to eq(added_text.at('//div/text()'))
     end
 
     it "should determine only when elements are added" do
       changes = doc.at('div').diff(added_element.at('div'), :added => true).to_a
 
-      changes.length.should == 1
+      expect(changes.length).to eq(1)
 
-      changes[0][0].should == '+'
-      changes[0][1].should == added_element.at('//div/p[2]')
+      expect(changes[0][0]).to eq('+')
+      expect(changes[0][1]).to eq(added_element.at('//div/p[2]'))
     end
 
     it "should determine only when attributes are added" do
       changes = doc.at('div').diff(added_attr.at('div'), :added => true).to_a
 
-      changes.length.should == 1
+      expect(changes.length).to eq(1)
 
-      changes[0][0].should == '+'
-      changes[0][1].should == added_attr.at('//p/@id')
+      expect(changes[0][0]).to eq('+')
+      expect(changes[0][1]).to eq(added_attr.at('//p/@id'))
     end
   end
 
@@ -268,28 +268,28 @@
     it "should determine only when text nodes are removed" do
       changes = doc.at('div').diff(removed_text.at('div'), :removed => true).to_a
 
-      changes.length.should == 1
+      expect(changes.length).to eq(1)
 
-      changes[0][0].should == '-'
-      changes[0][1].should == doc.at('//p/text()')
+      expect(changes[0][0]).to eq('-')
+      expect(changes[0][1]).to eq(doc.at('//p/text()'))
     end
 
     it "should determine only when elements are removed" do
       changes = doc.at('div').diff(removed_element.at('div'), :removed => true).to_a
 
-      changes.length.should == 1
+      expect(changes.length).to eq(1)
 
-      changes[0][0].should == '-'
-      changes[0][1].should == doc.at('//div/p')
+      expect(changes[0][0]).to eq('-')
+      expect(changes[0][1]).to eq(doc.at('//div/p'))
     end
 
     it "should determine only when attributes are removed" do
       changes = added_attr.at('div').diff(removed_attr.at('div'), :removed => true).to_a
 
-      changes.length.should == 1
+      expect(changes.length).to eq(1)
 
-      changes[0][0].should == '-'
-      changes[0][1].should == added_attr.at('//p/@id')
+      expect(changes[0][0]).to eq('-')
+      expect(changes[0][1]).to eq(added_attr.at('//p/@id'))
     end
   end
 end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 4b9ecea..5f26cbb 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,2 +1,2 @@
-gem 'rspec', '~> 2.4'
+gem 'rspec', '~> 3.0'
 require 'rspec'