equivalent-xml 0.4.2 → 0.4.3

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWQxNTcyMmQxZDQ3ZTNmNTg4ZmVhMmYyMzhlYzc0MzI0ZjgxNTkyYw==
4
+ N2UyN2Q1OTkwM2EwOGVmYjc3OTk1ZDI3NDVjMGIwNzAzMDY4MTViNg==
5
5
  data.tar.gz: !binary |-
6
- NGViYmU3NTJhNmExMTMxODlkMjQwNTQzZDVhZjE5ZTQ1MTVhMjk0OA==
6
+ ODlkOGEwZTZjNjg1NzE5ODI2YmFmMjUyMDM0YzFjMzAyYWUxZGEwMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- N2YyYWNkZDkxNDI1NWJhNjM0MDYwYmI3MjFhMTE0M2JiNjhjODIxOGMwNGRm
10
- ZDkzMDRjZTI5YTAxY2ZhY2RiODgyYTEyMjY4Nzk5MzgyNWUxMGYzYTFlNWE0
11
- YzJmMTY5ZTE2ZDM2NTIxNWYwYmNhMzY0MTFiZDNmNTUxZTNmYzU=
9
+ NzUyYmEzNjVjYzhjZGE0YTFmMDg4YTlhMGRkNGEzYThhYmYzZTA5MTNlOGRi
10
+ ODk3ZGQ4ZmJlOTljMDlhY2Y2ZWE4NWUwMDJhNzk4NWEyOWE4ZDI0NjY4MzQy
11
+ NGY2YjllNmMxOWNkMWE5NmJlNjAwMTIxNzY0ZDkwMjdkOTA2NmE=
12
12
  data.tar.gz: !binary |-
13
- ZTIxMzkwMWIzZWQ2MGQxYTI3YmM2OTY0M2FkNDcxNjMyNDEzNmJkYTBkNTk4
14
- NWNlOGM2ZGVhNjU0YmRiMGUyZjdlOTY4N2Y5M2IyZWI0ZWM3N2I5OWQ1MmVk
15
- YzNiYjE1Y2YwMzJlMGJiNDBhYjg2ZGMxMzI0YTkxZmRkZjViMTk=
13
+ OGIyMWRlZTVhYmFmZGE5MTE4MzQ5MjkxNmJjNjNkZDVlNTljM2MxNmZhNmQ4
14
+ MjYyZDQ4Y2ZiMzA3ODg0Zjg4ODA0NTY0M2MyMmNjZTgzNWQ1Nzk2ZDIyMmNl
15
+ NzYxNGNjMzBhNzc4MDk0MmY0NTIxYTY0NmQ0YzBmM2U1ZmViOGE=
data/README.md CHANGED
@@ -106,6 +106,7 @@ Chained modifiers:
106
106
 
107
107
  ## History
108
108
 
109
+ - <b>0.4.3</b> - Updates for rspec 3
109
110
  - <b>0.4.2</b> - Move version back into gemspec for now
110
111
  - <b>0.4.1</b> - Improved RSpec version checking (contrib. by elandesign)
111
112
  - <b>0.4.0</b> - Added :ignore_attr_values option (contrib. by ivannovosad)
@@ -1,7 +1,7 @@
1
1
  require 'equivalent-xml'
2
2
 
3
3
  begin
4
- require 'rspec-expectations'
4
+ require 'rspec/expectations'
5
5
  rescue LoadError
6
6
  end
7
7
 
@@ -16,7 +16,7 @@ module EquivalentXml::RSpecMatchers
16
16
  end
17
17
 
18
18
  # Determine if the receiver is equivalent to the argument as defined
19
- # in {file:README.rdoc README.rdoc} and {EquivalentXml.equivalent? EquivalentXml.equivalent?}.
19
+ # in {file:README.rdoc README.rdoc} and {EquivalentXml.equivalent? EquivalentXml.equivalent?}.
20
20
  # node.should be_equivalent_to(other_node)
21
21
  # node.should_not be_equivalent_to(other_node)
22
22
  # node.should be_equivalent_to(other_node).respecting_element_order
@@ -29,31 +29,31 @@ module EquivalentXml::RSpecMatchers
29
29
  end
30
30
 
31
31
  rspec_namespace.define :be_equivalent_to do |expected|
32
- @opts = {}
32
+ opts = {}
33
33
  match do |actual|
34
- EquivalentXml.equivalent?(actual,expected,@opts)
34
+ EquivalentXml.equivalent?(actual,expected,opts)
35
35
  end
