Class: Capybara::Email::Driver
- Inherits:
-
Driver::Base
- Object
- Driver::Base
- Capybara::Email::Driver
- Defined in:
- lib/capybara/email/driver.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
Instance Method Summary collapse
- #body ⇒ Object
-
#dom ⇒ Object
Nokogiri object for traversing content.
-
#find(selector) ⇒ Array<Capybara::Driver::Node>
Find elements based on given xpath.
- #follow(url) ⇒ Object
-
#from ⇒ Array<String>
Access to email sender(s).
-
#initialize(email) ⇒ Driver
constructor
A new instance of Driver.
-
#raw ⇒ Object
Plain text email contents.
-
#source ⇒ Object
String version of email HTML source.
-
#subject ⇒ Object
Access to email subject.
-
#to ⇒ Array<String>
Access to email recipient(s).
Constructor Details
#initialize(email) ⇒ Driver
Returns a new instance of Driver.
4 5 6 |
# File 'lib/capybara/email/driver.rb', line 4 def initialize(email) @email = email end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
2 3 4 |
# File 'lib/capybara/email/driver.rb', line 2 def email @email end |
Instance Method Details
#body ⇒ Object
23 24 25 |
# File 'lib/capybara/email/driver.rb', line 23 def body dom.to_xml end |
#dom ⇒ Object
Nokogiri object for traversing content
57 58 59 |
# File 'lib/capybara/email/driver.rb', line 57 def dom @dom ||= Nokogiri::HTML(source) end |
#find(selector) ⇒ Array<Capybara::Driver::Node>
Find elements based on given xpath
66 67 68 |
# File 'lib/capybara/email/driver.rb', line 66 def find(selector) dom.xpath(selector).map { |node| Capybara::Email::Node.new(self, node) } end |
#follow(url) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/capybara/email/driver.rb', line 8 def follow(url) url = URI.parse(url) url = case Capybara.current_driver when :rack_test url.to_s when :poltergeist Capybara.current_session.driver.app_server.url(url.request_uri) else Capybara.current_session.driver.send(:url, url.request_uri) end Capybara.current_session.driver.visit url end |
#from ⇒ Array<String>
Access to email sender(s)
delegates back to instance of Mail::Message
50 51 52 |
# File 'lib/capybara/email/driver.rb', line 50 def from email.from end |
#raw ⇒ Object
Plain text email contents
84 85 86 |
# File 'lib/capybara/email/driver.rb', line 84 def raw email.body.encoded end |
#source ⇒ Object
String version of email HTML source
73 74 75 76 77 78 79 |
# File 'lib/capybara/email/driver.rb', line 73 def source if email.mime_type == 'text/plain' convert_to_html(raw) else raw end end |
#subject ⇒ Object
Access to email subject
delegates back to instance of Mail::Message
32 33 34 |
# File 'lib/capybara/email/driver.rb', line 32 def subject email.subject end |
#to ⇒ Array<String>
Access to email recipient(s)
delegates back to instance of Mail::Message
41 42 43 |
# File 'lib/capybara/email/driver.rb', line 41 def to email.to end |