xpath-specs 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +1 -0
- data/.gitignore +26 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/xpath/specs.rb +4 -0
- data/lib/xpath/specs/contain_a_matcher.rb +73 -0
- data/lib/xpath/specs/page_part.rb +36 -0
- data/lib/xpath/specs/version.rb +5 -0
- data/xpath-specs.gemspec +25 -0
- metadata +127 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NDRlMGQ4MGQxZjA4Yzk0ODE3MDBiMGFiMWQ2YmNiMzZhYjEzMmEwOQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MTVmMmViNDliNDhkZDYwYjNlNDczN2NiZmMxZjkxZDJhNTU5NWI1Yw==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
M2IzY2I1MjM2ZWRmZTQ1M2JhNmJmNjBhNTUxMTEyZGI2NzA4MDhjOWM3OTg2
|
10
|
+
NWJlN2UxYjIzZTYxNDczYjM3MjVmM2E3MmM3ZTA2ZDhkNGUyZTYzMjk3ZDA3
|
11
|
+
MjZjZGJkMDc0YzFmYmNlOGYyZGMxZmYwYjU1MGNlYzRhNTJlM2Y=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YTU3ODFjNTdhYjM0YzQ4ZjMzYTMzMmEzMWJhMGFmMDA1NzIyN2M2YWVhMTFh
|
14
|
+
YmJlYWUxZjEwNjg1NjQwYzViZmY1OWY3YTNiMDg4NGNkMGY0ZDBkNWFjYTQ0
|
15
|
+
NGVjNDQ5MzJmYjJiMzNhNDFhMzEzZDliNGEwMWE1MjA0MDkwNTg=
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
��m�z��_;��y�?m�ؓ���o&���U{q�/I�����&~p����ssч4�nQ:l���d��27�foW{�G���;Pd8�V
|
data/.gitignore
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.ruby-version
|
6
|
+
Gemfile.lock
|
7
|
+
coverage
|
8
|
+
InstalledFiles
|
9
|
+
lib/bundler/man
|
10
|
+
pkg
|
11
|
+
rdoc
|
12
|
+
spec/reports
|
13
|
+
test/tmp
|
14
|
+
test/version_tmp
|
15
|
+
tmp
|
16
|
+
vendor
|
17
|
+
|
18
|
+
# YARD artifacts
|
19
|
+
.yardoc
|
20
|
+
_yardoc
|
21
|
+
doc/
|
22
|
+
|
23
|
+
# emacs files
|
24
|
+
*~
|
25
|
+
*#
|
26
|
+
.#*
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Philippe Bourgau
|
2
|
+
|
3
|
+
MIT License
|
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
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Xpath::Specs
|
2
|
+
|
3
|
+
An RSpec library to get better messages when matching XPaths
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'xpath-specs'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install xpath-specs
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/xpath/specs.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Xpath
|
4
|
+
module Specs
|
5
|
+
|
6
|
+
class ContainA
|
7
|
+
def initialize(page_part)
|
8
|
+
@page_part = page_part
|
9
|
+
end
|
10
|
+
|
11
|
+
def matches?(page)
|
12
|
+
@doc = Nokogiri::HTML(body_of(page))
|
13
|
+
doc_contains(@page_part)
|
14
|
+
end
|
15
|
+
|
16
|
+
def failure_message_for_should
|
17
|
+
failure_message_for_should_ex(@page_part)
|
18
|
+
end
|
19
|
+
|
20
|
+
def failure_message_for_should_not
|
21
|
+
"expected the page not to contain #{@page_part.long_description})"
|
22
|
+
end
|
23
|
+
|
24
|
+
def description
|
25
|
+
"expected the page to contain #{@page_part.long_description}"
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def body_of(page)
|
31
|
+
if page.respond_to?(:body)
|
32
|
+
page.body
|
33
|
+
else
|
34
|
+
page
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def matched_node(page_part)
|
39
|
+
@doc.xpath(page_part.xpath)
|
40
|
+
end
|
41
|
+
|
42
|
+
def doc_contains(page_part)
|
43
|
+
!matched_node(page_part).empty?
|
44
|
+
end
|
45
|
+
|
46
|
+
def failure_message_for_should_ex(page_part)
|
47
|
+
if parent_cannot_be_found(page_part)
|
48
|
+
failure_message_for_should_ex(page_part.parent)
|
49
|
+
elsif !page_part.has_parent
|
50
|
+
[description,
|
51
|
+
"but could not find #{page_part.long_description}"].join("\n")
|
52
|
+
else
|
53
|
+
[description,
|
54
|
+
"it found #{page_part.parent.long_description} :",
|
55
|
+
" #{matched_node(page_part.parent)}",
|
56
|
+
"but not #{page_part.long_description}"].join("\n")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def parent_cannot_be_found(page_part)
|
61
|
+
page_part.has_parent and !doc_contains(page_part.parent)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def contain_a(page_part)
|
69
|
+
Xpath::Specs::ContainA.new(page_part)
|
70
|
+
end
|
71
|
+
|
72
|
+
alias :contain_an :contain_a
|
73
|
+
alias :contain_the :contain_a
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module Xpath
|
4
|
+
module Specs
|
5
|
+
|
6
|
+
class PagePart
|
7
|
+
def initialize(description, xpath, parent = nil)
|
8
|
+
@xpath = xpath
|
9
|
+
@description = description
|
10
|
+
@parent = parent
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :parent, :description, :xpath
|
14
|
+
|
15
|
+
def has_parent
|
16
|
+
!parent.nil?
|
17
|
+
end
|
18
|
+
|
19
|
+
def long_description
|
20
|
+
"#{description} (#{xpath})"
|
21
|
+
end
|
22
|
+
|
23
|
+
def with(description, xpath)
|
24
|
+
PagePart.new(description, self.xpath+xpath, self)
|
25
|
+
end
|
26
|
+
def within_a(outer_page_part)
|
27
|
+
outer_page_part.with(self.description, self.xpath)
|
28
|
+
end
|
29
|
+
def that(description, xpath)
|
30
|
+
PagePart.new("#{self.description} that #{description}", self.xpath+xpath, self)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
data/xpath-specs.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'xpath/specs/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "xpath-specs"
|
8
|
+
spec.version = Xpath::Specs::VERSION
|
9
|
+
spec.authors = ["Philou"]
|
10
|
+
spec.email = ["philippe.bourgau@gmail.com"]
|
11
|
+
spec.description = %q{A gem providing recursive and named wrappers around xpaths, in order to improve error messages when testing xpath presence in html files}
|
12
|
+
spec.summary = %q{An RSpec library to get better messages when matching XPaths}
|
13
|
+
spec.homepage = "https://github.com/philou/xpath-specs"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "nokogiri"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xpath-specs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Philou
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- !binary |-
|
12
|
+
LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURrakNDQW5xZ0F3SUJB
|
13
|
+
Z0lCQVRBTkJna3Foa2lHOXcwQkFRVUZBREJITVJrd0Z3WURWUVFEREJCd2FH
|
14
|
+
bHMKYVhCd1pTNWliM1Z5WjJGMU1SVXdFd1lLQ1pJbWlaUHlMR1FCR1JZRloy
|
15
|
+
MWhhV3d4RXpBUkJnb0praWFKay9JcwpaQUVaRmdOamIyMHdIaGNOTVRNd09U
|
16
|
+
SXpNVEV3T1RBM1doY05NVFF3T1RJek1URXdPVEEzV2pCSE1Sa3dGd1lEClZR
|
17
|
+
UUREQkJ3YUdsc2FYQndaUzVpYjNWeVoyRjFNUlV3RXdZS0NaSW1pWlB5TEdR
|
18
|
+
QkdSWUZaMjFoYVd3eEV6QVIKQmdvSmtpYUprL0lzWkFFWkZnTmpiMjB3Z2dF
|
19
|
+
aU1BMEdDU3FHU0liM0RRRUJBUVVBQTRJQkR3QXdnZ0VLQW9JQgpBUUM4Q3Bv
|
20
|
+
cVp3RWJ6WHI1NUVVeGRTcGxnbjBNWVo5eFBHTy9YbVJhOGJENjNuK0pZV0Yw
|
21
|
+
QVMrbWo0NTJaWTE4CnJ3TSt5S3JLaHRzQSthSkpkbE9hZmdJVW5ZNVNyWk9y
|
22
|
+
N3Y3a2djNlQyWU5vVWorTTAwVW0yanYrc2hRYk90VjYKcUdwMEp3MUhmUE5V
|
23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d3dIY0llUVpCL05JRDdiZXJJZjlhd3gzCnlMY2wxY21tNUFMdEovK0Jr
|
39
|
+
a21wMGk0YW1YZVRETXZxOXI4UEJzVnNRd3hZT1lKQlArVW14ejNQWDZIakZI
|
40
|
+
clEKWGRrWHgzb1oKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=
|
41
|
+
date: 2014-05-13 00:00:00.000000000 Z
|
42
|
+
dependencies:
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: nokogiri
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: bundler
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ~>
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '1.3'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ~>
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '1.3'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: rake
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
type: :development
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
description: A gem providing recursive and named wrappers around xpaths, in order
|
86
|
+
to improve error messages when testing xpath presence in html files
|
87
|
+
email:
|
88
|
+
- philippe.bourgau@gmail.com
|
89
|
+
executables: []
|
90
|
+
extensions: []
|
91
|
+
extra_rdoc_files: []
|
92
|
+
files:
|
93
|
+
- .gitignore
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- lib/xpath/specs.rb
|
99
|
+
- lib/xpath/specs/contain_a_matcher.rb
|
100
|
+
- lib/xpath/specs/page_part.rb
|
101
|
+
- lib/xpath/specs/version.rb
|
102
|
+
- xpath-specs.gemspec
|
103
|
+
homepage: https://github.com/philou/xpath-specs
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ! '>='
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.0.3
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: An RSpec library to get better messages when matching XPaths
|
127
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|