Class: Cucumber::Mailcatcher::Api
- Inherits:
-
Object
- Object
- Cucumber::Mailcatcher::Api
- Defined in:
- lib/cucumber/mailcatcher/api.rb
Instance Method Summary collapse
- #delete_messages ⇒ Object
- #get_messages ⇒ Object
- #get_messages_from_email(email) ⇒ Object
- #get_messages_to_email(email) ⇒ Object
- #get_messages_with_html_body(body) ⇒ Object
- #get_messages_with_plain_body(body) ⇒ Object
- #get_messages_with_subject(subject) ⇒ Object
-
#initialize(http_client) ⇒ Api
constructor
A new instance of Api.
Constructor Details
#initialize(http_client) ⇒ Api
Returns a new instance of Api.
4 5 6 |
# File 'lib/cucumber/mailcatcher/api.rb', line 4 def initialize http_client @http = http_client end |
Instance Method Details
#delete_messages ⇒ Object
54 55 56 57 |
# File 'lib/cucumber/mailcatcher/api.rb', line 54 def @http.do_delete '/messages' true end |
#get_messages ⇒ Object
8 9 10 |
# File 'lib/cucumber/mailcatcher/api.rb', line 8 def @http.do_get_json '/messages' end |
#get_messages_from_email(email) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/cucumber/mailcatcher/api.rb', line 12 def email = .select { |item| item if item["sender"].include?(email) } end |
#get_messages_to_email(email) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/cucumber/mailcatcher/api.rb', line 20 def email = .select { |item| item if item["recipients"].include?(email) || item["recipients"].include?('<' + email + '>') } end |
#get_messages_with_html_body(body) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/cucumber/mailcatcher/api.rb', line 36 def body = .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) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/cucumber/mailcatcher/api.rb', line 45 def body = .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) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/cucumber/mailcatcher/api.rb', line 28 def subject = .select { |item| item if item["subject"].include?(subject) } end |