36
-
36
+
37
37
  chain :respecting_element_order do
38
- @opts[:element_order] = true
38
+ opts[:element_order] = true
39
39
  end
40
-
40
+
41
41
  chain :with_whitespace_intact do
42
- @opts[:normalize_whitespace] = false
42
+ opts[:normalize_whitespace] = false
43
43
  end
44
44
 
45
45
  chain :ignoring_content_of do |paths|
46
- @opts[:ignore_content] = paths
46
+ opts[:ignore_content] = paths
47
47
  end
48
48
 
49
49
  chain :ignoring_attr_values do
50
- @opts[:ignore_attr_values] = true
50
+ opts[:ignore_attr_values] = true
51
51
  end
52
-
52
+
53
53
  failure_message_for_should do |actual|
54
54
  [ 'expected:', expected.to_s, 'got:', actual.to_s ].join("\n")
55
55
  end
56
-
56
+
57
57
  failure_message_for_should_not do |actual|
58
58
  [ 'expected:', actual.to_s, 'not to be equivalent to:', expected.to_s ].join("\n")
59
59
  end
@@ -11,81 +11,81 @@ describe EquivalentXml do
11
11
 
12
12
  it "should consider a document equivalent to itself" do
13
13
  doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first>foo bar baz</first><second>things</second></doc>")
14
- doc1.should be_equivalent_to(doc1)
14
+ expect(doc1).to be_equivalent_to(doc1)
15
15
  end
16
-
16
+
17
17
  it "should compare non-XML content based on its string representation" do
18
- nil.should be_equivalent_to(nil)
19
- ''.should be_equivalent_to('')
20
- ''.should be_equivalent_to(nil)
21
- 'foo'.should be_equivalent_to('foo')
22
- 'foo'.should_not be_equivalent_to('bar')
18
+ expect(nil).to be_equivalent_to(nil)
19
+ expect('').to be_equivalent_to('')
20
+ expect('').to be_equivalent_to(nil)
21
+ expect('foo').to be_equivalent_to('foo')
22
+ expect('foo').not_to be_equivalent_to('bar')
23
23
  doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first order='1'>foo bar baz</first><second>things</second></doc>")
24
- doc1.should_not be_equivalent_to(nil)
24
+ expect(doc1).not_to be_equivalent_to(nil)
25
25
  end
26
26
 
27
27
  it "should ensure that attributes match" do
28
28
  doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first order='1'>foo bar baz</first><second>things</second></doc>")
29
29
  doc2 = Nokogiri::XML("<doc xmlns='foo:bar'><first order='2'>foo bar baz</first><second>things</second></doc>")
30
- doc1.should_not be_equivalent_to(doc2)
30
+ expect(doc1).not_to be_equivalent_to(doc2)
31
31
 
32
32
  doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first order='1'>foo bar baz</first><second>things</second></doc>")
33
33
  doc2 = Nokogiri::XML("<doc xmlns='foo:bar'><first order='1'>foo bar baz</first><second>things</second></doc>")
34
- doc1.should be_equivalent_to(doc2)
34
+ expect(doc1).to be_equivalent_to(doc2)
35
35
  end
36
-
36
+
37
37
  it "shouldn't care about attribute order" do
38
38
  doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first order='1' value='quux'>foo bar baz</first><second>things</second></doc>")
39
39
  doc2 = Nokogiri::XML("<doc xmlns='foo:bar'><first value='quux' order='1'>foo bar baz</first><second>things</second></doc>")
40
- doc1.should be_equivalent_to(doc2)
40
+ expect(doc1).to be_equivalent_to(doc2)
41
41
  end
42
-
42
+
43
43
  it "shouldn't care about element order by default" do
44
44
  doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first>foo bar baz</first><second>things</second></doc>")
45
45
  doc2 = Nokogiri::XML("<doc xmlns='foo:bar'><second>things</second><first>foo bar baz</first></doc>")
46
- doc1.should be_equivalent_to(doc2)
46
+ expect(doc1).to be_equivalent_to(doc2)
47
47
  end
48
-
48
+
49
49
  it "should care about element order if :element_order => true is specified" do
50
50
  doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first>foo bar baz</first><second>things</second></doc>")
51
51
  doc2 = Nokogiri::XML("<doc xmlns='foo:bar'><second>things</second><first>foo bar baz</first></doc>")
