Module: RSpec::WebserviceMatchers::Util
- Defined in:
- lib/rspec/webservice_matchers/util.rb
Class Method Summary collapse
- .error_message(errors) ⇒ Object
- .head(url_or_domain_name, follow: false) ⇒ Object
- .status(url_or_domain_name, follow: false) ⇒ Object
- .try_ssl_connection(domain_name_or_url) ⇒ Object
-
.up?(url_or_domain_name) ⇒ Boolean
and follow a few redirects if necessary.
- .valid_cert?(domain_name_or_url) ⇒ Boolean
Class Method Details
.error_message(errors) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/rspec/webservice_matchers/util.rb', line 11 def self.(errors) return errors. if errors.respond_to?(:message) errors .map(&:to_s) .join('; ') .capitalize end |
.head(url_or_domain_name, follow: false) ⇒ Object
24 25 26 27 28 |
# File 'lib/rspec/webservice_matchers/util.rb', line 24 def self.head(url_or_domain_name, follow: false) url = make_url(url_or_domain_name) response = recheck_on_timeout { connection(follow: follow).head(url) } [response.status, response.headers] end |
.status(url_or_domain_name, follow: false) ⇒ Object
20 21 22 |
# File 'lib/rspec/webservice_matchers/util.rb', line 20 def self.status(url_or_domain_name, follow: false) head(url_or_domain_name, follow: follow)[0] end |
.try_ssl_connection(domain_name_or_url) ⇒ Object
47 48 49 50 51 |
# File 'lib/rspec/webservice_matchers/util.rb', line 47 def self.try_ssl_connection(domain_name_or_url) url = "https://#{remove_protocol(domain_name_or_url)}" recheck_on_timeout { connection.head(url) } true end |
.up?(url_or_domain_name) ⇒ Boolean
and follow a few redirects if necessary.
32 33 34 35 36 37 |
# File 'lib/rspec/webservice_matchers/util.rb', line 32 def self.up?(url_or_domain_name) url = make_url(url_or_domain_name) conn = connection(follow: true) response = recheck_on_timeout { conn.head(url) } response.status == 200 end |
.valid_cert?(domain_name_or_url) ⇒ Boolean
39 40 41 42 43 44 45 |
# File 'lib/rspec/webservice_matchers/util.rb', line 39 def self.valid_cert?(domain_name_or_url) try_ssl_connection(domain_name_or_url) true rescue # Not serving SSL, expired, or incorrect domain name in certificate false end |