Browse files

Merge pull request #8 from hashrocket/master

Documentation additions
  • Loading branch information...
2 parents 9143797 + 2355db5 commit f7a959d0c900ec32f32dc9c99a96bfdc87b65e4a @bcardarella bcardarella committed Mar 30, 2012
Showing with 34 additions and 4 deletions.
  1. +30 −0 lib/capybara/email/driver.rb
  2. +4 −4 lib/capybara/node/email.rb
View
30 lib/capybara/email/driver.rb
@@ -17,30 +17,57 @@ def follow(url)
Capybara.current_session.driver.visit url
end
+
def body
dom.to_xml
end
+ # Access to email subject
+ #
+ # delegates back to instance of Mail::Message
+ #
+ # @return String
def subject
email.subject
end
+ # Access to email recipient(s)
+ #
+ # delegates back to instance of Mail::Message
+ #
+ # @return [Array<String>]
def to
email.to
end
+ # Access to email sender(s)
+ #
+ # delegates back to instance of Mail::Message
+ #
+ # @return [Array<String>]
def from
email.from
end
+ # Nokogiri object for traversing content
+ #
+ # @return Nokogiri::HTML::Document
def dom
@dom ||= Nokogiri::HTML(source)
end
+ # Find elements based on given xpath
+ #
+ # @param [xpath string]
+ #
+ # @return [Array<Capybara::Driver::Node>]
def find(selector)
dom.xpath(selector).map { |node| Capybara::Email::Node.new(self, node) }
end
+ # String version of email HTML source
+ #
+ # @return String
def source
if email.mime_type == 'text/plain'
convert_to_html(raw)
@@ -49,6 +76,9 @@ def source
end
end
+ # Plain text email contents
+ #
+ # @return String
def raw
email.body.encoded
end
View
8 lib/capybara/node/email.rb
@@ -1,27 +1,27 @@
class Capybara::Node::Email < Capybara::Node::Document
- # Delgate to the email body
+ # Delegate to the email body
#
# @return [Mail::Message#body]
def body
base.raw
end
- # Delgate to the email subject
+ # Delegate to the email subject
#
# @return [Mail::Message#subject]
def subject
base.subject
end
- # Delgate to the email to
+ # Delegate to the email to
#
# @return [Mail::Message#to]
def to
base.to
end
- # Delgate to the email from
+ # Delegate to the email from
#
# @return [Mail::Message#from]
def from

0 comments on commit f7a959d

Please sign in to comment.