test_xml 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -97,10 +97,20 @@ In the features/env.rb
97
97
 
98
98
  In your steps file e.g. features/step_definitions/xml_steps.rb add this step:
99
99
 
100
- Then /^the response should match the following xml$/ do |string|
101
- response.body.should match_xml(string)
100
+ Then /^the response should match the following xml$/ do |xml|
101
+ response.body.should equal_xml(xml)
102
102
  end
103
103
 
104
104
  == REQUIREMENTS
105
105
 
106
106
  * nokogiri
107
+
108
+ == Many Thanks
109
+
110
+ {Nick Sutterer}[http://github.com/apotonick] thank you for bringing RSpec 2, Ruby 1.9.2 and MiniTest! You revived the gem! :)
111
+
112
+ == LICENSE
113
+
114
+ Copyright © 2010-2011, Pavel Gabriel
115
+
116
+ Released under the MIT License.
@@ -1,3 +1,14 @@
1
1
  require 'nokogiri'
2
2
  require 'test_xml/nokogiri/node'
3
3
  require 'test_xml/nokogiri'
4
+
5
+ module TestXml
6
+ class << self
7
+ attr_accessor :enable_placeholders
8
+
9
+ def placeholders_enabled?
10
+ !!enable_placeholders
11
+ end
12
+ end
13
+
14
+ end
@@ -24,11 +24,18 @@ module TestXml
24
24
  children.size == 0 or (children.size == 1 && children.first.text?)
25
25
  end
26
26
 
27
+ def placeholder?
28
+ TestXml.placeholders_enabled? and (content =~ /^`.*`$/)
29
+ end
30
+
27
31
  private
28
32
  def equal_text?(element)
33
+ element.content = content if element.placeholder?
34
+
29
35
  content == element.content
30
36
  end
31
37
 
38
+
32
39
  def contains_elements_of?(element)
33
40
  element.elements.find {|el| not contains?(el)}.nil?
34
41
  end
@@ -1,3 +1,3 @@
1
1
  module TestXml
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "match_xml(xml)" do
3
+ describe "contain_xml(xml)" do
4
4
  subject {
5
5
  <<-XML
6
6
  <xml>
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "match_xml_structure(xml)" do
3
+ describe "contain_xml_structure(xml)" do
4
4
  subject {
5
5
  <<-XML
6
6
  <xml>
@@ -2,7 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  # TODO: attributes are not matched.
4
4
 
5
- describe "exactly_match_xml(xml)" do
5
+
6
+ describe "equal_xml(xml)" do
6
7
  subject {
7
8
  <<-XML
8
9
  <xml>
@@ -12,6 +13,23 @@ describe "exactly_match_xml(xml)" do
12
13
  XML
13
14
  }
14
15
 
16
+ before { TestXml.enable_placeholders = false }
17
+
18
+ context "when placeholders are enabled" do
19
+ before { TestXml.enable_placeholders = true }
20
+
21
+ context "and xml with equal structure contains placeholder" do
22
+ it "should pass" do
23
+ should equal_xml(<<-XML)
24
+ <xml>
25
+ <one>`example`</one>
26
+ <two>2</two>
27
+ </xml>
28
+ XML
29
+ end
30
+ end
31
+ end
32
+
15
33
  context "when xml is equal with subject" do
16
34
  it "should pass" do
17
35
  should equal_xml(<<-XML)
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe "exactly_match_xml_structure(xml)" do
3
+ describe "equal_xml_structure(xml)" do
4
4
  subject {
5
5
  <<-XML
6
6
  <xml>
metadata CHANGED
@@ -1,8 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test_xml
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 25
4
5
  prerelease:
5
- version: 0.1.0
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 1
10
+ version: 0.1.1
6
11
  platform: ruby
7
12
  authors:
8
13
  - Pavel Gabriel
@@ -22,6 +27,11 @@ dependencies:
22
27
  requirements:
23
28
  - - ">="
24
29
  - !ruby/object:Gem::Version
30
+ hash: 31
31
+ segments:
32
+ - 1
33
+ - 3
34
+ - 2
25
35
  version: 1.3.2
26
36
  type: :runtime
27
37
  version_requirements: *id001
@@ -33,6 +43,9 @@ dependencies:
33
43
  requirements:
34
44
  - - ">="
35
45
  - !ruby/object:Gem::Version
46
+ hash: 3
47
+ segments:
48
+ - 0
36
49
  version: "0"
37
50
  type: :development
38
51
  version_requirements: *id002
@@ -44,6 +57,9 @@ dependencies:
44
57
  requirements:
45
58
  - - ">="
46
59
  - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
47
63
  version: "0"
48
64
  type: :development
49
65
  version_requirements: *id003
@@ -55,6 +71,10 @@ dependencies:
55
71
  requirements:
56
72
  - - ~>
57
73
  - !ruby/object:Gem::Version
74
+ hash: 7
75
+ segments:
76
+ - 2
77
+ - 2
58
78
  version: "2.2"
59
79
  type: :development
60
80
  version_requirements: *id004
@@ -92,7 +112,6 @@ files:
92
112
  - spec/matchers/contain_xml_structure_spec.rb
93
113
  - spec/matchers/equal_xml_spec.rb
94
114
  - spec/matchers/equal_xml_structure_spec.rb
95
- - spec/spec.opts
96
115
  - spec/spec_helper.rb
97
116
  - test/nokogiri/test_node.rb
98
117
  - test/test_helper.rb
@@ -113,12 +132,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
132
  requirements:
114
133
  - - ">="
115
134
  - !ruby/object:Gem::Version
135
+ hash: 3
136
+ segments:
137
+ - 0
116
138
  version: "0"
117
139
  required_rubygems_version: !ruby/object:Gem::Requirement
118
140
  none: false
119
141
  requirements:
120
142
  - - ">="
121
143
  - !ruby/object:Gem::Version
144
+ hash: 3
145
+ segments:
146
+ - 0
122
147
  version: "0"
123
148
  requirements: []
124
149
 
@@ -132,7 +157,6 @@ test_files:
132
157
  - spec/matchers/contain_xml_structure_spec.rb
133
158
  - spec/matchers/equal_xml_spec.rb
134
159
  - spec/matchers/equal_xml_structure_spec.rb
135
- - spec/spec.opts
136
160
  - spec/spec_helper.rb
137
161
  - test/nokogiri/test_node.rb
138
162
  - test/test_helper.rb
@@ -1,2 +0,0 @@
1
- --colour
2
- --format nested