class Cucumber::Mailcatcher::HttpClient

Public Class Methods

new() click to toggle source
# File lib/cucumber/mailcatcher/http_client.rb, line 20
def initialize
  error = "Please set the Mailcatcher server url e.g. Cucumber::Mailcatcher::HttpClient.server_url = 'http://localhost:1080'"

  valid = @@server_url =~ /\A#{URI.regexp(%w(http https))}\z/

  raise error unless valid
end
server_url() click to toggle source
# File lib/cucumber/mailcatcher/http_client.rb, line 12
def self.server_url
  @@server_url
end
server_url=(server_url) click to toggle source
# File lib/cucumber/mailcatcher/http_client.rb, line 16
def self.server_url=server_url
  @@server_url = server_url
end

Public Instance Methods

do_delete(relative_url) click to toggle source
# File lib/cucumber/mailcatcher/http_client.rb, line 37
def do_delete relative_url
  uri = URI("#{@@server_url}#{relative_url}")

  request = Net::HTTP.new(uri.host,uri.port)
  request.delete(uri.path).code
end
do_get(relative_url) click to toggle source
# File lib/cucumber/mailcatcher/http_client.rb, line 28
def do_get relative_url
  uri = URI("#{@@server_url}#{relative_url}")
  Net::HTTP.get_response(uri)
end
do_get_json(relative_url) click to toggle source
# File lib/cucumber/mailcatcher/http_client.rb, line 33
def do_get_json relative_url
  JSON.load((do_get relative_url).body)
end