equivalent-xml 0.2.5 → 0.2.6
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.
- data/README.rdoc +1 -2
- data/lib/equivalent-xml/rspec_matchers.rb +42 -32
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -1,48 +1,58 @@
|
|
1
1
|
require 'equivalent-xml'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
if defined?(RSpec)
|
6
|
-
rspec_namespace = RSpec::Matchers
|
7
|
-
elsif defined?(Spec)
|
8
|
-
rspec_namespace = Spec::Matchers
|
9
|
-
else
|
10
|
-
raise RSpecNotFound, "Cannot find Spec (rspec 1.x) or RSpec (rspec 2.x)"
|
11
|
-
end
|
3
|
+
module EquivalentXml::RSpecMatchers
|
12
4
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
EquivalentXml.equivalent?(@actual,@expected,@opts)
|
5
|
+
if defined?(::RSpec)
|
6
|
+
rspec_namespace = ::RSpec::Matchers
|
7
|
+
elsif defined?(::Spec)
|
8
|
+
rspec_namespace = ::Spec::Matchers
|
9
|
+
else
|
10
|
+
raise NameError, "Cannot find Spec (rspec 1.x) or RSpec (rspec 2.x)"
|
20
11
|
end
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
|
13
|
+
# Determine if the receiver is equivalent to the argument as defined
|
14
|
+
# in {file:README.rdoc README.rdoc} and {EquivalentXml.equivalent? EquivalentXml.equivalent?}.
|
15
|
+
# node.should be_equivalent_to(other_node)
|
16
|
+
# node.should_not be_equivalent_to(other_node)
|
17
|
+
# node.should be_equivalent_to(other_node).respecting_element_order
|
18
|
+
# node.should be_equivalent_to(other_node).with_whitespace_intact
|
19
|
+
# node.should be_equivalent_to(other_node).respecting_element_order.with_whitespace_intact
|
20
|
+
def be_equivalent_to(expected)
|
21
|
+
# Placeholder method for documentation purposes; the actual
|
22
|
+
# method is defined using RSpec's matcher DSL.
|
24
23
|
end
|
24
|
+
|
25
|
+
rspec_namespace.define :be_equivalent_to do |expected|
|
26
|
+
@opts = {}
|
27
|
+
match do |actual|
|
28
|
+
EquivalentXml.equivalent?(actual,expected,@opts)
|
29
|
+
end
|
25
30
|
|
26
|
-
|
27
|
-
|
28
|
-
|
31
|
+
chain :respecting_element_order do
|
32
|
+
@opts[:element_order] = true
|
33
|
+
end
|
29
34
|
|
30
|
-
|
31
|
-
|
35
|
+
chain :with_whitespace_intact do
|
36
|
+
@opts[:normalize_whitespace] = false
|
37
|
+
end
|
38
|
+
|
39
|
+
failure_message_for_should do |actual|
|
40
|
+
<<-MESSAGE
|
32
41
|
expected:
|
33
|
-
#{
|
42
|
+
#{expected.to_s}
|
34
43
|
got:
|
35
|
-
#{
|
44
|
+
#{actual.to_s}
|
36
45
|
MESSAGE
|
37
|
-
|
46
|
+
end
|
38
47
|
|
39
|
-
|
40
|
-
|
48
|
+
failure_message_for_should_not do |actual|
|
49
|
+
<<-MESSAGE
|
41
50
|
expected:
|
42
|
-
#{
|
51
|
+
#{actual.to_s}
|
43
52
|
not to be equivalent to:
|
44
|
-
#{
|
53
|
+
#{expected.to_s}
|
45
54
|
MESSAGE
|
55
|
+
end
|
46
56
|
end
|
47
57
|
|
48
|
-
end
|
58
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: equivalent-xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 6
|
10
|
+
version: 0.2.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael B. Klein
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-24 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|