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
21 22 23 |
# File 'lib/capybara/email/driver.rb', line 21 def body dom.to_xml end |
#dom ⇒ Object
Nokogiri object for traversing content
55 56 57 |
# File 'lib/capybara/email/driver.rb', line 55 def dom @dom ||= Nokogiri::HTML(source) end |
#find(selector) ⇒ Array<Capybara::Driver::Node>
Find elements based on given xpath
64 65 66 |
# File 'lib/capybara/email/driver.rb', line 64 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 |
# 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 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
48 49 50 |
# File 'lib/capybara/email/driver.rb', line 48 def from email.from end |
#raw ⇒ Object
Plain text email contents
82 83 84 |
# File 'lib/capybara/email/driver.rb', line 82 def raw email.body.encoded end |
#source ⇒ Object
String version of email HTML source
71 72 73 74 75 76 77 |
# File 'lib/capybara/email/driver.rb', line 71 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
30 31 32 |
# File 'lib/capybara/email/driver.rb', line 30 def subject email.subject end |
#to ⇒ Array<String>
Access to email recipient(s)
delegates back to instance of Mail::Message
39 40 41 |
# File 'lib/capybara/email/driver.rb', line 39 def to email.to end |