52
- doc1.should_not be_equivalent_to(doc2).respecting_element_order
52
+ expect(doc1).not_to be_equivalent_to(doc2).respecting_element_order
53
53
  end
54
-
54
+
55
55
  it "should ensure nodesets have the same number of elements" do
56
56
  doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first>foo bar baz</first><second>things</second></doc>")
57
57
  doc2 = Nokogiri::XML("<doc xmlns='foo:bar'><second>things</second><first>foo bar baz</first><third/></doc>")
58
- doc1.should_not be_equivalent_to(doc2)
58
+ expect(doc1).not_to be_equivalent_to(doc2)
59
59
  end
60
60
 
61
61
  it "should ensure namespaces match" do
62
62
  doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first>foo bar baz</first><second>things</second></doc>")
63
63
  doc2 = Nokogiri::XML("<doc xmlns='foo:baz'><first>foo bar baz</first><second>things</second></doc>")
64
- doc1.should_not be_equivalent_to(doc2)
64
+ expect(doc1).not_to be_equivalent_to(doc2)
65
65
  end
66
66
 
67
67
  it "should compare namespaces based on URI, not on prefix" do
68
68
  doc1 = Nokogiri::XML("<doc xmlns:foo='foo:bar'><foo:first>foo bar baz</foo:first><foo:second>things</foo:second></doc>")
69
69
  doc2 = Nokogiri::XML("<doc xmlns:baz='foo:bar'><baz:first>foo bar baz</baz:first><baz:second>things</baz:second></doc>")
70
- doc1.should be_equivalent_to(doc2)
70
+ expect(doc1).to be_equivalent_to(doc2)
71
71
  end
72
72
 
73
73
  it "should ignore declared but unused namespaces" do
74
74
  doc1 = Nokogiri::XML("<doc xmlns:foo='foo:bar'><first>foo bar baz</first><second>things</second></doc>")
75
75
  doc2 = Nokogiri::XML("<doc><first>foo bar baz</first><second>things</second></doc>")
76
- doc1.should be_equivalent_to(doc2)
76
+ expect(doc1).to be_equivalent_to(doc2)
77
77
  end
78
78
 
79
79
  it "should normalize simple whitespace by default" do
80
80
  doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first>foo bar baz</first><second>things</second></doc>")
81
81
  doc2 = Nokogiri::XML("<doc xmlns='foo:bar'><first>foo bar baz</first><second>things</second></doc>")
82
- doc1.should be_equivalent_to(doc2)
82
+ expect(doc1).to be_equivalent_to(doc2)
83
83
  end
84
84
 
85
85
  it "shouldn't normalize simple whitespace if :normalize_whitespace => false is specified" do
86
86
  doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first>foo bar baz</first><second>things</second></doc>")
87
87
  doc2 = Nokogiri::XML("<doc xmlns='foo:bar'><first>foo bar baz</first><second>things</second></doc>")
88
- doc1.should_not be_equivalent_to(doc2).with_whitespace_intact
88
+ expect(doc1).not_to be_equivalent_to(doc2).with_whitespace_intact
89
89
  end
90
90
 
91
91
  it "should normalize complex whitespace by default" do
@@ -97,9 +97,9 @@ describe EquivalentXml do
97
97
  bar baz
98
98
  </first>
99
99
  </doc>})
100
- doc1.should be_equivalent_to(doc2)
100
+ expect(doc1).to be_equivalent_to(doc2)
101
101
  end
102
-
102
+
103
103
  it "shouldn't normalize complex whitespace if :normalize_whitespace => false is specified" do
104
104
  doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first>foo bar baz</first><second>things</second></doc>")
105
105
  doc2 = Nokogiri::XML(%{<doc xmlns='foo:bar'>
@@ -109,7 +109,7 @@ describe EquivalentXml do
109
109
  bar baz
110
110
  </first>
111
111
  </doc>})
112
- doc1.should_not be_equivalent_to(doc2).with_whitespace_intact
112
+ expect(doc1).not_to be_equivalent_to(doc2).with_whitespace_intact
113
113
  end
114
114
 
115
115
  it "should ignore comment nodes" do
@@ -122,33 +122,33 @@ describe EquivalentXml do
122
122
  bar baz
123
123
  </first>
124
124
  </doc>})
125
- doc1.should be_equivalent_to(doc2)
125
+ expect(doc1).to be_equivalent_to(doc2)
126
126
  end
127
-
127
+
128
128
  it "should properly handle a mixture of text and element nodes" do
