Class: Asserter::Url
- Inherits:
-
Object
- Object
- Asserter::Url
- Defined in:
- lib/depengine/asserter/url.rb
Instance Attribute Summary collapse
-
#check_host ⇒ Object
Returns the value of attribute check_host.
-
#check_port ⇒ Object
Returns the value of attribute check_port.
-
#check_protocol ⇒ Object
Returns the value of attribute check_protocol.
-
#check_response_string ⇒ Object
Returns the value of attribute check_response_string.
-
#check_uri ⇒ Object
Returns the value of attribute check_uri.
Instance Method Summary collapse
Instance Attribute Details
#check_host ⇒ Object
Returns the value of attribute check_host.
4 5 6 |
# File 'lib/depengine/asserter/url.rb', line 4 def check_host @check_host end |
#check_port ⇒ Object
Returns the value of attribute check_port.
5 6 7 |
# File 'lib/depengine/asserter/url.rb', line 5 def check_port @check_port end |
#check_protocol ⇒ Object
Returns the value of attribute check_protocol.
3 4 5 |
# File 'lib/depengine/asserter/url.rb', line 3 def check_protocol @check_protocol end |
#check_response_string ⇒ Object
Returns the value of attribute check_response_string.
7 8 9 |
# File 'lib/depengine/asserter/url.rb', line 7 def check_response_string @check_response_string end |
#check_uri ⇒ Object
Returns the value of attribute check_uri.
6 7 8 |
# File 'lib/depengine/asserter/url.rb', line 6 def check_uri @check_uri end |
Instance Method Details
#assert_url_response_of(options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/depengine/asserter/url.rb', line 9 def assert_url_response_of(={}) Helper.validates_presence_of check_protocol, "check_protocol not set" Helper.validates_presence_of check_host, "check_host not set" Helper.validates_presence_of check_port, "check_port not set" Helper.validates_presence_of check_uri, "check_uri not set" Helper.validates_presence_of check_response_string, "check_response_string not set" check_url = "#{check_protocol}://#{check_host}:#{check_port}#{check_uri}" $log.writer.info "Checking URL = #{check_url} for \"#{check_response_string}\"" # Net::HTTP.start(check_host, Integer(check_port)) do |http| port = Integer(check_port) Net::HTTP.start(check_host, port) do |http| request = Net::HTTP::Get.new check_uri response = http.request request # Net::HTTPResponse object $log.writer.debug "ResponseCode: #{response.code}" $log.writer.debug "ResponseMessage: #{response.}" $log.writer.debug "ResponseBody: #{response.body}" if not response.code == '200' $log.writer.error "Got response code: #{response.code}" exit 1 end if not response.body =~ Regexp.new(check_response_string) $log.writer.error "Expected: #{check_response_string}" $log.writer.error "Got: #{response.body}" exit 1 end end end |