capybara-email 2.2.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34013a7a32169cf2e6623ee3233f726eae1c7637
4
- data.tar.gz: 058a077ec6feadaad0c6d4851a1ecdbe1d214770
3
+ metadata.gz: 963242d16a1cb3ba343c083fc5f94785321f4d9a
4
+ data.tar.gz: ede60982f5e7e1a1f27c03ff9fc7725377aea5b6
5
5
  SHA512:
6
- metadata.gz: 62bcce3d61139980e3151a536ade50be359b197af06002a781cdf37bc9866cb4f6f459aee5d93092fe6868ad13ff23f4f6ce784893a7be2ede204cc68af009a9
7
- data.tar.gz: 4c233885ff5e0b439763169001221fef849ddfe2ddde823ae4e09ed20a10f8c6e5918bd33748dd86b5f0ea15de89fa3a16e7f2d3a66d618abed8e134bcc47dd8
6
+ metadata.gz: 8a91967c7e2a825b4fbadc246cf1c59986418a4c67b299e36d46560db9d57d421e748205fef9e2bd032778560a28e50dcc38c9bee4114a3a22cb011f60175a15
7
+ data.tar.gz: 1bfc5e78d30473bdd2e907ba39f0fa19d51111d0871ae9c137a94d7ea45604109a67b1046e154ed0e93c141a71b9dcdcb7a934472b2ca258c2d0e45776d6d29a
data/README.md CHANGED
@@ -50,6 +50,14 @@ feature 'Emailer' do
50
50
  current_email.should have_content 'Hello Joe!'
51
51
  end
52
52
 
53
+ scenario 'testing for a custom header' do
54
+ current_email.headers.should include 'header-key'
55
+ end
56
+
57
+ scenario 'testing for a custom header value' do
58
+ current_email.header('header-key').should eq 'header_value'
59
+ end
60
+
53
61
  scenario 'view the email body in your browser' do
54
62
  # the `launchy` gem is required
55
63
  current_email.save_and_open
@@ -127,6 +135,14 @@ class EmailTriggerControllerTest < ActionController::IntegrationTest
127
135
  current_email.should have_content 'Hello Joe!'
128
136
  end
129
137
 
138
+ test 'testing for a custom header' do
139
+ current_email.headers.should include 'header-key'
140
+ end
141
+
142
+ test 'testing for a custom header value' do
143
+ current_email.header('header-key').should eq 'header_value'
144
+ end
145
+
130
146
  test 'view the email body in your browser' do
131
147
  # the `launchy` gem is required
132
148
  current_email.save_and_open
@@ -134,6 +150,18 @@ class EmailTriggerControllerTest < ActionController::IntegrationTest
134
150
  end
135
151
  ```
136
152
 
153
+ ### CurrentEmail API ###
154
+
155
+ The `current_email` method will delegate all necessary method calls to
156
+ `Mail::Message`. So if you need to access the subject of an email:
157
+
158
+ ```ruby
159
+ current_email.subject`
160
+ ```
161
+
162
+ Check out API for the `mail` gem for details on what methods are
163
+ available.
164
+
137
165
  ## Sending Emails with JavaScript ##
138
166
  Sending emails asynchronously will cause `#open_email` to not open the
139
167
  correct email or not find any email at all depending on the state of the
@@ -17,33 +17,6 @@ class Capybara::Email::Driver < Capybara::Driver::Base
17
17
  dom.to_xml
18
18
  end
19
19
 
20
- # Access to email subject
21
- #
22
- # delegates back to instance of Mail::Message
23
- #
24
- # @return String
25
- def subject
26
- email.subject
27
- end
28
-
29
- # Access to email recipient(s)
30
- #
31
- # delegates back to instance of Mail::Message
32
- #
33
- # @return [Array<String>]
34
- def to
35
- email.to
36
- end
37
-
38
- # Access to email sender(s)
39
- #
40
- # delegates back to instance of Mail::Message
41
- #
42
- # @return [Array<String>]
43
- def from
44
- email.from
45
- end
46
-
47
20
  # Nokogiri object for traversing content
48
21
  #
49
22
  # @return Nokogiri::HTML::Document
@@ -91,6 +64,18 @@ class Capybara::Email::Driver < Capybara::Driver::Base
91
64
 
92
65
  private
93
66
 
67
+ def method_missing(meth, *args, &block)
68
+ if email.respond_to?(meth)
69
+ if args.empty?
70
+ email.send(meth)
71
+ else
72
+ email.send(meth, args)
73
+ end
74
+ else
75
+ super
76
+ end
77
+ end
78
+
94
79
  def convert_to_html(text)
95
80
  "<html><body>#{convert_links(text)}</body></html>"
96
81
  end
@@ -1,5 +1,5 @@
1
1
  module Capybara
2
2
  module Email
3
- VERSION = '2.2.1'
3
+ VERSION = '2.3.0'
4
4
  end
5
5
  end
@@ -7,32 +7,25 @@ class Capybara::Node::Email < Capybara::Node::Document
7
7
  base.raw
8
8
  end
9
9
 
10
- # Delegate to the email subject
10
+ # Returns the value of the passed in header key.
11
11
  #
12
- # @return [Mail::Message#subject]
13
- def subject
14
- base.subject
12
+ # @return String
13
+ def header(key)
14
+ base.email.header[key].value
15
15
  end
16
16
 
17
- # Delegate to the email to
17
+ # Returns the header keys as an array of strings.
18
18
  #
19
- # @return [Mail::Message#to]
20
- def to
21
- base.to
19
+ # @return [String]
20
+ def headers
21
+ base.email.header.fields.map(&:name)
22
22
  end
23
23
 
24
- # Delegate to the email reply_to
24
+ # Corrects the inspect string
25
25
  #
26
- # @return [Mail::Message#reply_to]
27
- def reply_to
28
- base.email.reply_to
29
- end
30
-
31
- # Delegate to the email from
32
- #
33
- # @return [Mail::Message#from]
34
- def from
35
- base.from
26
+ # @return [String]
27
+ def inspect
28
+ "<#{self.class.to_s}>"
36
29
  end
37
30
 
38
31
  # Save a snapshot of the page.
@@ -59,4 +52,10 @@ class Capybara::Node::Email < Capybara::Node::Document
59
52
  rescue LoadError
60
53
  warn 'Please install the launchy gem to open page with save_and_open_page'
61
54
  end
55
+
56
+ private
57
+
58
+ def method_missing(meth, *args, &block)
59
+ base.send(meth, *args)
60
+ end
62
61
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-email
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Cardarella
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-06 00:00:00.000000000 Z
11
+ date: 2014-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail