Module: RSpec::WebserviceMatchers
- Defined in:
- lib/rspec/webservice_matchers.rb,
lib/rspec/webservice_matchers/version.rb
Constant Summary collapse
- VERSION =
"1.2.2"
Class Method Summary collapse
- .connection ⇒ Object
- .has_valid_ssl_cert?(domain_name_or_url) ⇒ Boolean
-
.make_url(url_or_domain_name) ⇒ Object
Ensure that the given string is a URL, making it into one if necessary.
Class Method Details
.connection ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/rspec/webservice_matchers.rb', line 97 def self.connection Faraday.new do |c| c.[:timeout] = TIMEOUT c.[:open_timeout] = TIMEOUT c.adapter :net_http end end |
.has_valid_ssl_cert?(domain_name_or_url) ⇒ Boolean
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rspec/webservice_matchers.rb', line 13 def self.has_valid_ssl_cert?(domain_name_or_url) # Normalize the input: remove 'http(s)://' if it's there if %r|^https?://(.+)$| === domain_name_or_url domain_name_or_url = $1 end # Test by seeing if Curl retrieves without complaining begin connection.head("https://#{domain_name_or_url}") return true rescue # Not serving SSL, expired, or incorrect domain name in certificate return false end end |
.make_url(url_or_domain_name) ⇒ Object
Ensure that the given string is a URL, making it into one if necessary.
107 108 109 110 111 112 113 |
# File 'lib/rspec/webservice_matchers.rb', line 107 def self.make_url(url_or_domain_name) unless %r|^https?://| === url_or_domain_name "http://#{url_or_domain_name}" else url_or_domain_name end end |