rspec-xml 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -1
- data/lib/rspec-xml/version.rb +1 -1
- data/lib/rspec-xml/xml_matchers/have_xpath/matcher.rb +27 -0
- data/lib/rspec-xml/xml_matchers/have_xpath/text_matcher.rb +32 -0
- data/lib/rspec-xml/xml_matchers/have_xpath.rb +33 -0
- data/lib/rspec-xml/xml_matchers.rb +10 -80
- data/license.txt +22 -0
- data/readme.md +22 -1
- data/rspec-xml.gemspec +2 -1
- data/spec/features/have_path.feature +11 -12
- data/spec/features/steps/have_path_steps.rb +15 -15
- data/spec/rspec-xml/xml_matchers/have_xpath/matcher_spec.rb +38 -0
- data/spec/rspec-xml/xml_matchers/have_xpath/text_matcher_spec.rb +53 -0
- data/spec/rspec-xml/xml_matchers/have_xpath_matcher_spec.rb +57 -0
- data/spec/spec_helper.rb +4 -1
- metadata +28 -4
- data/spec/xml_matchers_spec.rb +0 -32
data/Gemfile
CHANGED
data/lib/rspec-xml/version.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
module RSpecXML
|
2
|
+
module XMLMatchers
|
3
|
+
class HaveXPath
|
4
|
+
private
|
5
|
+
|
6
|
+
class Matcher
|
7
|
+
def initialize(options={})
|
8
|
+
self.xpath = options[:xpath]
|
9
|
+
end
|
10
|
+
|
11
|
+
def matches?(xml)
|
12
|
+
::Nokogiri::XML(xml).xpath(@xpath).count > 0
|
13
|
+
end
|
14
|
+
|
15
|
+
def failure_message_for_should
|
16
|
+
"expected #{xpath} to exist"
|
17
|
+
end
|
18
|
+
|
19
|
+
def failure_message_for_should_not
|
20
|
+
"expected #{xpath} to not exist"
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_accessor :xpath
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RSpecXML
|
2
|
+
module XMLMatchers
|
3
|
+
class HaveXPath
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
class TextMatcher
|
8
|
+
|
9
|
+
def initialize(options={})
|
10
|
+
self.xpath = options[:xpath]
|
11
|
+
self.text = options[:text]
|
12
|
+
end
|
13
|
+
|
14
|
+
def matches?(xml)
|
15
|
+
::Nokogiri::XML(xml).xpath(xpath).text == text
|
16
|
+
end
|
17
|
+
|
18
|
+
def failure_message_for_should
|
19
|
+
"expected #{xpath} to contain #{text}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def failure_message_for_should_not
|
23
|
+
"expected #{xpath} to not exist with text: #{text}"
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
attr_accessor :text, :xpath
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module RSpecXML
|
2
|
+
module XMLMatchers
|
3
|
+
class HaveXPath
|
4
|
+
|
5
|
+
def initialize(xpath)
|
6
|
+
self.matcher = Matcher.new(:xpath => xpath)
|
7
|
+
end
|
8
|
+
|
9
|
+
def with_text(text)
|
10
|
+
self.matcher = TextMatcher.new(
|
11
|
+
:xpath => matcher.xpath,
|
12
|
+
:text => text.to_s )
|
13
|
+
self
|
14
|
+
end
|
15
|
+
|
16
|
+
def matches?(xml)
|
17
|
+
matcher.matches?(xml)
|
18
|
+
end
|
19
|
+
|
20
|
+
def failure_message_for_should
|
21
|
+
matcher.failure_message_for_should
|
22
|
+
end
|
23
|
+
|
24
|
+
def failure_message_for_should_not
|
25
|
+
matcher.failure_message_for_should_not
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_accessor :matcher
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,84 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
def initialize(xpath)
|
6
|
-
self.xpath = xpath
|
7
|
-
@matcher = Matcher.new(:xpath => xpath)
|
8
|
-
end
|
9
|
-
|
10
|
-
def with_text(text)
|
11
|
-
@matcher = TextMatcher.new(:xpath => xpath, :text => text)
|
12
|
-
self
|
13
|
-
end
|
14
|
-
|
15
|
-
def matches?(xml)
|
16
|
-
@matcher.matches?(xml)
|
17
|
-
end
|
18
|
-
|
19
|
-
def failure_message_for_should
|
20
|
-
@matcher.failure_message_for_should
|
21
|
-
end
|
22
|
-
|
23
|
-
def failure_message_for_should_not
|
24
|
-
@matcher.failure_message_for_should_not
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
attr_accessor :xpath
|
30
|
-
|
31
|
-
class Matcher
|
32
|
-
|
33
|
-
def initialize(options={})
|
34
|
-
self.xpath = options[:xpath]
|
35
|
-
end
|
36
|
-
|
37
|
-
def matches?(xml)
|
38
|
-
::Nokogiri::XML(xml).xpath(@xpath).count > 0
|
39
|
-
end
|
40
|
-
|
41
|
-
def failure_message_for_should
|
42
|
-
"expected #{xpath} to exist"
|
43
|
-
end
|
1
|
+
root = File.dirname(__FILE__)
|
2
|
+
require "#{root}/xml_matchers/have_xpath/matcher"
|
3
|
+
require "#{root}/xml_matchers/have_xpath/text_matcher"
|
4
|
+
require "#{root}/xml_matchers/have_xpath"
|
44
5
|
|
45
|
-
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
attr_accessor :xpath
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
class TextMatcher
|
56
|
-
|
57
|
-
def initialize(options)
|
58
|
-
self.xpath = options[:xpath]
|
59
|
-
self.text = options[:text]
|
60
|
-
end
|
61
|
-
|
62
|
-
def matches?(xml)
|
63
|
-
::Nokogiri::XML(xml).xpath(xpath).text == text
|
64
|
-
end
|
65
|
-
|
66
|
-
def failure_message_for_should
|
67
|
-
"expected #{xpath} to contain #{text}"
|
68
|
-
end
|
69
|
-
|
70
|
-
def failure_message_for_should_not
|
71
|
-
"expected #{xpath} to contain #{text}"
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
6
|
+
module RSpecXML
|
7
|
+
module XMLMatchers
|
75
8
|
|
76
|
-
|
77
|
-
|
78
|
-
|
9
|
+
def have_xpath(xpath)
|
10
|
+
HaveXPath.new(xpath)
|
11
|
+
end
|
79
12
|
|
80
|
-
|
81
|
-
HaveXPath.new(xpath)
|
82
|
-
end
|
83
|
-
end
|
13
|
+
end
|
84
14
|
end
|
data/license.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2005-2010 The RSpec Development Team
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/readme.md
CHANGED
@@ -2,11 +2,32 @@
|
|
2
2
|
*spec your xml*
|
3
3
|
|
4
4
|
## installation
|
5
|
-
```
|
5
|
+
```
|
6
|
+
# Gemfile
|
6
7
|
gem 'rspec-xml'
|
7
8
|
```
|
8
9
|
|
9
10
|
## Usage
|
11
|
+
|
10
12
|
```ruby
|
13
|
+
# some_spec.rb
|
14
|
+
"<something>else</something>".should have_xpath('/something')
|
11
15
|
"<something>else</something>".should have_xpath('/something').with_text('else')
|
16
|
+
|
17
|
+
"<something>else</something>".should_not have_xpath('/what')
|
18
|
+
"<something>else</something>".should_not have_xpath('/something').with_text('what')
|
12
19
|
```
|
20
|
+
|
21
|
+
### Builder
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
xml = ''
|
25
|
+
builder = Builder::XmlMarkup.new(:target => xml)
|
26
|
+
builder.instruct!
|
27
|
+
|
28
|
+
builder.some_xml do |xml|
|
29
|
+
xml.inner 'stuff'
|
30
|
+
end
|
31
|
+
|
32
|
+
xml.should have_xpath('//some_xml/inner').with_text('stuff')
|
33
|
+
```
|
data/rspec-xml.gemspec
CHANGED
@@ -17,7 +17,8 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
|
-
|
20
|
+
s.add_development_dependency 'turnip'
|
21
|
+
s.add_development_dependency 'mocha'
|
21
22
|
|
22
23
|
s.add_runtime_dependency 'rspec'
|
23
24
|
s.add_runtime_dependency 'nokogiri'
|
@@ -1,15 +1,14 @@
|
|
1
1
|
Feature: "some xml".should have_xpath('//something').with_text('Budweiser') ---
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
Background:
|
4
|
+
Given there is a string of XML
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
Then the test should fail
|
6
|
+
Scenario: the matcher should pass when the node contains the text
|
7
|
+
Given the best node contains the text: Budweiser
|
8
|
+
When I test for the text: Budweiser within the best node
|
9
|
+
Then the test should pass
|
10
|
+
|
11
|
+
Scenario: the matcher should fail when the node doesn't contain the text
|
12
|
+
Given the best node contains the text: Budweiser
|
13
|
+
When I test for the text: Miller within the best node
|
14
|
+
Then the test should fail
|
@@ -1,22 +1,22 @@
|
|
1
1
|
steps_for :have_path do
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
step 'there is a string of XML' do
|
3
|
+
@xml = lambda { |insides| "<xml>#{insides}</xml>" }
|
4
|
+
end
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
step 'the :node_name node contains the text: :text' do |node_name, text|
|
7
|
+
@xml = @xml.call "<#{node_name}>#{text}</#{node_name}>"
|
8
|
+
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
step 'I test for the text: :text within the :node_name node' do |text, node_name|
|
11
|
+
@test = lambda { @xml.should have_xpath("//#{node_name}").with_text(text) }
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
step 'the test should pass' do
|
15
|
+
@test.should_not raise_error(RSpec::Expectations::ExpectationNotMetError)
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
step 'the test should fail' do
|
19
|
+
@test.should raise_error(RSpec::Expectations::ExpectationNotMetError)
|
20
|
+
end
|
21
21
|
|
22
22
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RSpecXML::XMLMatchers::HaveXPath::Matcher do
|
4
|
+
describe '#initialize' do
|
5
|
+
it 'should accept an xpath' do
|
6
|
+
matcher = subject.class.new(:xpath => 'not a real xpath')
|
7
|
+
matcher.xpath.should == 'not a real xpath'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#matches?' do
|
12
|
+
# TODO mock out Nokogiri
|
13
|
+
|
14
|
+
it 'should return true if the supplied xml contains the xpath' do
|
15
|
+
matcher = subject.class.new(:xpath => '//hi')
|
16
|
+
matcher.matches?('<hi></hi>').should be_true
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should return false if the supplied xml contains the xpath' do
|
20
|
+
matcher = subject.class.new(:xpath => '//hi')
|
21
|
+
matcher.matches?('<no></no>').should be_false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#failure_message_for_should' do
|
26
|
+
it 'should turn a message about the xpath not existing when it should' do
|
27
|
+
subject.stubs(:xpath).returns('xpath')
|
28
|
+
subject.failure_message_for_should.should == "expected xpath to exist"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#failure_message_for_should_not' do
|
33
|
+
it 'should turn a message about the xpath existing when it should not' do
|
34
|
+
subject.stubs(:xpath).returns('xpath')
|
35
|
+
subject.failure_message_for_should_not.should == "expected xpath to not exist"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe RSpecXML::XMLMatchers::HaveXPath::TextMatcher do
|
4
|
+
describe '#initialize' do
|
5
|
+
it 'should accept an xpath' do
|
6
|
+
matcher = subject.class.new(:xpath => 'not a real xpath')
|
7
|
+
matcher.send(:xpath).should == 'not a real xpath'
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should accept text' do
|
11
|
+
matcher = subject.class.new(:text => 'text')
|
12
|
+
matcher.send(:text).should == 'text'
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#matches?' do
|
18
|
+
# TODO mock out Nokogiri
|
19
|
+
|
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
|
+
matcher.matches?('<hi>hi</hi>').should be_true
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should return false if the supplied xml contains the xpath but not the text' do
|
26
|
+
matcher = subject.class.new(:xpath => '//hi', :text => 'what')
|
27
|
+
matcher.matches?('<hi></hi>').should be_false
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should return false if the supplied xml does not contain the xpath' do
|
31
|
+
matcher = subject.class.new(:xpath => '//hi', :text => 'what')
|
32
|
+
matcher.matches?('<no></no>').should be_false
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#failure_message_for_should' do
|
38
|
+
it 'should turn a message about the xpath not existing when the supplied text' do
|
39
|
+
subject.stubs(:xpath).returns('xpath')
|
40
|
+
subject.stubs(:text).returns('text')
|
41
|
+
subject.failure_message_for_should.should == "expected xpath to contain text"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#failure_message_for_should_not' do
|
46
|
+
it 'should turn a message about the xpath existing when it should not' do
|
47
|
+
subject.stubs(:xpath).returns('xpath')
|
48
|
+
subject.stubs(:text).returns('text')
|
49
|
+
subject.failure_message_for_should_not.should == "expected xpath to not exist with text: text"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Factory
|
4
|
+
def self.xpath_matcher(xpath)
|
5
|
+
RSpecXML::XMLMatchers::HaveXPath.new(xpath)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe RSpecXML::XMLMatchers::HaveXPath do
|
10
|
+
describe '#intialize' do
|
11
|
+
it 'should build and save a matcher containing the supplied xpath' do
|
12
|
+
|
13
|
+
RSpecXML::XMLMatchers::HaveXPath::Matcher.
|
14
|
+
expects(:new).
|
15
|
+
with(:xpath => 'fake xpath').
|
16
|
+
returns(:flag)
|
17
|
+
|
18
|
+
xpath_matcher = Factory.xpath_matcher('fake xpath')
|
19
|
+
xpath_matcher.send(:matcher).should == :flag
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#with_text' do
|
25
|
+
it 'should build a new text matcher containing supplied xpath and text' do
|
26
|
+
|
27
|
+
RSpecXML::XMLMatchers::HaveXPath::TextMatcher.
|
28
|
+
expects(:new).
|
29
|
+
with(:xpath => 'fake xpath', :text => 'blah').
|
30
|
+
returns(:flag)
|
31
|
+
|
32
|
+
xpath_matcher = Factory.xpath_matcher('fake xpath').with_text('blah')
|
33
|
+
xpath_matcher.send(:matcher).should == :flag
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#failure_message_for_should' do
|
39
|
+
it 'should delegate to the matcher' do
|
40
|
+
xpath_matcher = Factory.xpath_matcher('whatever')
|
41
|
+
xpath_matcher.stubs(:matcher).
|
42
|
+
returns(stub( :failure_message_for_should => 'woo!' ))
|
43
|
+
|
44
|
+
xpath_matcher.failure_message_for_should.should == 'woo!'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#failure_message_for_should' do
|
49
|
+
it 'should delegate to the matcher' do
|
50
|
+
xpath_matcher = Factory.xpath_matcher('whatever')
|
51
|
+
xpath_matcher.stubs(:matcher).
|
52
|
+
returns(stub( :failure_message_for_should_not => 'woo!' ))
|
53
|
+
|
54
|
+
xpath_matcher.failure_message_for_should_not.should == 'woo!'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: turnip
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: mocha
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
- !ruby/object:Gem::Dependency
|
31
47
|
name: rspec
|
32
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,12 +88,18 @@ files:
|
|
72
88
|
- lib/rspec-xml.rb
|
73
89
|
- lib/rspec-xml/version.rb
|
74
90
|
- lib/rspec-xml/xml_matchers.rb
|
91
|
+
- lib/rspec-xml/xml_matchers/have_xpath.rb
|
92
|
+
- lib/rspec-xml/xml_matchers/have_xpath/matcher.rb
|
93
|
+
- lib/rspec-xml/xml_matchers/have_xpath/text_matcher.rb
|
94
|
+
- license.txt
|
75
95
|
- readme.md
|
76
96
|
- rspec-xml.gemspec
|
77
97
|
- spec/features/have_path.feature
|
78
98
|
- spec/features/steps/have_path_steps.rb
|
99
|
+
- spec/rspec-xml/xml_matchers/have_xpath/matcher_spec.rb
|
100
|
+
- spec/rspec-xml/xml_matchers/have_xpath/text_matcher_spec.rb
|
101
|
+
- spec/rspec-xml/xml_matchers/have_xpath_matcher_spec.rb
|
79
102
|
- spec/spec_helper.rb
|
80
|
-
- spec/xml_matchers_spec.rb
|
81
103
|
homepage: ''
|
82
104
|
licenses: []
|
83
105
|
post_install_message:
|
@@ -105,5 +127,7 @@ summary: Spec your XML
|
|
105
127
|
test_files:
|
106
128
|
- spec/features/have_path.feature
|
107
129
|
- spec/features/steps/have_path_steps.rb
|
130
|
+
- spec/rspec-xml/xml_matchers/have_xpath/matcher_spec.rb
|
131
|
+
- spec/rspec-xml/xml_matchers/have_xpath/text_matcher_spec.rb
|
132
|
+
- spec/rspec-xml/xml_matchers/have_xpath_matcher_spec.rb
|
108
133
|
- spec/spec_helper.rb
|
109
|
-
- spec/xml_matchers_spec.rb
|
data/spec/xml_matchers_spec.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe RSpecXML::XMLMatchers do
|
4
|
-
describe '#have_xpath' do
|
5
|
-
context '#with_text' do
|
6
|
-
it 'should pass if the xpath exists containing the supplied text' do
|
7
|
-
"<node>HAI</node>".should have_xpath('/node').with_text('HAI')
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should fail if the xpath does not exist" do
|
11
|
-
lambda { "<node>HAI</node>".should have_xpath('/ne').with_text('HAI')}.
|
12
|
-
should raise_error(RSpec::Expectations::ExpectationNotMetError)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should fail if the xpath does not contain the supplied text' do
|
16
|
-
lambda { "<node>HAI</node>".should have_xpath('/ne').with_text('HI')}.
|
17
|
-
should raise_error(RSpec::Expectations::ExpectationNotMetError)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
context 'without specifying text' do
|
22
|
-
it 'should pass if the node exists' do
|
23
|
-
'<node>something</node>'.should have_xpath('/node')
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should fail if the node does not exist' do
|
27
|
-
lambda { "<node>HAI</node>".should have_xpath('/ne')}.
|
28
|
-
should raise_error(RSpec::Expectations::ExpectationNotMetError)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|