Class: PoolParty::Verifiers::HttpMatch

Inherits:
VerifierBase show all
Defined in:
lib/poolparty/verification/verifiers/http_match.rb

Overview

HttpMatch Verifier

Verify the body of an HTTP call matches a regular expression

Usage

http_match url, response_code

Example

verify do
  http_match  "http://host/index.html", /Welcome to your/
  http_match  "http://host/index.html", /new poolparty instance/
end

Instance Attribute Summary collapse

Attributes inherited from VerifierBase

#host

Instance Method Summary collapse

Methods inherited from VerifierBase

inherited, #name

Constructor Details

#initialize(uri, regexp) ⇒ HttpMatch

Returns a new instance of HttpMatch.



27
28
29
30
# File 'lib/poolparty/verification/verifiers/http_match.rb', line 27

def initialize(uri, regexp)
  @uri    = URI.parse(uri)
  @regexp = regexp
end

Instance Attribute Details

#regexpObject (readonly)

Returns the value of attribute regexp.



26
27
28
# File 'lib/poolparty/verification/verifiers/http_match.rb', line 26

def regexp
  @regexp
end

#uriObject (readonly)

Returns the value of attribute uri.



26
27
28
# File 'lib/poolparty/verification/verifiers/http_match.rb', line 26

def uri
  @uri
end

Instance Method Details

#passing?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/poolparty/verification/verifiers/http_match.rb', line 32

def passing?
  @regexp.match(@uri.read) ? true : false
end

#to_sObject



36
37
38
# File 'lib/poolparty/verification/verifiers/http_match.rb', line 36

def to_s
  "<#{self.class.to_s} uri:#{uri} regexp:#{regexp}>"
end