Module: RSpec::WebserviceMatchers

Defined in:
lib/rspec/webservice_matchers.rb,
lib/rspec/webservice_matchers/version.rb

Constant Summary collapse

VERSION =
"1.2.0"

Class Method Summary collapse

Class Method Details

.has_valid_ssl_cert?(domain_name_or_url) ⇒ Boolean



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rspec/webservice_matchers.rb', line 14

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