129
129
  doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><phrase>This phrase <b>has bold text</b> in it.</phrase></doc>")
130
130
  doc2 = Nokogiri::XML("<doc xmlns='foo:bar'><phrase>This phrase in <b>has bold text</b> it.</phrase></doc>")
131
- doc1.should_not be_equivalent_to(doc2)
131
+ expect(doc1).not_to be_equivalent_to(doc2)
132
132
  end
133
133
 
134
134
  it "should properly handle documents passed in as strings" do
135
135
  doc1 = "<doc xmlns='foo:bar'><first order='1'>foo bar baz</first><second>things</second></doc>"
136
136
  doc2 = "<doc xmlns='foo:bar'><first order='1'>foo bar baz</first><second>things</second></doc>"
137
- doc1.should be_equivalent_to(doc2)
137
+ expect(doc1).to be_equivalent_to(doc2)
138
138
 
139
139
  doc1 = "<doc xmlns='foo:bar'><first order='1'>foo bar baz</first><second>things</second></doc>"
140
140
  doc2 = "<doc xmlns='foo:bar'><first order='1'>foo bar baz quux</first><second>things</second></doc>"
141
- doc1.should_not be_equivalent_to(doc2)
141
+ expect(doc1).not_to be_equivalent_to(doc2)
142
142
  end
143
143
 
144
144
  it "should compare nodesets" do
145
145
  doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first>foo bar baz</first><second>things</second></doc>")
146
- doc1.root.children.should be_equivalent_to(doc1.root.children)
146
+ expect(doc1.root.children).to be_equivalent_to(doc1.root.children)
147
147
  end
148
-
148
+
149
149
  it "should compare nodeset with string" do
150
150
  doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first>foo bar baz</first><second>things</second></doc>")
151
- doc1.root.children.should be_equivalent_to("<first xmlns='foo:bar'>foo bar baz</first><second xmlns='foo:bar'>things</second>")
151
+ expect(doc1.root.children).to be_equivalent_to("<first xmlns='foo:bar'>foo bar baz</first><second xmlns='foo:bar'>things</second>")
152
152
  end
153
153
 
154
154
  context "with the :ignore_content_paths option set to a CSS selector" do
@@ -156,47 +156,47 @@ describe EquivalentXml do
156
156
  doc1 = Nokogiri::XML("<Devices><Device><Name>iPhone</Name><SerialNumber>1234</SerialNumber></Device></Devices>")
157
157
  doc2 = Nokogiri::XML("<Devices><Device><Name>iPhone</Name><SerialNumber>5678</SerialNumber></Device></Devices>")
158
158
 
159
- EquivalentXml.equivalent?(doc1, doc2, :ignore_content => "SerialNumber").should be_true
160
- EquivalentXml.equivalent?(doc1, doc2, :ignore_content => "Devices>Device>SerialNumber").should be_true
159
+ expect(EquivalentXml.equivalent?(doc1, doc2, :ignore_content => "SerialNumber")).to eq(true)
160
+ expect(EquivalentXml.equivalent?(doc1, doc2, :ignore_content => "Devices>Device>SerialNumber")).to eq(true)
161
161
 
162
- doc1.should be_equivalent_to(doc2).ignoring_content_of("SerialNumber")
163
- doc1.should be_equivalent_to(doc2).ignoring_content_of("Devices>Device>SerialNumber")
162
+ expect(doc1).to be_equivalent_to(doc2).ignoring_content_of("SerialNumber")
163
+ expect(doc1).to be_equivalent_to(doc2).ignoring_content_of("Devices>Device>SerialNumber")
164
164
  end
165
165
 
166
166
  it "ignores the text content of a node that matches the given CSS selector when comparing with a matcher" do
167
167
  doc1 = Nokogiri::XML("<Devices><Device><Name>iPhone</Name><SerialNumber>1234</SerialNumber></Device></Devices>")
168
168
  doc2 = Nokogiri::XML("<Devices><Device><Name>iPhone</Name><SerialNumber>5678</SerialNumber></Device></Devices>")
169
169
 
170
- doc1.should be_equivalent_to(doc2).ignoring_content_of("SerialNumber")
171
- doc1.should be_equivalent_to(doc2).ignoring_content_of("Devices>Device>SerialNumber")
170
+ expect(doc1).to be_equivalent_to(doc2).ignoring_content_of("SerialNumber")
171
+ expect(doc1).to be_equivalent_to(doc2).ignoring_content_of("Devices>Device>SerialNumber")
172
172
  end
173
173
 
174
174
  it "ignores all children of a node that matches the given selector when comparing for equivalence" do
175
175
  doc1 = Nokogiri::XML("<Devices><Device><Name>iPhone</Name><SerialNumber>1234</SerialNumber></Device></Devices>")
176
176
  doc2 = Nokogiri::XML("<Devices><Device><Name>iPad</Name><SerialNumber>5678</SerialNumber></Device></Devices>")
177
177
 
178
- doc1.should be_equivalent_to(doc2).ignoring_content_of("Device")
178
+ expect(doc1).to be_equivalent_to(doc2).ignoring_content_of("Device")
179
179
  end
180
180
 
181
181
  it "still considers the number of elements even if they match the given CSS selector" do
182
182
  doc1 = Nokogiri::XML("<Devices><Device><Name>iPhone</Name><SerialNumber>1234</SerialNumber></Device></Devices>")
183
183
  doc2 = Nokogiri::XML("<Devices><Device><Name>iPhone</Name><SerialNumber>1234</SerialNumber></Device><Device><Name>iPad</Name><SerialNumber>5678</SerialNumber></Device></Devices>")
184
184
 
185
- doc1.should_not be_equivalent_to(doc2).ignoring_content_of("Device")
185
+ expect(doc1).not_to be_equivalent_to(doc2).ignoring_content_of("Device")
186
186
  end
187
187
 
188
188
  it "still considers attributes on the matched path when comparing for equivalence" do
189
189
  doc1 = Nokogiri::XML("<Devices><Device status='owned'><Name>iPhone</Name><SerialNumber>1234</SerialNumber></Device></Devices>")
190
190
  doc2 = Nokogiri::XML("<Devices><Device status='rented'><Name>iPhone</Name><SerialNumber>1234</SerialNumber></Device></Devices>")
191
191
 
192
- doc1.should_not be_equivalent_to(doc2).ignoring_content_of("Device")
192
+ expect(doc1).not_to be_equivalent_to(doc2).ignoring_content_of("Device")
193
193
  end
194
194
 
195
195
  it "ignores all matches of the CSS selector" do
196
196
  doc1 = Nokogiri::XML("<Devices><Device><Name>iPhone</Name><SerialNumber>1001</SerialNumber></Device><Device><Name>iPad</Name><SerialNumber>2001</SerialNumber></Device></Devices>")
197
197
  doc2 = Nokogiri::XML("<Devices><Device><Name>iPhone</Name><SerialNumber>1002</SerialNumber></Device><Device><Name>iPad</Name><SerialNumber>2002</SerialNumber></Device></Devices>")
198
198
 
199
- doc1.should be_equivalent_to(doc2).ignoring_content_of("SerialNumber")
199
+ expect(doc1).to be_equivalent_to(doc2).ignoring_content_of("SerialNumber")
200
200
  end
201
201
  end
202
202
 
@@ -205,7 +205,7 @@ describe EquivalentXml do
205
205
  doc1 = Nokogiri::XML("<Devices><Device><Name>iPhone</Name><SerialNumber>1234</SerialNumber><ICCID>AAAA</ICCID></Device></Devices>")
206
206
  doc2 = Nokogiri::XML("<Devices><Device><Name>iPhone</Name><SerialNumber>5678</SerialNumber><ICCID>BBBB</ICCID></Device></Devices>")
207
207
 
208
- doc1.should be_equivalent_to(doc2).ignoring_content_of(["SerialNumber", "ICCID"])
208
+ expect(doc1).to be_equivalent_to(doc2).ignoring_content_of(["SerialNumber", "ICCID"])
209
209
  end
210
210
  end
211
211
 
@@ -213,7 +213,7 @@ describe EquivalentXml do
213
213
  it "ignores the values of attributes when comparing for equivalence" do
214
214
  doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first order='1'>foo bar baz</first><second>things</second></doc>")
215
215
  doc2 = Nokogiri::XML("<doc xmlns='foo:bar'><first order='2'>foo bar baz</first><second>things</second></doc>")
216
- doc1.should be_equivalent_to(doc2).ignoring_attr_values
216
+ expect(doc1).to be_equivalent_to(doc2).ignoring_attr_values
217
217
  end
218
218
  end
219
219
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: equivalent-xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael B. Klein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-17 00:00:00.000000000 Z
11
+ date: 2014-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri