equivalent-xml 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -88,6 +88,5 @@ Chained modifiers:
88
88
 
89
89
  == Copyright
90
90
 
91
- Copyright (c) 2011 Michael B. Klein. See LICENSE.txt for
92
- further details.
91
+ Copyright (c) 2011 Michael B. Klein. See LICENSE.txt for further details.
93
92
 
@@ -1,48 +1,58 @@
1
1
  require 'equivalent-xml'
2
2
 
3
- class RSpecNotFound < Exception ; end
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
- rspec_namespace.define :be_equivalent_to do |expected, opts|
14
- @opts = opts || {}
15
-
16
- match do |actual|
17
- @expected = expected
18
- @actual = actual
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
- chain :respecting_element_order do
23
- @opts[:element_order] = true
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
- chain :with_whitespace_intact do
27
- @opts[:normalize_whitespace] = false
28
- end
31
+ chain :respecting_element_order do
32
+ @opts[:element_order] = true
33
+ end
29
34
 
30
- failure_message_for_should do
31
- <<-MESSAGE
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
- #{@expected.to_s}
42
+ #{expected.to_s}
34
43
  got:
35
- #{@actual.to_s}
44
+ #{actual.to_s}
36
45
  MESSAGE
37
- end
46
+ end
38
47
 
39
- failure_message_for_should_not do
40
- <<-MESSAGE
48
+ failure_message_for_should_not do |actual|
49
+ <<-MESSAGE
41
50
  expected:
42
- #{@actual.to_s}
51
+ #{actual.to_s}
43
52
  not to be equivalent to:
44
- #{@expected.to_s}
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: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 5
10
- version: 0.2.5
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-23 00:00:00 -07:00
18
+ date: 2011-03-24 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency