poller 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 Net::HTTPResponse object and will apply
5
- # the search_term to the HTTPResponse.body
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 http_response [Net::HTTPResponse object] - the http response
18
- def matches?(http_response)
19
- return @search_term.match(http_response.body) if @search_term.class == Regexp
20
- http_response.body.include?(@search_term)
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 Net::HTTPResponse object and will apply
5
- # the search_term to the result of the XPath querying the HTTPResponse.body
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 http_response [Net::HTTPResponse object] - the http response
28
- def matches?(http_response)
29
- xml_doc = REXML::Document.new(http_response.body)
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 Net::HTTPResponse object and will apply
5
- # the search_term to the result of the XPath querying the HTTPResponse.body
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 http_response [Net::HTTPResponse object] - the http response
26
- def matches?(http_response)
27
- xml_doc = REXML::Document.new(http_response.body)
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)
@@ -54,7 +54,7 @@ module Poller
54
54
 
55
55
  def satisfied?
56
56
  return false if @http_response.nil?
57
- @matcher.matches?(@http_response)
57
+ @matcher.matches?(@http_response.body)
58
58
  end
59
59
 
60
60
  end
@@ -1,3 +1,3 @@
1
1
  module Poller
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.2"
3
3
  end
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.0
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 00:00:00.000000000 Z
12
+ date: 2013-03-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec