class Cucumber::Mailcatcher::Api
Public Class Methods
new(http_client)
click to toggle source
# File lib/cucumber/mailcatcher/api.rb, line 4 def initialize http_client @http = http_client end
Public Instance Methods
delete_messages()
click to toggle source
# File lib/cucumber/mailcatcher/api.rb, line 54 def delete_messages @http.do_delete '/messages' true end
get_messages()
click to toggle source
# File lib/cucumber/mailcatcher/api.rb, line 8 def get_messages @http.do_get_json '/messages' end
get_messages_from_email(email)
click to toggle source
# File lib/cucumber/mailcatcher/api.rb, line 12 def get_messages_from_email email messages = get_messages messages.select { |item| item if item["sender"].include?(email) } end
get_messages_to_email(email)
click to toggle source
# File lib/cucumber/mailcatcher/api.rb, line 20 def get_messages_to_email email messages = get_messages messages.select { |item| item if item["recipients"].include?(email) || item["recipients"].include?('<' + email + '>') } end
get_messages_with_html_body(body)
click to toggle source
# File lib/cucumber/mailcatcher/api.rb, line 36 def get_messages_with_html_body body messages = get_messages messages.select { |item| response = @http.do_get "/messages/#{item['id']}.json.html" item if response.code != '404' && response.body.include?(body) } end
get_messages_with_plain_body(body)
click to toggle source
# File lib/cucumber/mailcatcher/api.rb, line 45 def get_messages_with_plain_body body messages = get_messages messages.select { |item| response = @http.do_get "/messages/#{item['id']}.json.plain" item if response.code != '404' && response.body.include?(body) } end
get_messages_with_subject(subject)
click to toggle source
# File lib/cucumber/mailcatcher/api.rb, line 28 def get_messages_with_subject subject messages = get_messages messages.select { |item| item if item["subject"].include?(subject) } end