capybara-email 2.2.1 → 3.0.2

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
- SHA1:
3
- metadata.gz: 34013a7a32169cf2e6623ee3233f726eae1c7637
4
- data.tar.gz: 058a077ec6feadaad0c6d4851a1ecdbe1d214770
2
+ SHA256:
3
+ metadata.gz: 47084fd2f4f50cc5243ecd6f5991f15b883dac96bab100d608c8a60d1d7096c3
4
+ data.tar.gz: 392baaa97f62a4a8debb8a77d78d68ea52884c3292c4ecb4652c4733ffab03d7
5
5
  SHA512:
6
- metadata.gz: 62bcce3d61139980e3151a536ade50be359b197af06002a781cdf37bc9866cb4f6f459aee5d93092fe6868ad13ff23f4f6ce784893a7be2ede204cc68af009a9
7
- data.tar.gz: 4c233885ff5e0b439763169001221fef849ddfe2ddde823ae4e09ed20a10f8c6e5918bd33748dd86b5f0ea15de89fa3a16e7f2d3a66d618abed8e134bcc47dd8
6
+ metadata.gz: 9bc4c279d92dd4e124a2c08b607fc77d87344ad0003300c4dcf67ae3f244793f824f513c0ead4559a49dfee39e7c99c7b1a828941541468287adaa89c3bf0c56
7
+ data.tar.gz: 905f32f981afe4d3b25254b66e82607486ca46c8e7d12c11458bbabb2854dca5e8e2fe7b7da9843ba548176f0e4063b348553a814f0da3e89a700097325060da
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2018 DockYard, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # CapybaraEmail #
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/dockyard/capybara-email.png?branch=master)](http://travis-ci.org/dockyard/capybara-email)
4
- [![Dependency Status](https://gemnasium.com/dockyard/capybara-email.png?travis)](https://gemnasium.com/dockyard/capybara-email)
5
- [![Code Climate](https://d3s6mut3hikguw.cloudfront.net/github/dockyard/capybara-email.png)](https://codeclimate.com/github/dockyard/capybara-email)
3
+ [![Build Status](https://travis-ci.org/DavyJonesLocker/capybara-email.svg?branch=master)](https://travis-ci.org/DavyJonesLocker/capybara-email)
4
+ [![Code Climate](https://d3s6mut3hikguw.cloudfront.net/github/dockyard/capybara-email.svg)](https://codeclimate.com/github/dockyard/capybara-email)
6
5
 
7
6
  Easily test [ActionMailer](https://github.com/rails/rails/tree/master/actionmailer) and [Mail](https://github.com/mikel/mail) messages in your Capybara integration tests
8
7
 
@@ -26,7 +25,11 @@ Or install it yourself as:
26
25
 
27
26
  ### RSpec ###
28
27
 
29
- Require `capybara/email/rspec` in your `spec_helper`
28
+ In your `spec_helper.rb` require `capybara/email/rspec`.
29
+
30
+ ```ruby
31
+ require 'capybara/email/rspec'
32
+ ```
30
33
 
31
34
  Example:
32
35
 
@@ -43,11 +46,23 @@ feature 'Emailer' do
43
46
 
44
47
  scenario 'following a link' do
45
48
  current_email.click_link 'your profile'
46
- page.should have_content 'Profile page'
49
+ expect(page).to have_content 'Profile page'
47
50
  end
48
51
 
49
52
  scenario 'testing for content' do
50
- current_email.should have_content 'Hello Joe!'
53
+ expect(current_email).to have_content 'Hello Joe!'
54
+ end
55
+
56
+ scenario 'testing for attachments' do
57
+ expect(current_email.attachments.first.filename).to eq 'filename.csv'
58
+ end
59
+
60
+ scenario 'testing for a custom header' do
61
+ expect(current_email.headers).to include 'header-key'
62
+ end
63
+
64
+ scenario 'testing for a custom header value' do
65
+ expect(current_email.header('header-key')).to eq 'header_value'
51
66
  end
52
67
 
53
68
  scenario 'view the email body in your browser' do
@@ -84,7 +99,7 @@ Scenario: Email is sent to winning user
84
99
 
85
100
  Then /^"([^"]*)" receives an email with "([^"]*)" as the subject$/ do |email_address, subject|
86
101
  open_email(email_address)
87
- current_email.subject.should eq subject
102
+ expect(current_email.subject).to eq subject
88
103
  end
89
104
  ```
90
105
 
@@ -107,7 +122,7 @@ end
107
122
  Example:
108
123
 
109
124
  ```ruby
110
- class EmailTriggerControllerTest < ActionController::IntegrationTest
125
+ class EmailTriggerControllerTest < ActionDispatch::IntegrationTest
111
126
  def setup
112
127
  # will clear the message queue
113
128
  clear_emails
@@ -120,11 +135,19 @@ class EmailTriggerControllerTest < ActionController::IntegrationTest
120
135
 
121
136
  test 'following a link' do
122
137
  current_email.click_link 'your profile'
123
- page.should have_content 'Profile page'
138
+ expect(page).to have_content 'Profile page'
124
139
  end
125
140
 
126
141
  test 'testing for content' do
127
- current_email.should have_content 'Hello Joe!'
142
+ expect(current_email).to have_content 'Hello Joe!'
143
+ end
144
+
145
+ test 'testing for a custom header' do
146
+ expect(current_email.headers).to include 'header-key'
147
+ end
148
+
149
+ test 'testing for a custom header value' do
150
+ expect(current_email.header('header-key')).to eq 'header_value'
128
151
  end
129
152
 
130
153
  test 'view the email body in your browser' do
@@ -134,6 +157,40 @@ class EmailTriggerControllerTest < ActionController::IntegrationTest
134
157
  end
135
158
  ```
136
159
 
160
+ ### CurrentEmail API ###
161
+
162
+ The `current_email` method will delegate all necessary method calls to
163
+ `Mail::Message`. So if you need to access the subject of an email:
164
+
165
+ ```ruby
166
+ current_email.subject
167
+ ```
168
+
169
+ Check out API for the `mail` gem for details on what methods are
170
+ available.
171
+
172
+ ## Setting your test host
173
+ When testing, it's common to want to open an email and click through to your
174
+ application. To do this, you'll probably need to update your test
175
+ environment, as well as Capybara's configuration.
176
+
177
+ By default, Capybara's `app_host` is set to
178
+ `http://example.com.` You should update this so that it points to the
179
+ same host as your test environment. In our example, we'll update both to
180
+ `http://localhost:3001`:
181
+
182
+ ```ruby
183
+ # tests/test_helper.rb
184
+ ActionDispatch::IntegrationTest do
185
+ Capybara.server_port = 3001
186
+ Capybara.app_host = 'http://localhost:3001'
187
+ end
188
+
189
+ # config/environments/test.rb
190
+ config.action_mailer.default_url_options = { host: 'localhost',
191
+ port: 3001 }
192
+ ```
193
+
137
194
  ## Sending Emails with JavaScript ##
138
195
  Sending emails asynchronously will cause `#open_email` to not open the
139
196
  correct email or not find any email at all depending on the state of the
@@ -163,14 +220,11 @@ pull requests to specific branches rather than master.
163
220
 
164
221
  Please make sure you include tests!
165
222
 
166
- Unless Rails drops support for Ruby 1.8.7 we will continue to use the
167
- hash-rocket syntax. Please respect this.
168
-
169
223
  Don't use tabs to indent, two spaces are the standard.
170
224
 
171
225
  ## Legal ##
172
226
 
173
- [DockYard](http://dockyard.com), LLC &copy; 2012
227
+ [DockYard](http://dockyard.com), Inc. &copy; 2014
174
228
 
175
229
  [@dockyard](http://twitter.com/dockyard)
176
230
 
@@ -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
@@ -62,6 +35,9 @@ class Capybara::Email::Driver < Capybara::Driver::Base
62
35
 
63
36
  alias_method :find_xpath, :find
64
37
 
38
+ def find_css(selector)
39
+ dom.css(selector).map { |node| Capybara::Email::Node.new(self, node) }
40
+ end
65
41
 
66
42
  # String version of email HTML source
67
43
  #
@@ -91,6 +67,18 @@ class Capybara::Email::Driver < Capybara::Driver::Base
91
67
 
92
68
  private
93
69
 
70
+ def method_missing(meth, *args, &block)
71
+ if email.respond_to?(meth)
72
+ if args.empty?
73
+ email.send(meth)
74
+ else
75
+ email.send(meth, args)
76
+ end
77
+ else
78
+ super
79
+ end
80
+ end
81
+
94
82
  def convert_to_html(text)
95
83
  "<html><body>#{convert_links(text)}</body></html>"
96
84
  end
@@ -12,14 +12,14 @@ class Capybara::Email::Node < Capybara::Driver::Node
12
12
  end
13
13
 
14
14
  def visible_text
15
- Capybara::Helpers.normalize_whitespace(unnormalized_text)
15
+ normalize_whitespace(unnormalized_text)
16
16
  end
17
17
 
18
18
  def all_text
19
- Capybara::Helpers.normalize_whitespace(text)
19
+ normalize_whitespace(text)
20
20
  end
21
21
 
22
- def click
22
+ def click(_keys=[], _options={})
23
23
  driver.follow(self[:href].to_s)
24
24
  end
25
25
 
@@ -31,6 +31,10 @@ class Capybara::Email::Node < Capybara::Driver::Node
31
31
  string_node.visible?
32
32
  end
33
33
 
34
+ def disabled?
35
+ string_node.disabled?
36
+ end
37
+
34
38
  def find(locator)
35
39
  native.xpath(locator).map { |node| self.class.new(driver, node) }
36
40
  end
@@ -54,6 +58,10 @@ class Capybara::Email::Node < Capybara::Driver::Node
54
58
 
55
59
  private
56
60
 
61
+ def normalize_whitespace(text)
62
+ text.to_s.gsub(/[[:space:]]+/, ' ').strip
63
+ end
64
+
57
65
  def string_node
58
66
  @string_node ||= Capybara::Node::Simple.new(native)
59
67
  end
@@ -1,7 +1,8 @@
1
1
  require 'capybara/email'
2
2
 
3
3
  RSpec.configure do |config|
4
+ config.include Capybara::Email::DSL, :type => :acceptance
4
5
  config.include Capybara::Email::DSL, :type => :feature
5
6
  config.include Capybara::Email::DSL, :type => :request
6
- config.include Capybara::Email::DSL, :type => :acceptance
7
+ config.include Capybara::Email::DSL, :type => :system
7
8
  end
@@ -1,5 +1,5 @@
1
1
  module Capybara
2
2
  module Email
3
- VERSION = '2.2.1'
3
+ VERSION = '3.0.2'
4
4
  end
5
5
  end
@@ -7,32 +7,31 @@ class Capybara::Node::Email < Capybara::Node::Document
7
7
  base.raw
8
8
  end
9
9
 
10
- # Delegate to the email subject
11
- #
12
- # @return [Mail::Message#subject]
13
- def subject
14
- base.subject
10
+ # Treat the message's body as a Capybara::Node::Simple so that
11
+ # selectors actually work instead of raising NotImplementedErrors
12
+ def body_as_simple_node
13
+ @body_as_simple_node ||= Capybara.string base.raw
15
14
  end
16
15
 
17
- # Delegate to the email to
16
+ # Returns the value of the passed in header key.
18
17
  #
19
- # @return [Mail::Message#to]
20
- def to
21
- base.to
18
+ # @return String
19
+ def header(key)
20
+ base.email.header[key].value
22
21
  end
23
22
 
24
- # Delegate to the email reply_to
23
+ # Returns the header keys as an array of strings.
25
24
  #
26
- # @return [Mail::Message#reply_to]
27
- def reply_to
28
- base.email.reply_to
25
+ # @return [String]
26
+ def headers
27
+ base.email.header.fields.map(&:name)
29
28
  end
30
29
 
31
- # Delegate to the email from
30
+ # Corrects the inspect string
32
31
  #
33
- # @return [Mail::Message#from]
34
- def from
35
- base.from
32
+ # @return [String]
33
+ def inspect
34
+ "<#{self.class.to_s}>"
36
35
  end
37
36
 
38
37
  # Save a snapshot of the page.
@@ -41,7 +40,7 @@ class Capybara::Node::Email < Capybara::Node::Document
41
40
  #
42
41
  def save_page(path = nil)
43
42
  path ||= "capybara-email-#{Time.new.strftime("%Y%m%d%H%M%S")}#{rand(10**10)}.html"
44
- path = File.expand_path(path, Capybara.save_and_open_page_path) if Capybara.save_and_open_page_path
43
+ path = File.expand_path(path, Capybara.save_path) if Capybara.save_path
45
44
 
46
45
  FileUtils.mkdir_p(File.dirname(path))
47
46
 
@@ -59,4 +58,17 @@ class Capybara::Node::Email < Capybara::Node::Document
59
58
  rescue LoadError
60
59
  warn 'Please install the launchy gem to open page with save_and_open_page'
61
60
  end
61
+
62
+ private
63
+
64
+ # Tries to send to `base` first.
65
+ # If an NotImplementedError is hit because some finders/matchers/etc. aren't implemented,
66
+ # fall back to treating the message body as a Capybara::Node::Simple
67
+ def method_missing(meth, *args, &block)
68
+ begin
69
+ base.send(meth, *args)
70
+ rescue NotImplementedError
71
+ body_as_simple_node.send(meth, *args)
72
+ end
73
+ end
62
74
  end
@@ -0,0 +1,227 @@
1
+ require 'spec_helper'
2
+
3
+ class TestApp
4
+ def self.call(env)
5
+ [200, {'Content-Type' => 'text/plain'}, ['Hello world!']]
6
+ end
7
+ end
8
+
9
+ feature 'Integration test' do
10
+ background do
11
+ clear_email
12
+ Capybara.app = ::TestApp
13
+ end
14
+
15
+ scenario 'html email' do
16
+ email = deliver(html_email)
17
+
18
+ open_email('test@example.com')
19
+ current_email.click_link 'example'
20
+ expect(page).to have_content 'Hello world!'
21
+ expect(current_email).to have_content 'This is only a html test'
22
+ expect(current_email).to have_css 'a'
23
+
24
+ expect(all_emails.first).to eq email
25
+
26
+ clear_emails
27
+ expect(all_emails).to be_empty
28
+ end
29
+
30
+ scenario 'html email follows links' do
31
+ email = deliver(html_email)
32
+ open_email('test@example.com')
33
+
34
+ current_email.click_link 'example'
35
+ expect(page.current_url).to eq('http://example.com/')
36
+
37
+ current_email.click_link 'another example'
38
+ expect(page.current_url).to eq('http://example.com:1234/')
39
+
40
+ current_email.click_link 'yet another example'
41
+ expect(page.current_url).to eq('http://example.com:1234/some/path?foo=bar')
42
+ end
43
+
44
+ scenario 'html email follows links via click_on' do
45
+ email = deliver(html_email)
46
+ open_email('test@example.com')
47
+
48
+ current_email.click_on 'example'
49
+ expect(page.current_url).to eq('http://example.com/')
50
+ end
51
+
52
+ scenario 'plain text email' do
53
+ email = deliver(plain_email)
54
+
55
+ open_email('test@example.com')
56
+ current_email.click_link 'http://example.com'
57
+ expect(page).to have_content 'Hello world!'
58
+ expect(current_email).to have_content 'This is only a plain test.'
59
+
60
+ expect(all_emails.first).to eq email
61
+
62
+ clear_emails
63
+ expect(all_emails).to be_empty
64
+ end
65
+
66
+ # should read html_part
67
+ scenario 'multipart email' do
68
+ email = deliver(multipart_email)
69
+
70
+ open_email('test@example.com')
71
+ current_email.click_link 'example'
72
+ expect(page).to have_content 'Hello world!'
73
+ expect(current_email).to have_content 'This is only a html test'
74
+
75
+ expect(all_emails.first).to eq email
76
+
77
+ clear_emails
78
+ expect(all_emails).to be_empty
79
+ end
80
+
81
+ it 'delegates to base' do
82
+ email = deliver(plain_email)
83
+ open_email('test@example.com')
84
+ expect(current_email.subject).to eq 'Test Email'
85
+ end
86
+
87
+ # should read html_part
88
+ scenario 'multipart/related email' do
89
+ email = deliver(multipart_related_email)
90
+
91
+ open_email('test@example.com')
92
+ current_email.click_link 'example'
93
+ expect(page).to have_content 'Hello world!'
94
+ expect(current_email).to have_content 'This is only a html test'
95
+
96
+ expect(all_emails.first).to eq email
97
+
98
+ clear_emails
99
+ expect(all_emails).to be_empty
100
+ end
101
+
102
+ # should read html_part
103
+ scenario 'multipart/mixed email' do
104
+ email = deliver(multipart_mixed_email)
105
+
106
+ open_email('test@example.com')
107
+ current_email.click_link 'example'
108
+ expect(page).to have_content 'Hello world!'
109
+ expect(current_email).to have_content 'This is only a html test'
110
+
111
+ expect(all_emails.first).to eq email
112
+
113
+ clear_emails
114
+ expect(all_emails).to be_empty
115
+ end
116
+
117
+ scenario 'email content matchers' do
118
+ email = deliver(multipart_email)
119
+ open_email('test@example.com')
120
+ expect(current_email).to have_link('another example', :href => 'http://example.com:1234')
121
+ end
122
+
123
+ scenario 'via ActionMailer' do
124
+ email = deliver(plain_email)
125
+
126
+ expect(all_emails.first).to eq email
127
+
128
+ clear_emails
129
+ expect(all_emails).to be_empty
130
+ end
131
+
132
+ scenario 'via Mail' do
133
+ email = plain_email.deliver!
134
+
135
+ expect(all_emails.first).to eq email
136
+
137
+ clear_emails
138
+ expect(all_emails).to be_empty
139
+ end
140
+
141
+ scenario 'multiple emails' do
142
+ deliver(plain_email)
143
+ deliver(Mail::Message.new(:to => 'test@example.com', :body => 'New Message', :context => 'text/plain'))
144
+ open_email('test@example.com')
145
+ expect(current_email.body).to eq 'New Message'
146
+ end
147
+
148
+ scenario "cc'd" do
149
+ deliver(Mail::Message.new(:cc => 'test@example.com', :body => 'New Message', :context => 'text/plain'))
150
+ open_email('test@example.com')
151
+ expect(current_email.body).to eq 'New Message'
152
+ end
153
+
154
+ scenario "bcc'd" do
155
+ deliver(Mail::Message.new(:bcc => 'test@example.com', :body => 'New Message', :context => 'text/plain'))
156
+ open_email('test@example.com')
157
+ expect(current_email.body).to eq 'New Message'
158
+ end
159
+ end
160
+
161
+ def deliver(email)
162
+ ActionMailer::Base.deliveries << email
163
+ email
164
+ end
165
+
166
+ def html_email
167
+ Mail::Message.new(:body => <<-HTML, :content_type => 'text/html', :to => 'test@example.com')
168
+ <html>
169
+ <body>
170
+ <p>
171
+ This is only a html test.
172
+ <a href="http://example.com">example</a>
173
+ <a href="http://example.com:1234">another example</a>
174
+ <a href="http://example.com:1234/some/path?foo=bar">yet another example</a>
175
+ </p>
176
+ </body>
177
+ </html>
178
+ HTML
179
+ end
180
+
181
+ def plain_email
182
+ Mail::Message.new(:body => <<-PLAIN, :content_type => 'text/plain', :to => 'test@example.com', :from => 'sender@example.com', :subject => 'Test Email')
183
+ This is only a plain test.
184
+ http://example.com
185
+ PLAIN
186
+ end
187
+
188
+ def multipart_email
189
+ Mail::Message.new do
190
+ to 'test@example.com'
191
+ text_part do
192
+ body plain_email.body.encoded
193
+ end
194
+ html_part do
195
+ content_type 'text/html; charset=UTF-8'
196
+ body html_email.body.encoded
197
+ end
198
+ end
199
+ end
200
+
201
+ def multipart_related_email
202
+ Mail::Message.new do
203
+ to 'test@example.com'
204
+ text_part do
205
+ body plain_email.body.encoded
206
+ end
207
+ html_part do
208
+ content_type 'text/html; charset=UTF-8'
209
+ body html_email.body.encoded
210
+ end
211
+ content_type 'multipart/related; charset=UTF-8'
212
+ end
213
+ end
214
+
215
+ def multipart_mixed_email
216
+ Mail::Message.new do
217
+ to 'test@example.com'
218
+ text_part do
219
+ body plain_email.body.encoded
220
+ end
221
+ html_part do
222
+ content_type 'text/html; charset=UTF-8'
223
+ body html_email.body.encoded
224
+ end
225
+ content_type 'multipart/mixed; charset=UTF-8'
226
+ end
227
+ end
@@ -0,0 +1,98 @@
1
+ require 'spec_helper'
2
+
3
+ describe Capybara::Node::Email do
4
+ let(:message) { Mail::Message.new }
5
+ let(:email) { Capybara::Node::Email.new(nil, Capybara::Email::Driver.new(message)) }
6
+
7
+ describe '#body' do
8
+ context 'html' do
9
+ before do
10
+ message.content_type = 'text/html'
11
+ message.body = '<a href="http://example.com">example</a>'
12
+ end
13
+
14
+ it 'delegates to the base' do
15
+ expect(email.body).to eq '<a href="http://example.com">example</a>'
16
+ end
17
+ end
18
+
19
+ context 'plain' do
20
+ before do
21
+ message.content_type = 'text/plain'
22
+ message.body = 'http://example.com'
23
+ end
24
+
25
+ it 'delegates to the base' do
26
+ expect(email.body).to eq 'http://example.com'
27
+ end
28
+ end
29
+ end
30
+
31
+ describe '#subject' do
32
+ before do
33
+ message.subject = 'Test subject'
34
+ end
35
+
36
+ it 'delegates to the base' do
37
+ expect(email.subject).to eq 'Test subject'
38
+ end
39
+ end
40
+
41
+ describe '#to' do
42
+ before do
43
+ message.to = 'test@example.com'
44
+ end
45
+
46
+ it 'delegates to the base' do
47
+ expect(email.to).to include 'test@example.com'
48
+ end
49
+ end
50
+
51
+ describe '#reply_to' do
52
+ before do
53
+ message.reply_to = 'test@example.com'
54
+ end
55
+
56
+ it 'delegates to the base' do
57
+ expect(email.reply_to).to include 'test@example.com'
58
+ end
59
+ end
60
+
61
+ describe '#from' do
62
+ before do
63
+ message.from = 'test@example.com'
64
+ end
65
+
66
+ it 'delegates to the base' do
67
+ expect(email.from).to include 'test@example.com'
68
+ end
69
+ end
70
+
71
+ describe '#header' do
72
+ before do
73
+ message['header-key'] = 'header_value'
74
+ end
75
+
76
+ it 'delegates to the base' do
77
+ expect(email.header('header-key')).to eq 'header_value'
78
+ end
79
+ end
80
+
81
+ describe '#headers' do
82
+ before do
83
+ message['first-key'] = 'first_value'
84
+ message['second-key'] = 'second_value'
85
+ end
86
+
87
+ it 'delegates to the base' do
88
+ expect(email.headers).to include 'first-key'
89
+ expect(email.headers).to include 'second-key'
90
+ end
91
+ end
92
+
93
+ describe '#inspect' do
94
+ it 'corrects class name' do
95
+ expect(email.inspect).to eq '<Capybara::Node::Email>'
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ begin
5
+ require 'byebug'
6
+ rescue LoadError
7
+ end
8
+
9
+ RSpec.configure do |config|
10
+ config.mock_with :mocha
11
+ end
12
+
13
+ require 'mail'
14
+ require 'bourne'
15
+ require 'action_mailer'
16
+ require 'capybara/rspec'
17
+ require 'capybara/email/rspec'
18
+
19
+ Mail.defaults do
20
+ delivery_method :test
21
+ end
22
+
23
+ RSpec.configure do |config|
24
+ config.mock_with :mocha
25
+ end
metadata CHANGED
@@ -1,97 +1,103 @@
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: 3.0.2
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: 2020-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: capybara
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.2.0
33
+ version: '2.4'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '4.0'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - ~>
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '2.4'
44
+ - - "<"
39
45
  - !ruby/object:Gem::Version
40
- version: 2.2.0
46
+ version: '4.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: actionmailer
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - '>'
51
+ - - ">"
46
52
  - !ruby/object:Gem::Version
47
53
  version: '3.0'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - '>'
58
+ - - ">"
53
59
  - !ruby/object:Gem::Version
54
60
  version: '3.0'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: bourne
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - '>='
65
+ - - ">="
60
66
  - !ruby/object:Gem::Version
61
67
  version: '0'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - '>='
72
+ - - ">="
67
73
  - !ruby/object:Gem::Version
68
74
  version: '0'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: rspec
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
- - - '>='
79
+ - - ">="
74
80
  - !ruby/object:Gem::Version
75
81
  version: '0'
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
- - - '>='
86
+ - - ">="
81
87
  - !ruby/object:Gem::Version
82
88
  version: '0'
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: rake
85
91
  requirement: !ruby/object:Gem::Requirement
86
92
  requirements:
87
- - - '>='
93
+ - - ">="
88
94
  - !ruby/object:Gem::Version
89
95
  version: '0'
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
- - - '>='
100
+ - - ">="
95
101
  - !ruby/object:Gem::Version
96
102
  version: '0'
97
103
  description: Test your ActionMailer and Mailer messages in Capybara
@@ -102,6 +108,7 @@ executables: []
102
108
  extensions: []
103
109
  extra_rdoc_files: []
104
110
  files:
111
+ - LICENSE
105
112
  - README.md
106
113
  - lib/capybara-email.rb
107
114
  - lib/capybara/email.rb
@@ -111,8 +118,12 @@ files:
111
118
  - lib/capybara/email/rspec.rb
112
119
  - lib/capybara/email/version.rb
113
120
  - lib/capybara/node/email.rb
121
+ - spec/email/driver_spec.rb
122
+ - spec/node/email_spec.rb
123
+ - spec/spec_helper.rb
114
124
  homepage: https://github.com/dockyard/capybara-email
115
- licenses: []
125
+ licenses:
126
+ - MIT
116
127
  metadata: {}
117
128
  post_install_message:
118
129
  rdoc_options: []
@@ -120,18 +131,21 @@ require_paths:
120
131
  - lib
121
132
  required_ruby_version: !ruby/object:Gem::Requirement
122
133
  requirements:
123
- - - '>='
134
+ - - ">="
124
135
  - !ruby/object:Gem::Version
125
136
  version: '0'
126
137
  required_rubygems_version: !ruby/object:Gem::Requirement
127
138
  requirements:
128
- - - '>='
139
+ - - ">="
129
140
  - !ruby/object:Gem::Version
130
141
  version: '0'
131
142
  requirements: []
132
143
  rubyforge_project:
133
- rubygems_version: 2.0.3
144
+ rubygems_version: 2.7.8
134
145
  signing_key:
135
146
  specification_version: 4
136
147
  summary: Test your ActionMailer and Mailer messages in Capybara
137
- test_files: []
148
+ test_files:
149
+ - spec/node/email_spec.rb
150
+ - spec/email/driver_spec.rb
151
+ - spec/spec_helper.rb