poller 0.3.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,8 @@
|
|
1
1
|
# This class expects a search_term in its constructor which can be
|
2
2
|
# either a String or a Regexp
|
3
3
|
#
|
4
|
-
# The matches? method takes a
|
5
|
-
# the search_term to
|
4
|
+
# The matches? method takes a String (http response body) and applies
|
5
|
+
# the search_term to it
|
6
6
|
|
7
7
|
module Matchers
|
8
8
|
module HTTP
|
@@ -14,10 +14,10 @@ module Matchers
|
|
14
14
|
@search_term = search_term
|
15
15
|
end
|
16
16
|
|
17
|
-
# @param
|
18
|
-
def matches?(
|
19
|
-
return @search_term.match(
|
20
|
-
|
17
|
+
# @param body_s [String] - the http response body
|
18
|
+
def matches?(body_s)
|
19
|
+
return @search_term.match(body_s) if @search_term.class == Regexp
|
20
|
+
body_s.include?(@search_term)
|
21
21
|
end
|
22
22
|
|
23
23
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# This class expects a String holding an XPath expression and an optional
|
2
2
|
# number of occurrences of the XPath to be found in the document.
|
3
3
|
#
|
4
|
-
# The matches? method takes a
|
5
|
-
#
|
4
|
+
# The matches? method takes a String (eg response body) and applies the search_term
|
5
|
+
# to the result of the XPath querying the document given in said String
|
6
6
|
#
|
7
7
|
# = Examples
|
8
8
|
# dcx = DocumentContainsXPath.new('//ElementA/ElementB')
|
@@ -24,9 +24,9 @@ module Matchers
|
|
24
24
|
@occurrences = occurrences
|
25
25
|
end
|
26
26
|
|
27
|
-
# @param
|
28
|
-
def matches?(
|
29
|
-
xml_doc = REXML::Document.new(
|
27
|
+
# @param document_s [String] - the document given as String
|
28
|
+
def matches?(document_s)
|
29
|
+
xml_doc = REXML::Document.new(document_s)
|
30
30
|
nodes = REXML::XPath.match(xml_doc, @xpath_expr_s)
|
31
31
|
nodes.count >= @occurrences
|
32
32
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# This class expects a String holding an XPath expression and a search_term
|
2
2
|
# in its constructor which can be either a String or a Regexp
|
3
3
|
#
|
4
|
-
# The matches? method takes a
|
5
|
-
#
|
4
|
+
# The matches? method takes a String (eg response body) and applies the search_term
|
5
|
+
# to the result of the XPath querying the document given in said String
|
6
6
|
#
|
7
7
|
# = Example
|
8
8
|
# xct = XPathContainsText.new('//ElementA/ElementB', 'Text that I expect')
|
@@ -22,9 +22,9 @@ module Matchers
|
|
22
22
|
@search_term = search_term
|
23
23
|
end
|
24
24
|
|
25
|
-
# @param
|
26
|
-
def matches?(
|
27
|
-
xml_doc = REXML::Document.new(
|
25
|
+
# @param document_s [String] - the XML document given as String
|
26
|
+
def matches?(document_s)
|
27
|
+
xml_doc = REXML::Document.new(document_s)
|
28
28
|
xpath = REXML::XPath.first(xml_doc, @xpath_expr_s)
|
29
29
|
return @search_term.match(xpath.text) if @search_term.class == Regexp
|
30
30
|
xpath.text.include?(@search_term)
|
data/lib/poller/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
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: 2013-03-
|
12
|
+
date: 2013-03-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|