Class: MailFetcher::MailCatcherClient
- Inherits:
-
Object
- Object
- MailFetcher::MailCatcherClient
- Defined in:
- lib/mail_fetcher/mail_catcher_client.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
-
#find(recipient, subject = '', wait = 1) ⇒ Object
MailCatcherMessage if message found or nil.
-
#initialize(host, port, clean_inbox = false) ⇒ MailCatcherClient
constructor
A new instance of MailCatcherClient.
Constructor Details
#initialize(host, port, clean_inbox = false) ⇒ MailCatcherClient
Returns a new instance of MailCatcherClient.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mail_fetcher/mail_catcher_client.rb', line 10 def initialize(host, port, clean_inbox=false) base_url = "http://#{host}:#{port}" @connection = Faraday.new base_url do |conn| conn.request :json conn.response :json, :content_type => /\bjson$/ conn.use :instrumentation conn.adapter Faraday.default_adapter end if clean_inbox end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
8 9 10 |
# File 'lib/mail_fetcher/mail_catcher_client.rb', line 8 def logger @logger end |
Instance Method Details
#find(recipient, subject = '', wait = 1) ⇒ Object
Returns MailCatcherMessage if message found or nil.
22 23 24 25 26 27 28 |
# File 'lib/mail_fetcher/mail_catcher_client.rb', line 22 def find(recipient, subject='', wait=1) = eventually(:tries => wait, :delay => 1) do = all.find { |m| m['recipients'][0].include?(recipient) && m['subject'].include?(subject) } ? ['id'] : nil end ? MailCatcherMessage.new(@connection, ) : nil end |