rspec-xml 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rspec-xml/version.rb +1 -1
- data/lib/rspec-xml/xml_matchers/have_xpath/attr_matcher.rb +6 -4
- data/lib/rspec-xml/xml_matchers/have_xpath/text_matcher.rb +1 -1
- data/spec/rspec-xml/xml_matchers/have_xpath/attr_matcher_spec.rb +9 -2
- data/spec/rspec-xml/xml_matchers/have_xpath/text_matcher_spec.rb +9 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a264ff1f5588f0f158aeedb07f152a58e9191c40
|
4
|
+
data.tar.gz: 1a484b679129b367096cad167a22a72f83cfdc65
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e51e76da555618322bda7c056ba8bb4e6d5d1f7cc4a853bafedc56b71c1daddb159b3f3c91ca961150f62b9676eb860477f9934e42209b4988118b50dba04e2f
|
7
|
+
data.tar.gz: 0ac7259c98971f4d83013d0643343e989502886e1848a52afc0a80d4e482e6f2092f8a37a599e159cf11c849f4b6964c798b8839d0230da45498e06d7daf1c5e
|
data/lib/rspec-xml/version.rb
CHANGED
@@ -12,10 +12,12 @@ module RSpecXML
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def matches?(xml)
|
15
|
-
|
16
|
-
!
|
17
|
-
|
18
|
-
|
15
|
+
nodes = ::Nokogiri::XML(xml).xpath(xpath).to_a
|
16
|
+
!nodes.empty? && nodes.any? do |node|
|
17
|
+
attr.all? do |k, v|
|
18
|
+
attr_value = node.attr(k.to_s)
|
19
|
+
!attr_value.nil? && attr_value == v.to_s
|
20
|
+
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
@@ -18,8 +18,15 @@ describe RSpecXML::XMLMatchers::HaveXPath::AttrMatcher do
|
|
18
18
|
# TODO mock out Nokogiri
|
19
19
|
|
20
20
|
it 'should return true if the supplied xml contains the xpath with supplied attributes' do
|
21
|
-
matcher = subject.class.new(:xpath => '//hi', :attr => {'foo' => 'bar', 'x' => 2})
|
22
|
-
expect(matcher.matches?(
|
21
|
+
matcher = subject.class.new(:xpath => '//root/hi', :attr => {'foo' => 'bar', 'x' => 2})
|
22
|
+
expect(matcher.matches?(<<EOS
|
23
|
+
<root>
|
24
|
+
<hi foo="bar" x="1"/>
|
25
|
+
<hi foo="bar" x="2"/>
|
26
|
+
<hi foo="bar" x="3"/>
|
27
|
+
</root>
|
28
|
+
EOS
|
29
|
+
)).to be_truthy
|
23
30
|
end
|
24
31
|
|
25
32
|
it 'should return false if the supplied xml contains the xpath but not the one of the attibutes' do
|
@@ -18,8 +18,15 @@ describe RSpecXML::XMLMatchers::HaveXPath::TextMatcher do
|
|
18
18
|
# TODO mock out Nokogiri
|
19
19
|
|
20
20
|
it 'should return true if the supplied xml contains the xpath with supplied text' do
|
21
|
-
matcher = subject.class.new(:xpath => '//hi', :text => 'hi')
|
22
|
-
expect(matcher.matches?(
|
21
|
+
matcher = subject.class.new(:xpath => '//root/hi', :text => 'hi')
|
22
|
+
expect(matcher.matches?(<<EOS
|
23
|
+
<root>
|
24
|
+
<hi>hello</hi>
|
25
|
+
<hi>hi</hi>
|
26
|
+
<hi>hey</hi>
|
27
|
+
</root>
|
28
|
+
EOS
|
29
|
+
)).to be_truthy
|
23
30
|
end
|
24
31
|
|
25
32
|
it 'should return false if the supplied xml contains the xpath but not the text' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Carper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: turnip
|