equivalent-xml 0.4.4 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MjZkNWNmMGY5ZGUzOTNkYzMwYWUxOGVmODljYzgyMTgzZjc4YzEyMw==
4
+ MDRhZTQ4ZjZiYmU5ZmIzZTU1M2U5MzU1ZjE1MzY2MjFmN2VlZjUzYg==
5
5
  data.tar.gz: !binary |-
6
- Mjk5ZjM4ZTA0N2UwNWJjNjI3ZGRlNTk2OTk0M2UyZGUxYzE5NTNiYw==
6
+ NTY1MTViYWYzYjY5NWFmNTU3YjdlYTg4MjRhNjQ2MGFhNjJjNTk5Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTYxODA2Y2ZjNDFjZWM3OGY0MTA3MmJiNzgxMTBlZWRhMTg4NzY4M2Q3YTc0
10
- NTJmMjM0YWFjNGFlOGZmZmRiNTI5NzQ3ZWMyNDM5ZjJiZjZkYjJiMjBhMTEz
11
- NmFhNGU0ZGQ1MjhlZWJjOWY4N2Q1NzhhNTIwNTAyNWFlODFjNjg=
9
+ ZjkwYjhmMjA5Yjg3ZTQyNTI1MjgwZWQ3MjNmMzE3MTM5MTIwOTc0MTlmMDMx
10
+ NmI4OTljYzA4Njk0ZTdkMDlhMDhmNjQxNTZhMTYxYzFkNWM2MGQ0NDAwNzMw
11
+ NmM2ZWY1MGUxZTQ1MjcxM2JkNjVlOWQ1MjI2ZWYwNGJjODQ5ZDc=
12
12
  data.tar.gz: !binary |-
13
- Y2EyYjA5MDQ3N2UzOTQ3MGFiMDU3ODdjNTdmYWY2ZGU3OTc4ZDNhYWEyMjYy
14
- MmQzNGU3ZDIzYzI0MTJkNGQzZjI1NGY5YzJmZjc2MjQ1YmY2YjgxYzc1OGU0
15
- MDY1YzVlMzcxYmQzMjNiM2E0MGQxOTA4ODg5NDYxYzY4MjY5MTU=
13
+ M2VkNjVlNGQ2YThmYTc4OTQzMTQwYjg2OTJmYjUzODg1YjQwNGY5YmU2YzNj
14
+ OGM0NTNiYjNhNDk1Y2QxODUyODE4Y2VlYzlmZmMxNzY2Y2I0MTczYmY4Njc3
15
+ ZTZhODA3OTk3YzdiMDhlOGZjNTZiMjljZTUzM2FmMjg3YzU4Y2U=
data/README.md CHANGED
@@ -113,6 +113,8 @@ Chained modifiers:
113
113
 
114
114
  ## History
115
115
 
116
+ - <b>0.5.1</b> - Fix false negative when comparing a Nokogiri::XML::Node to a string (introduced in 0.5.0)
117
+ - <b>0.5.0</b> - Allow to compare XML-Fragments in Strings (contrib. by webmasters)
116
118
  - <b>0.4.4</b> - Fix rspec 3 deprecation warnings while maintaining compatibility with rspec 1 & 2 (w/assist from barelyknown & DanielHeath)
117
119
  - <b>0.4.3</b> - Updates for rspec 3
118
120
  - <b>0.4.2</b> - Move version back into gemspec for now
@@ -21,6 +21,9 @@ module EquivalentXml
21
21
  if [node_1, node_2].any? { |node| node.is_a?(Nokogiri::XML::NodeSet)}
22
22
  self.compare_nodesets(as_nodeset(node_1, opts), as_nodeset(node_2, opts), opts, &block)
23
23
  else
24
+ # Don't let one node to coerced to a DocumentFragment if the other one is a Document
25
+ node_2 = Nokogiri::XML(node_2) if node_1.is_a?(Nokogiri::XML::Document) and !node_2.is_a?(Nokogiri::XML::Node)
26
+ node_1 = Nokogiri::XML(node_1) if node_2.is_a?(Nokogiri::XML::Document) and !node_1.is_a?(Nokogiri::XML::Node)
24
27
  self.compare_nodes(as_node(node_1), as_node(node_2), opts, &block)
25
28
  end
26
29
  end
@@ -156,8 +159,8 @@ module EquivalentXml
156
159
  if data.respond_to?(:node_type)
157
160
  return data
158
161
  else
159
- result = Nokogiri::XML(data)
160
- if result.root.nil?
162
+ result = Nokogiri::XML.fragment(data)
163
+ if result.respond_to?(:root) && result.root.nil?
161
164
  return data
162
165
  else
163
166
  return result
@@ -198,6 +198,13 @@ describe EquivalentXml do
198
198
 
199
199
  expect(doc1).to be_equivalent_to(doc2).ignoring_content_of("SerialNumber")
200
200
  end
201
+
202
+ it "should properly compare a document to a string" do
203
+ doc1 = '<test_document><foo/><test_xml/></test_document>'
204
+ doc2 = Nokogiri::XML doc1
205
+ expect(doc1).to be_equivalent_to(doc2)
206
+ expect(doc2).to be_equivalent_to(doc1)
207
+ end
201
208
  end
202
209
 
203
210
  context "with the :ignore_content_paths option set to an array of CSS selectors" do
@@ -216,4 +223,13 @@ describe EquivalentXml do
216
223
  expect(doc1).to be_equivalent_to(doc2).ignoring_attr_values
217
224
  end
218
225
  end
226
+
227
+ context "(on fragments consisting of multiple nodes)" do
228
+ it "should compare all nodes" do
229
+ doc1 = "<h1>Headline</h1><h1>Headline</h1>"
230
+ doc2 = "<h1>Headline</h1><h2>Headline2</h2>"
231
+ expect(doc1).not_to be_equivalent_to(doc2)
232
+ end
233
+ end
234
+
219
235
  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.4
4
+ version: 0.5.1
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-07-15 00:00:00.000000000 Z
11
+ date: 2014-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri