capybara-email 2.5.0 → 3.0.1

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: 2ef4fdf419a53ce0ec2e89f2959160b3e0c8ee1a
4
- data.tar.gz: 5ebab8b7675a663ba2823fdb84f0443242eee18e
3
+ metadata.gz: 19722f41ea3d510cf52f7f3ca23adbe8e5f69fe5
4
+ data.tar.gz: 5babd4d80004dd96a9d957a112e92eea5d5952b6
5
5
  SHA512:
6
- metadata.gz: 447ca55e3abd05dd6c0828701715233ec9ca8bf0e7412009c03d34318b0284f7a06fbe4aab609e0c28ce74c6ff4b2f6a22845c32f4354bfb2b0e5a889ee783e7
7
- data.tar.gz: 7c150883ba441154a4772960147f4713524c47dc7c2ddfad5bf0c1393c401780c6d3d769dca4a94ceea585044cb3600359dc12c91a9d4127c5fd82667cdde8c2
6
+ metadata.gz: 51b91a27112e7167e90d78749173a8c5319a16343ecfe7a85f50f6e0e42c6eee010c741558c0d9e796acc90d86a0d81cf2dc1614819ddec97a6dba4a1aedd787
7
+ data.tar.gz: d2a8ac4205bca07aa84d3dacfe93c0e65523585beac737f7cbf357966881e95e5ed7518df3731432f1c23df110483dff7e686fca6b471436e03f2574e5c2a435
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,7 +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)
3
+ [![Build Status](https://travis-ci.org/DavyJonesLocker/capybara-email.svg?branch=master)](https://travis-ci.org/DavyJonesLocker/capybara-email)
4
+ [![Dependency Status](https://gemnasium.com/badges/DavyJonesLocker/capybara-email.svg?travis)](https://gemnasium.com/DavyJonesLocker/capybara-email.svg)
5
5
  [![Code Climate](https://d3s6mut3hikguw.cloudfront.net/github/dockyard/capybara-email.png)](https://codeclimate.com/github/dockyard/capybara-email)
6
6
 
7
7
  Easily test [ActionMailer](https://github.com/rails/rails/tree/master/actionmailer) and [Mail](https://github.com/mikel/mail) messages in your Capybara integration tests
@@ -123,7 +123,7 @@ end
123
123
  Example:
124
124
 
125
125
  ```ruby
126
- class EmailTriggerControllerTest < ActionController::IntegrationTest
126
+ class EmailTriggerControllerTest < ActionDispatch::IntegrationTest
127
127
  def setup
128
128
  # will clear the message queue
129
129
  clear_emails
@@ -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
 
@@ -54,6 +54,10 @@ class Capybara::Email::Node < Capybara::Driver::Node
54
54
 
55
55
  private
56
56
 
57
+ def normalize_whitespace(text)
58
+ text.to_s.gsub(/[[:space:]]+/, ' ').strip
59
+ end
60
+
57
61
  def string_node
58
62
  @string_node ||= Capybara::Node::Simple.new(native)
59
63
  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.5.0'
3
+ VERSION = '3.0.1'
4
4
  end
5
5
  end
@@ -40,7 +40,7 @@ class Capybara::Node::Email < Capybara::Node::Document
40
40
  #
41
41
  def save_page(path = nil)
42
42
  path ||= "capybara-email-#{Time.new.strftime("%Y%m%d%H%M%S")}#{rand(10**10)}.html"
43
- 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
44
44
 
45
45
  FileUtils.mkdir_p(File.dirname(path))
46
46
 
@@ -0,0 +1,219 @@
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 'plain text email' do
45
+ email = deliver(plain_email)
46
+
47
+ open_email('test@example.com')
48
+ current_email.click_link 'http://example.com'
49
+ expect(page).to have_content 'Hello world!'
50
+ expect(current_email).to have_content 'This is only a plain test.'
51
+
52
+ expect(all_emails.first).to eq email
53
+
54
+ clear_emails
55
+ expect(all_emails).to be_empty
56
+ end
57
+
58
+ # should read html_part
59
+ scenario 'multipart email' do
60
+ email = deliver(multipart_email)
61
+
62
+ open_email('test@example.com')
63
+ current_email.click_link 'example'
64
+ expect(page).to have_content 'Hello world!'
65
+ expect(current_email).to have_content 'This is only a html test'
66
+
67
+ expect(all_emails.first).to eq email
68
+
69
+ clear_emails
70
+ expect(all_emails).to be_empty
71
+ end
72
+
73
+ it 'delegates to base' do
74
+ email = deliver(plain_email)
75
+ open_email('test@example.com')
76
+ expect(current_email.subject).to eq 'Test Email'
77
+ end
78
+
79
+ # should read html_part
80
+ scenario 'multipart/related email' do
81
+ email = deliver(multipart_related_email)
82
+
83
+ open_email('test@example.com')
84
+ current_email.click_link 'example'
85
+ expect(page).to have_content 'Hello world!'
86
+ expect(current_email).to have_content 'This is only a html test'
87
+
88
+ expect(all_emails.first).to eq email
89
+
90
+ clear_emails
91
+ expect(all_emails).to be_empty
92
+ end
93
+
94
+ # should read html_part
95
+ scenario 'multipart/mixed email' do
96
+ email = deliver(multipart_mixed_email)
97
+
98
+ open_email('test@example.com')
99
+ current_email.click_link 'example'
100
+ expect(page).to have_content 'Hello world!'
101
+ expect(current_email).to have_content 'This is only a html test'
102
+
103
+ expect(all_emails.first).to eq email
104
+
105
+ clear_emails
106
+ expect(all_emails).to be_empty
107
+ end
108
+
109
+ scenario 'email content matchers' do
110
+ email = deliver(multipart_email)
111
+ open_email('test@example.com')
112
+ expect(current_email).to have_link('another example', :href => 'http://example.com:1234')
113
+ end
114
+
115
+ scenario 'via ActionMailer' do
116
+ email = deliver(plain_email)
117
+
118
+ expect(all_emails.first).to eq email
119
+
120
+ clear_emails
121
+ expect(all_emails).to be_empty
122
+ end
123
+
124
+ scenario 'via Mail' do
125
+ email = plain_email.deliver!
126
+
127
+ expect(all_emails.first).to eq email
128
+
129
+ clear_emails
130
+ expect(all_emails).to be_empty
131
+ end
132
+
133
+ scenario 'multiple emails' do
134
+ deliver(plain_email)
135
+ deliver(Mail::Message.new(:to => 'test@example.com', :body => 'New Message', :context => 'text/plain'))
136
+ open_email('test@example.com')
137
+ expect(current_email.body).to eq 'New Message'
138
+ end
139
+
140
+ scenario "cc'd" do
141
+ deliver(Mail::Message.new(:cc => 'test@example.com', :body => 'New Message', :context => 'text/plain'))
142
+ open_email('test@example.com')
143
+ expect(current_email.body).to eq 'New Message'
144
+ end
145
+
146
+ scenario "bcc'd" do
147
+ deliver(Mail::Message.new(:bcc => 'test@example.com', :body => 'New Message', :context => 'text/plain'))
148
+ open_email('test@example.com')
149
+ expect(current_email.body).to eq 'New Message'
150
+ end
151
+ end
152
+
153
+ def deliver(email)
154
+ ActionMailer::Base.deliveries << email
155
+ email
156
+ end
157
+
158
+ def html_email
159
+ Mail::Message.new(:body => <<-HTML, :content_type => 'text/html', :to => 'test@example.com')
160
+ <html>
161
+ <body>
162
+ <p>
163
+ This is only a html test.
164
+ <a href="http://example.com">example</a>
165
+ <a href="http://example.com:1234">another example</a>
166
+ <a href="http://example.com:1234/some/path?foo=bar">yet another example</a>
167
+ </p>
168
+ </body>
169
+ </html>
170
+ HTML
171
+ end
172
+
173
+ def plain_email
174
+ Mail::Message.new(:body => <<-PLAIN, :content_type => 'text/plain', :to => 'test@example.com', :from => 'sender@example.com', :subject => 'Test Email')
175
+ This is only a plain test.
176
+ http://example.com
177
+ PLAIN
178
+ end
179
+
180
+ def multipart_email
181
+ Mail::Message.new do
182
+ to 'test@example.com'
183
+ text_part do
184
+ body plain_email.body.encoded
185
+ end
186
+ html_part do
187
+ content_type 'text/html; charset=UTF-8'
188
+ body html_email.body.encoded
189
+ end
190
+ end
191
+ end
192
+
193
+ def multipart_related_email
194
+ Mail::Message.new do
195
+ to 'test@example.com'
196
+ text_part do
197
+ body plain_email.body.encoded
198
+ end
199
+ html_part do
200
+ content_type 'text/html; charset=UTF-8'
201
+ body html_email.body.encoded
202
+ end
203
+ content_type 'multipart/related; charset=UTF-8'
204
+ end
205
+ end
206
+
207
+ def multipart_mixed_email
208
+ Mail::Message.new do
209
+ to 'test@example.com'
210
+ text_part do
211
+ body plain_email.body.encoded
212
+ end
213
+ html_part do
214
+ content_type 'text/html; charset=UTF-8'
215
+ body html_email.body.encoded
216
+ end
217
+ content_type 'multipart/mixed; charset=UTF-8'
218
+ end
219
+ 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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-email
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Cardarella
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-17 00:00:00.000000000 Z
11
+ date: 2018-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mail
@@ -28,16 +28,22 @@ dependencies:
28
28
  name: capybara
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
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
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
43
  version: '2.4'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '4.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: actionmailer
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -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: []
@@ -130,8 +141,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
141
  version: '0'
131
142
  requirements: []
132
143
  rubyforge_project:
133
- rubygems_version: 2.4.5.1
144
+ rubygems_version: 2.6.11
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/email/driver_spec.rb
150
+ - spec/node/email_spec.rb
151
+ - spec/spec_helper.rb