rspec-xml 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/Gemfile +6 -0
- data/Rakefile +1 -0
- data/lib/rspec/xml_matchers.rb +30 -0
- data/lib/rspec-xml/version.rb +5 -0
- data/lib/rspec-xml.rb +7 -0
- data/lib/rspec.rb +6 -0
- data/readme.md +12 -0
- data/rspec-xml.gemspec +25 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/xml_matchers_spec.rb +19 -0
- metadata +106 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module XMLMatchers
|
2
|
+
class HaveXPath
|
3
|
+
|
4
|
+
def initialize(xpath)
|
5
|
+
@xpath = xpath
|
6
|
+
end
|
7
|
+
|
8
|
+
def with_text(text)
|
9
|
+
@text = text
|
10
|
+
self
|
11
|
+
end
|
12
|
+
|
13
|
+
def matches?(xml)
|
14
|
+
::Nokogiri::XML(xml).xpath(@xpath).text == @text
|
15
|
+
end
|
16
|
+
|
17
|
+
def failure_message_for_should
|
18
|
+
"expected #{@xpath} to exist"
|
19
|
+
end
|
20
|
+
|
21
|
+
def failure_message_for_should_not
|
22
|
+
"expected #{@xpath} to not exist"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def have_xpath(xpath)
|
27
|
+
HaveXPath.new(xpath)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
data/lib/rspec-xml.rb
ADDED
data/lib/rspec.rb
ADDED
data/readme.md
ADDED
data/rspec-xml.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "rspec-xml/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "rspec-xml"
|
7
|
+
s.version = Rspec::Xml::VERSION
|
8
|
+
s.authors = ["Dan Carper"]
|
9
|
+
s.email = ["dcarper@dreamagile.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Spec your XML}
|
12
|
+
s.description = %q{One simple matcher for now}
|
13
|
+
|
14
|
+
s.rubyforge_project = "rspec-xml"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
|
20
|
+
# specify any dependencies here; for example:
|
21
|
+
s.add_development_dependency 'bundler'
|
22
|
+
|
23
|
+
s.add_runtime_dependency 'rspec'
|
24
|
+
s.add_runtime_dependency 'nokogiri'
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.expand_path('../../lib/rspec', __FILE__)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe XMLMatchers do
|
4
|
+
describe '#have_xpath' do
|
5
|
+
it 'should pass if the xpath exists containing the supplied text' do
|
6
|
+
"<node>HAI</node>".should have_xpath('/node').with_text('HAI')
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should fail if the xpath does not exist" do
|
10
|
+
lambda { "<node>HAI</node>".should have_xpath('/ne').with_text('HAI')}.
|
11
|
+
should raise_error(RSpec::Expectations::ExpectationNotMetError)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should fail if the xpath does not contain the supplied text' do
|
15
|
+
lambda { "<node>HAI</node>".should have_xpath('/ne').with_text('HI')}.
|
16
|
+
should raise_error(RSpec::Expectations::ExpectationNotMetError)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-xml
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dan Carper
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: nokogiri
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: One simple matcher for now
|
63
|
+
email:
|
64
|
+
- dcarper@dreamagile.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- Rakefile
|
72
|
+
- lib/rspec-xml.rb
|
73
|
+
- lib/rspec-xml/version.rb
|
74
|
+
- lib/rspec.rb
|
75
|
+
- lib/rspec/xml_matchers.rb
|
76
|
+
- readme.md
|
77
|
+
- rspec-xml.gemspec
|
78
|
+
- spec/spec_helper.rb
|
79
|
+
- spec/xml_matchers_spec.rb
|
80
|
+
homepage: ''
|
81
|
+
licenses: []
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubyforge_project: rspec-xml
|
100
|
+
rubygems_version: 1.8.23
|
101
|
+
signing_key:
|
102
|
+
specification_version: 3
|
103
|
+
summary: Spec your XML
|
104
|
+
test_files:
|
105
|
+
- spec/spec_helper.rb
|
106
|
+
- spec/xml_matchers_spec.rb
|