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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8075c76f23702fb1e2ed80385cd102bfc92d507b
4
- data.tar.gz: a024df842466d9e389e636ac5649dd3ff4255616
3
+ metadata.gz: a264ff1f5588f0f158aeedb07f152a58e9191c40
4
+ data.tar.gz: 1a484b679129b367096cad167a22a72f83cfdc65
5
5
  SHA512:
6
- metadata.gz: 60b0ceb4a7c163819531c6043782970a82cd7fcbd57220ecdb4859714538a3641c254c8fe5a2c1cbbebf2a1a6dc4bce3f376591551702f0d2d6c80fe35dc850d
7
- data.tar.gz: 64e4b904035974b2aeff3316a2250048f294269518a218c7d56186b38065e72e7679ace9aa22c890e1d8cba3fa0ec64cbebc6e751447e9ecb0b09923ef47e380
6
+ metadata.gz: e51e76da555618322bda7c056ba8bb4e6d5d1f7cc4a853bafedc56b71c1daddb159b3f3c91ca961150f62b9676eb860477f9934e42209b4988118b50dba04e2f
7
+ data.tar.gz: 0ac7259c98971f4d83013d0643343e989502886e1848a52afc0a80d4e482e6f2092f8a37a599e159cf11c849f4b6964c798b8839d0230da45498e06d7daf1c5e
@@ -1,3 +1,3 @@
1
1
  module RSpecXML
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -12,10 +12,12 @@ module RSpecXML
12
12
  end
13
13
 
14
14
  def matches?(xml)
15
- node = ::Nokogiri::XML(xml).xpath(xpath)
16
- !node.empty? && attr.all? do |k, v|
17
- attr_value = node.attr(k.to_s)
18
- !attr_value.nil? && attr_value.value == v.to_s
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
 
@@ -12,7 +12,7 @@ module RSpecXML
12
12
  end
13
13
 
14
14
  def matches?(xml)
15
- ::Nokogiri::XML(xml).xpath(xpath).text == text
15
+ ::Nokogiri::XML(xml).xpath(xpath).to_a.any? { |e| e.text == text }
16
16
  end
17
17
 
18
18
  def description
@@ -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?('<hi foo="bar" x="2"/>')).to be_truthy
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?('<hi>hi</hi>')).to be_truthy
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.0
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: 2014-10-01 00:00:00.000000000 Z
11
+ date: 2015-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: turnip