equivalent-xml 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MDRhZTQ4ZjZiYmU5ZmIzZTU1M2U5MzU1ZjE1MzY2MjFmN2VlZjUzYg==
5
- data.tar.gz: !binary |-
6
- NTY1MTViYWYzYjY5NWFmNTU3YjdlYTg4MjRhNjQ2MGFhNjJjNTk5Zg==
2
+ SHA1:
3
+ metadata.gz: 3051b830ff4fe1eb413f68dca2c295f14822ab3b
4
+ data.tar.gz: 94e34667fb9b78fde7ae85927a88c66779135627
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZjkwYjhmMjA5Yjg3ZTQyNTI1MjgwZWQ3MjNmMzE3MTM5MTIwOTc0MTlmMDMx
10
- NmI4OTljYzA4Njk0ZTdkMDlhMDhmNjQxNTZhMTYxYzFkNWM2MGQ0NDAwNzMw
11
- NmM2ZWY1MGUxZTQ1MjcxM2JkNjVlOWQ1MjI2ZWYwNGJjODQ5ZDc=
12
- data.tar.gz: !binary |-
13
- M2VkNjVlNGQ2YThmYTc4OTQzMTQwYjg2OTJmYjUzODg1YjQwNGY5YmU2YzNj
14
- OGM0NTNiYjNhNDk1Y2QxODUyODE4Y2VlYzlmZmMxNzY2Y2I0MTczYmY4Njc3
15
- ZTZhODA3OTk3YzdiMDhlOGZjNTZiMjljZTUzM2FmMjg3YzU4Y2U=
6
+ metadata.gz: 4bfb2eb644e98bdab94a12000885267c85e71d3803fc87f0a33701bd9b4870bd3d59a9288024790298dfbb1c2b4a4c177642a8fe685a46f4b1e31077cd46375d
7
+ data.tar.gz: b58b66a52065a725671c2b61876708996f55f9871b69cfb3299700a7695ee59827ec33321bad1da0064cfb399edd7cceebfedc6d67aa6e2aecb7e06425c8e27b
data/README.md CHANGED
@@ -113,6 +113,7 @@ Chained modifiers:
113
113
 
114
114
  ## History
115
115
 
116
+ - <b>0.6.0</b> - Add ability to ignore specific attributes (from paclough); remove circular dependencies (nbibler); Simplify compatibility workaround for message methods (jirutka)
116
117
  - <b>0.5.1</b> - Fix false negative when comparing a Nokogiri::XML::Node to a string (introduced in 0.5.0)
117
118
  - <b>0.5.0</b> - Allow to compare XML-Fragments in Strings (contrib. by webmasters)
118
119
  - <b>0.4.4</b> - Fix rspec 3 deprecation warnings while maintaining compatibility with rspec 1 & 2 (w/assist from barelyknown & DanielHeath)
data/Rakefile CHANGED
@@ -14,10 +14,7 @@ end
14
14
  require 'rake'
15
15
 
16
16
  require 'rspec/core/rake_task'
17
- RSpec::Core::RakeTask.new do |t|
18
- t.pattern = FileList['./spec/**/*_spec.rb']
19
- end
20
-
17
+ RSpec::Core::RakeTask.new
21
18
  task :default => :spec
22
19
 
23
20
  Rake::RDocTask.new do |rdoc|
@@ -71,7 +71,9 @@ module EquivalentXml
71
71
 
72
72
  attr_names_match = node_1.name == node_2.name
73
73
 
74
- if opts[:ignore_attr_values]
74
+ ignore_attrs = opts[ :ignore_attr_values ]
75
+
76
+ if ignore_attrs && (ignore_attrs.empty? || ignore_attrs.include?( node_1.name ))
75
77
  attr_names_match
76
78
  else
77
79
  attr_names_match && (node_1.value == node_2.value)
@@ -1,4 +1,4 @@
1
- require 'equivalent-xml'
1
+ require 'equivalent-xml' unless defined?(::EquivalentXml)
2
2
 
3
3
  begin
4
4
  require 'rspec/expectations'
@@ -46,8 +46,8 @@ module EquivalentXml::RSpecMatchers
46
46
  opts[:ignore_content] = paths
47
47
  end
48
48
 
49
- chain :ignoring_attr_values do
50
- opts[:ignore_attr_values] = true
49
+ chain :ignoring_attr_values do |*attrs|
50
+ opts[:ignore_attr_values] = attrs
51
51
  end
52
52
 
53
53
  should_message = lambda do |actual|
@@ -59,12 +59,14 @@ module EquivalentXml::RSpecMatchers
59
59
  end
60
60
 
61
61
  if respond_to?(:failure_message_when_negated)
62
- failure_message &should_message
63
- failure_message_when_negated &should_not_message
62
+ failure_message(&should_message)
63
+ failure_message_when_negated(&should_not_message)
64
64
  else
65
- failure_message_for_should &should_message
66
- failure_message_for_should_not &should_not_message
65
+ failure_message_for_should(&should_message)
66
+ failure_message_for_should_not(&should_not_message)
67
67
  end
68
+
69
+ diffable
68
70
  end
69
71
 
70
72
  end
@@ -224,6 +224,26 @@ describe EquivalentXml do
224
224
  end
225
225
  end
226
226
 
227
+ context 'with :ignore_attr_values receiving specific attribute names' do
228
+ it 'ignores the value of one specified attribute, but fails if other attributes are different, when comparing for equivalence' do
229
+ doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first order='1' status='on'>foo bar baz</first><second>things</second></doc>")
230
+ doc2 = Nokogiri::XML("<doc xmlns='foo:bar'><first order='2' status='off'>foo bar baz</first><second>things</second></doc>")
231
+ expect(doc1).not_to be_equivalent_to(doc2).ignoring_attr_values( 'order' )
232
+ end
233
+
234
+ it 'ignores the value of one specified attribute, but succeeds if other attributes match, when comparing for equivalence' do
235
+ doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first order='1' status='on'>foo bar baz</first><second>things</second></doc>")
236
+ doc2 = Nokogiri::XML("<doc xmlns='foo:bar'><first order='2' status='on'>foo bar baz</first><second>things</second></doc>")
237
+ expect(doc1).to be_equivalent_to(doc2).ignoring_attr_values( 'order' )
238
+ end
239
+
240
+ it 'ignores the values of multiple specified attributes when comparing for equivalence' do
241
+ doc1 = Nokogiri::XML("<doc xmlns='foo:bar'><first order='1' status='on' changed='no'>foo bar baz</first><second>things</second></doc>")
242
+ doc2 = Nokogiri::XML("<doc xmlns='foo:bar'><first order='2' status='off' changed='no'>foo bar baz</first><second>things</second></doc>")
243
+ expect(doc1).to be_equivalent_to(doc2).ignoring_attr_values( 'order', 'status' )
244
+ end
245
+ end
246
+
227
247
  context "(on fragments consisting of multiple nodes)" do
228
248
  it "should compare all nodes" do
229
249
  doc1 = "<h1>Headline</h1><h1>Headline</h1>"
metadata CHANGED
@@ -1,100 +1,100 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: equivalent-xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
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-16 00:00:00.000000000 Z
11
+ date: 2015-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.4.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.4.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.0.0
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.0.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: simplecov
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.2.4
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.2.4
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.9.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.9.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rdoc
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '3.12'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.12'
97
- description: ! "Compares two XML Nodes (Documents, etc.) for certain semantic equivalencies.
97
+ description: "Compares two XML Nodes (Documents, etc.) for certain semantic equivalencies.
98
98
  \n Currently written for Nokogiri, but with an eye toward supporting multiple
99
99
  XML libraries"
100
100
  email: mbklein@gmail.com
@@ -121,12 +121,12 @@ require_paths:
121
121
  - lib
122
122
  required_ruby_version: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - ! '>='
124
+ - - ">="
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ! '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  requirements: []