letter_opener 1.1.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8bfdc716edae6b329aa3dc67591aec9ea62e755e
4
+ data.tar.gz: a8e46f86134d73fa0f49a56fbc9a86af5817da0e
5
+ SHA512:
6
+ metadata.gz: eed6194ed2dddb66eb1d76574c32cfce8350242f4c6b034a15d0112e16294b93199697585c60c52682508b94c5d394a16734dbe2e913f08aae1c55f75277adcc
7
+ data.tar.gz: 28316c457cdcd96ce3f4e343b2174b50ee1f3476b78785a179904f8275ff862db188b97a22d56eba09585f30f33d8b905708ea2a39c9136f0f68d640567512cf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.2.0 ##
2
+
3
+ * Fix auto_link() which in some cases would return an empty <a> tag for plain text messages. (thanks [Kevin McPhillips](https://github.com/kmcphillips))
4
+ * Update styles. (thanks [Adam Doppelt](https://github.com/gurgeous))
5
+
1
6
  ## 1.1.2 ##
2
7
 
3
8
  * Show formatted display names in html template (thanks [ClaireMcGinty](https://github.com/ClaireMcGinty))
@@ -1,118 +1,126 @@
1
- <meta http-equiv="Content-Type" content="text/html; charset=<%= encoding %>">
2
- <% if mail.subject %>
3
- <title><%= h mail.subject %></title>
4
- <% end %>
5
-
6
- <style type="text/css">
7
- #message_headers {
8
- width: 100%;
9
- padding: 10px 0 0 0;
10
- margin: 0;
11
- background: #fff;
12
- font-size: 12px;
13
- font-family: "Lucida Grande";
14
- border-bottom: 1px solid #dedede;
15
- overflow: auto;
16
- }
17
-
18
- #message_headers dl {
19
- float: left;
20
- margin: 0 0 10px 0;
21
- padding: 0;
22
- }
23
-
24
- #message_headers dt {
25
- width: 92px;
26
- padding: 1px;
27
- margin: 0;
28
- float: left;
29
- text-align: right;
30
- font-weight: bold;
31
- color: #7f7f7f;
32
- }
33
-
34
- #message_headers dd {
35
- margin: 0 0 0 102px;
36
- padding: 1px;
37
- }
38
-
39
- #message_headers p.alternate {
40
- float: right;
41
- margin: 0;
42
- }
43
-
44
- #message_headers p.alternate a {
45
- color: #09c;
46
- }
47
-
48
- pre#message_body {
49
- padding: 10px;
50
- word-wrap: break-word;
51
- }
52
- </style>
53
-
54
- <div id="message_headers">
55
- <dl>
56
- <dt>From:</dt>
57
- <dd><%= h from %></dd>
58
-
59
- <% unless sender.empty? %>
60
- <dt>Sender:</dt>
61
- <dd><%= h sender %></dd>
62
- <% end %>
63
-
64
- <% unless reply_to.empty? %>
65
- <dt>Reply-To:</dt>
66
- <dd><%= h reply_to %></dd>
67
- <% end %>
68
-
1
+ <html>
2
+ <head>
3
+ <meta http-equiv="Content-Type" content="text/html; charset=<%= encoding %>">
69
4
  <% if mail.subject %>
70
- <dt>Subject:</dt>
71
- <dd><strong><%= h mail.subject %></strong></dd>
5
+ <title><%= h mail.subject %></title>
72
6
  <% end %>
73
7
 
74
- <dt>Date:</dt>
75
- <dd><%= Time.now.strftime("%b %e, %Y %I:%M:%S %p %Z") %></dd>
76
-
77
- <% unless to.empty? %>
78
- <dt>To:</dt>
79
- <dd><%= h to %></dd>
80
- <% end %>
81
-
82
- <% unless cc.empty? %>
83
- <dt>CC:</dt>
84
- <dd><%= h cc %></dd>
85
- <% end %>
86
-
87
- <% unless bcc.empty? %>
88
- <dt>BCC:</dt>
89
- <dd><%= h bcc %></dd>
90
- <% end %>
91
-
92
- <% if @attachments.any? %>
93
- <dt>Attachments:</dt>
94
- <dd>
95
- <% @attachments.each do |filename, path| %>
96
- <a href="<%= path %>"><%= filename %></a>&nbsp;
8
+ <style type="text/css">
9
+ #container {
10
+ margin: 10px auto;
11
+ width: 800px;
12
+ }
13
+ #message_headers {
14
+ background: #fff;
15
+ font-size: 12px;
16
+ font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
17
+ border-bottom: 1px solid #dedede;
18
+ margin-bottom: 10px;
19
+ overflow: auto;
20
+ }
21
+
22
+ #message_headers dl {
23
+ float: left;
24
+ line-height: 1.3em;
25
+ padding: 0;
26
+ }
27
+
28
+ #message_headers dt {
29
+ width: 92px;
30
+ margin: 0;
31
+ float: left;
32
+ text-align: right;
33
+ font-weight: bold;
34
+ color: #7f7f7f;
35
+ }
36
+
37
+ #message_headers dd {
38
+ margin: 0 0 0 102px;
39
+ }
40
+
41
+ #message_headers p.alternate {
42
+ float: right;
43
+ margin: 0;
44
+ }
45
+
46
+ #message_headers p.alternate a {
47
+ color: #09c;
48
+ }
49
+
50
+ pre#message_body {
51
+ padding: 4px;
52
+ white-space: pre-wrap;
53
+ border: 1px solid #eee;
54
+ background-color: #fcfcfc;
55
+ }
56
+ </style>
57
+ </head>
58
+ <body>
59
+ <div id="container">
60
+ <div id="message_headers">
61
+ <dl>
62
+ <dt>From:</dt>
63
+ <dd><%= h from %></dd>
64
+
65
+ <% unless sender.empty? %>
66
+ <dt>Sender:</dt>
67
+ <dd><%= h sender %></dd>
68
+ <% end %>
69
+
70
+ <% unless reply_to.empty? %>
71
+ <dt>Reply-To:</dt>
72
+ <dd><%= h reply_to %></dd>
73
+ <% end %>
74
+
75
+ <% if mail.subject %>
76
+ <dt>Subject:</dt>
77
+ <dd><strong><%= h mail.subject %></strong></dd>
78
+ <% end %>
79
+
80
+ <dt>Date:</dt>
81
+ <dd><%= Time.now.strftime("%b %e, %Y %I:%M:%S %p %Z") %></dd>
82
+
83
+ <% unless to.empty? %>
84
+ <dt>To:</dt>
85
+ <dd><%= h to %></dd>
86
+ <% end %>
87
+
88
+ <% unless cc.empty? %>
89
+ <dt>CC:</dt>
90
+ <dd><%= h cc %></dd>
91
+ <% end %>
92
+
93
+ <% unless bcc.empty? %>
94
+ <dt>BCC:</dt>
95
+ <dd><%= h bcc %></dd>
96
+ <% end %>
97
+
98
+ <% if @attachments.any? %>
99
+ <dt>Attachments:</dt>
100
+ <dd>
101
+ <% @attachments.each do |filename, path| %>
102
+ <a href="<%= path %>"><%= filename %></a>&nbsp;
103
+ <% end %>
104
+ </dd>
105
+ <% end %>
106
+ </dl>
107
+
108
+ <% if mail.multipart? %>
109
+ <p class="alternate">
110
+ <% if type == "plain" && mail.html_part %>
111
+ <a href="rich.html">View HTML version</a>
112
+ <% elsif type == "rich" && mail.text_part %>
113
+ <a href="plain.html">View plain text version</a>
114
+ <% end %>
115
+ </p>
116
+ <% end %>
117
+ </div>
118
+
119
+ <% if type == "plain" %>
120
+ <pre id="message_body"><%= auto_link(h(body)) %></pre>
121
+ <% else %>
122
+ <%= body %>
97
123
  <% end %>
98
- </dd>
99
- <% end %>
100
- </dl>
101
-
102
- <% if mail.multipart? %>
103
- <p class="alternate">
104
- <% if type == "plain" && mail.html_part %>
105
- <a href="rich.html">View HTML version</a>
106
- <% elsif type == "rich" && mail.text_part %>
107
- <a href="plain.html">View plain text version</a>
108
- <% end %>
109
- </p>
110
- <% end %>
111
- </div>
112
-
113
- <% if type == "plain" %>
114
- <pre id="message_body"><%= auto_link(h(body)) %></pre>
115
- <% else %>
116
- <%= body %>
117
- <% end %>
118
-
124
+ </div>
125
+ </body>
126
+ </html>
@@ -100,8 +100,8 @@ module LetterOpener
100
100
  end
101
101
 
102
102
  def auto_link(text)
103
- text.gsub(URI.regexp(%W[https http])) do
104
- "<a href=\"#{$&}\">#{$&}</a>"
103
+ text.gsub(URI.regexp(%W[https http])) do |link|
104
+ "<a href=\"#{ link }\">#{ link }</a>"
105
105
  end
106
106
  end
107
107
 
@@ -17,8 +17,8 @@ describe LetterOpener::DeliveryMethod do
17
17
  end
18
18
 
19
19
  it 'raises an exception if no location passed' do
20
- lambda { LetterOpener::DeliveryMethod.new }.should raise_exception(LetterOpener::DeliveryMethod::InvalidOption)
21
- lambda { LetterOpener::DeliveryMethod.new(location: "foo") }.should_not raise_exception
20
+ expect { LetterOpener::DeliveryMethod.new }.to raise_exception(LetterOpener::DeliveryMethod::InvalidOption)
21
+ expect { LetterOpener::DeliveryMethod.new(location: "foo") }.to_not raise_exception
22
22
  end
23
23
 
24
24
  context 'integration' do
@@ -29,12 +29,13 @@ describe LetterOpener::DeliveryMethod do
29
29
 
30
30
  context 'normal location path' do
31
31
  it 'opens email' do
32
+ expect($stdout).to receive(:puts)
32
33
  expect {
33
34
  Mail.deliver do
34
35
  from 'Foo foo@example.com'
35
36
  body 'World! http://example.com'
36
37
  end
37
- }.not_to raise_error(Launchy::ApplicationNotFoundError)
38
+ }.not_to raise_error
38
39
  end
39
40
  end
40
41
 
@@ -42,12 +43,13 @@ describe LetterOpener::DeliveryMethod do
42
43
  let(:location) { File.expand_path('../../../tmp/letter_opener with space', __FILE__) }
43
44
 
44
45
  it 'opens email' do
46
+ expect($stdout).to receive(:puts)
45
47
  expect {
46
48
  Mail.deliver do
47
49
  from 'Foo foo@example.com'
48
50
  body 'World! http://example.com'
49
51
  end
50
- }.not_to raise_error(Launchy::ApplicationNotFoundError)
52
+ }.not_to raise_error
51
53
  end
52
54
  end
53
55
  end
@@ -55,7 +57,7 @@ describe LetterOpener::DeliveryMethod do
55
57
  context 'content' do
56
58
  context 'plain' do
57
59
  before do
58
- Launchy.should_receive(:open)
60
+ expect(Launchy).to receive(:open)
59
61
 
60
62
  Mail.deliver do
61
63
  from 'Foo <foo@example.com>'
@@ -70,31 +72,31 @@ describe LetterOpener::DeliveryMethod do
70
72
  end
71
73
 
72
74
  it 'creates plain html document' do
73
- File.exist?(plain_file).should be_true
75
+ expect(File.exist?(plain_file)).to be_true
74
76
  end
75
77
 
76
78
  it 'saves From field' do
77
- plain.should include("Foo <foo@example.com>")
79
+ expect(plain).to include("Foo <foo@example.com>")
78
80
  end
79
81
 
80
82
  it 'saves Sender field' do
81
- plain.should include("Baz <baz@example.com>")
83
+ expect(plain).to include("Baz <baz@example.com>")
82
84
  end
83
85
 
84
86
  it 'saves Reply-to field' do
85
- plain.should include("No Reply <no-reply@example.com>")
87
+ expect(plain).to include("No Reply <no-reply@example.com>")
86
88
  end
87
89
 
88
90
  it 'saves To field' do
89
- plain.should include("Bar <bar@example.com>")
91
+ expect(plain).to include("Bar <bar@example.com>")
90
92
  end
91
93
 
92
94
  it 'saves Subject field' do
93
- plain.should include("Hello")
95
+ expect(plain).to include("Hello")
94
96
  end
95
97
 
96
98
  it 'saves Body with autolink' do
97
- plain.should include('World! <a href="http://example.com">http://example.com</a>')
99
+ expect(plain).to include('World! <a href="http://example.com">http://example.com</a>')
98
100
  end
99
101
  end
100
102
 
@@ -103,7 +105,7 @@ describe LetterOpener::DeliveryMethod do
103
105
  let(:rich) { CGI.unescape_html(File.read(rich_file)) }
104
106
 
105
107
  before do
106
- Launchy.should_receive(:open)
108
+ expect(Launchy).to receive(:open)
107
109
 
108
110
  Mail.deliver do
109
111
  from 'foo@example.com'
@@ -120,31 +122,31 @@ describe LetterOpener::DeliveryMethod do
120
122
  end
121
123
 
122
124
  it 'creates plain html document' do
123
- File.exist?(plain_file).should be_true
125
+ expect(File.exist?(plain_file)).to be_true
124
126
  end
125
127
 
126
128
  it 'creates rich html document' do
127
- File.exist?(rich_file).should be_true
129
+ expect(File.exist?(rich_file)).to be_true
128
130
  end
129
131
 
130
132
  it 'shows link to rich html version' do
131
- plain.should include("View HTML version")
133
+ expect(plain).to include("View HTML version")
132
134
  end
133
135
 
134
136
  it 'saves text part' do
135
- plain.should include("This is <plain> text")
137
+ expect(plain).to include("This is <plain> text")
136
138
  end
137
139
 
138
140
  it 'saves html part' do
139
- rich.should include("<h1>This is HTML</h1>")
141
+ expect(rich).to include("<h1>This is HTML</h1>")
140
142
  end
141
143
 
142
144
  it 'saves escaped Subject field' do
143
- plain.should include("Many parts with <html>")
145
+ expect(plain).to include("Many parts with <html>")
144
146
  end
145
147
 
146
148
  it 'shows subject as title' do
147
- rich.should include("<title>Many parts with <html></title>")
149
+ expect(rich).to include("<title>Many parts with <html></title>")
148
150
  end
149
151
  end
150
152
  end
@@ -153,7 +155,7 @@ describe LetterOpener::DeliveryMethod do
153
155
  let(:location) { File.expand_path('../../../tmp/letter_opener with space', __FILE__) }
154
156
 
155
157
  before do
156
- Launchy.should_receive(:open)
158
+ expect(Launchy).to receive(:open)
157
159
 
158
160
  Mail.deliver do
159
161
  from 'Foo <foo@example.com>'
@@ -168,13 +170,13 @@ describe LetterOpener::DeliveryMethod do
168
170
  end
169
171
 
170
172
  it 'saves From filed' do
171
- plain.should include("Foo <foo@example.com>")
173
+ expect(plain).to include("Foo <foo@example.com>")
172
174
  end
173
175
  end
174
176
 
175
177
  context 'using deliver! method' do
176
178
  before do
177
- Launchy.should_receive(:open)
179
+ expect(Launchy).to receive(:open)
178
180
  Mail.new do
179
181
  from 'foo@example.com'
180
182
  to 'bar@example.com'
@@ -184,23 +186,23 @@ describe LetterOpener::DeliveryMethod do
184
186
  end
185
187
 
186
188
  it 'creates plain html document' do
187
- File.exist?(plain_file).should be_true
189
+ expect(File.exist?(plain_file)).to be_true
188
190
  end
189
191
 
190
192
  it 'saves From field' do
191
- plain.should include("foo@example.com")
193
+ expect(plain).to include("foo@example.com")
192
194
  end
193
195
 
194
196
  it 'saves To field' do
195
- plain.should include("bar@example.com")
197
+ expect(plain).to include("bar@example.com")
196
198
  end
197
199
 
198
200
  it 'saves Subject field' do
199
- plain.should include("Hello")
201
+ expect(plain).to include("Hello")
200
202
  end
201
203
 
202
204
  it 'saves Body field' do
203
- plain.should include("World!")
205
+ expect(plain).to include("World!")
204
206
  end
205
207
  end
206
208
 
@@ -219,12 +221,12 @@ describe LetterOpener::DeliveryMethod do
219
221
 
220
222
  it 'creates attachments dir with attachment' do
221
223
  attachment = Dir["#{location}/*/attachments/#{File.basename(__FILE__)}"].first
222
- File.exists?(attachment).should be_true
224
+ expect(File.exists?(attachment)).to be_true
223
225
  end
224
226
 
225
227
  it 'saves attachment name' do
226
228
  plain = File.read(Dir["#{location}/*/plain.html"].first)
227
- plain.should include(File.basename(__FILE__))
229
+ expect(plain).to include(File.basename(__FILE__))
228
230
  end
229
231
  end
230
232
 
@@ -247,14 +249,14 @@ describe LetterOpener::DeliveryMethod do
247
249
 
248
250
  it 'creates attachments dir with attachment' do
249
251
  attachment = Dir["#{location}/*/attachments/#{File.basename(__FILE__)}"].first
250
- File.exists?(attachment).should be_true
252
+ expect(File.exists?(attachment)).to be_true
251
253
  end
252
254
 
253
255
  it 'replaces inline attachment urls' do
254
256
  text = File.read(Dir["#{location}/*/rich.html"].first)
255
- mail.parts[0].body.should include(url)
256
- text.should_not include(url)
257
- text.should include("attachments/#{File.basename(__FILE__)}")
257
+ expect(mail.parts[0].body).to include(url)
258
+ expect(text).to_not include(url)
259
+ expect(text).to include("attachments/#{File.basename(__FILE__)}")
258
260
  end
259
261
  end
260
262
 
@@ -273,19 +275,19 @@ describe LetterOpener::DeliveryMethod do
273
275
 
274
276
  it 'creates attachments dir with attachment' do
275
277
  attachment = Dir["#{location}/*/attachments/non_word_chars_used_01.txt"].first
276
- File.exists?(attachment).should be_true
278
+ expect(File.exists?(attachment)).to be_true
277
279
  end
278
280
 
279
281
  it 'saves attachment name' do
280
282
  plain = File.read(Dir["#{location}/*/plain.html"].first)
281
- plain.should include('non_word_chars_used_01.txt')
283
+ expect(plain).to include('non_word_chars_used_01.txt')
282
284
  end
283
285
  end
284
286
 
285
287
 
286
288
  context 'subjectless mail' do
287
289
  before do
288
- Launchy.should_receive(:open)
290
+ expect(Launchy).to receive(:open)
289
291
 
290
292
  Mail.deliver do
291
293
  from 'Foo foo@example.com'
@@ -296,7 +298,7 @@ describe LetterOpener::DeliveryMethod do
296
298
  end
297
299
 
298
300
  it 'creates plain html document' do
299
- File.exist?(plain_file).should be_true
301
+ expect(File.exist?(plain_file)).to be_true
300
302
  end
301
303
  end
302
304
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe LetterOpener::Message do
4
4
  let(:location) { File.expand_path('../../../tmp/letter_opener', __FILE__) }
5
5
 
6
- def mail(options)
6
+ def mail(options={})
7
7
  Mail.new(options)
8
8
  end
9
9
 
@@ -11,25 +11,25 @@ describe LetterOpener::Message do
11
11
  it 'handles one email as a string' do
12
12
  mail = mail(:reply_to => 'test@example.com')
13
13
  message = described_class.new(location, mail)
14
- message.reply_to.should eq('test@example.com')
14
+ expect(message.reply_to).to eq('test@example.com')
15
15
  end
16
16
 
17
17
  it 'handles one email with display names' do
18
18
  mail = mail(:reply_to => 'test <test@example.com>')
19
19
  message = described_class.new(location, mail)
20
- message.reply_to.should eq('test <test@example.com>')
20
+ expect(message.reply_to).to eq('test <test@example.com>')
21
21
  end
22
22
 
23
23
  it 'handles array of emails' do
24
24
  mail = mail(:reply_to => ['test1@example.com', 'test2@example.com'])
25
25
  message = described_class.new(location, mail)
26
- message.reply_to.should eq('test1@example.com, test2@example.com')
26
+ expect(message.reply_to).to eq('test1@example.com, test2@example.com')
27
27
  end
28
28
 
29
29
  it 'handles array of emails with display names' do
30
30
  mail = mail(:reply_to => ['test1 <test1@example.com>', 'test2 <test2@example.com>'])
31
31
  message = described_class.new(location, mail)
32
- message.reply_to.should eq('test1 <test1@example.com>, test2 <test2@example.com>')
32
+ expect(message.reply_to).to eq('test1 <test1@example.com>, test2 <test2@example.com>')
33
33
  end
34
34
 
35
35
  end
@@ -38,25 +38,25 @@ describe LetterOpener::Message do
38
38
  it 'handles one email as a string' do
39
39
  mail = mail(:to => 'test@example.com')
40
40
  message = described_class.new(location, mail)
41
- message.to.should eq('test@example.com')
41
+ expect(message.to).to eq('test@example.com')
42
42
  end
43
43
 
44
44
  it 'handles one email with display names' do
45
45
  mail = mail(:to => 'test <test@example.com>')
46
46
  message = described_class.new(location, mail)
47
- message.to.should eq('test <test@example.com>')
47
+ expect(message.to).to eq('test <test@example.com>')
48
48
  end
49
49
 
50
50
  it 'handles array of emails' do
51
51
  mail = mail(:to => ['test1@example.com', 'test2@example.com'])
52
52
  message = described_class.new(location, mail)
53
- message.to.should eq('test1@example.com, test2@example.com')
53
+ expect(message.to).to eq('test1@example.com, test2@example.com')
54
54
  end
55
55
 
56
56
  it 'handles array of emails with display names' do
57
57
  mail = mail(:to => ['test1 <test1@example.com>', 'test2 <test2@example.com>'])
58
58
  message = described_class.new(location, mail)
59
- message.to.should eq('test1 <test1@example.com>, test2 <test2@example.com>')
59
+ expect(message.to).to eq('test1 <test1@example.com>, test2 <test2@example.com>')
60
60
  end
61
61
 
62
62
  end
@@ -65,25 +65,25 @@ describe LetterOpener::Message do
65
65
  it 'handles one cc email as a string' do
66
66
  mail = mail(:cc => 'test@example.com')
67
67
  message = described_class.new(location, mail)
68
- message.cc.should eq('test@example.com')
68
+ expect(message.cc).to eq('test@example.com')
69
69
  end
70
70
 
71
71
  it 'handles one cc email with display name' do
72
72
  mail = mail(:cc => ['test <test1@example.com>', 'test2 <test2@example.com>'])
73
73
  message = described_class.new(location, mail)
74
- message.cc.should eq('test <test1@example.com>, test2 <test2@example.com>')
74
+ expect(message.cc).to eq('test <test1@example.com>, test2 <test2@example.com>')
75
75
  end
76
76
 
77
77
  it 'handles array of cc emails' do
78
78
  mail = mail(:cc => ['test1@example.com', 'test2@example.com'])
79
79
  message = described_class.new(location, mail)
80
- message.cc.should eq('test1@example.com, test2@example.com')
80
+ expect(message.cc).to eq('test1@example.com, test2@example.com')
81
81
  end
82
82
 
83
83
  it 'handles array of cc emails with display names' do
84
84
  mail = mail(:cc => ['test <test1@example.com>', 'test2 <test2@example.com>'])
85
85
  message = described_class.new(location, mail)
86
- message.cc.should eq('test <test1@example.com>, test2 <test2@example.com>')
86
+ expect(message.cc).to eq('test <test1@example.com>, test2 <test2@example.com>')
87
87
  end
88
88
 
89
89
  end
@@ -92,25 +92,25 @@ describe LetterOpener::Message do
92
92
  it 'handles one bcc email as a string' do
93
93
  mail = mail(:bcc => 'test@example.com')
94
94
  message = described_class.new(location, mail)
95
- message.bcc.should eq('test@example.com')
95
+ expect(message.bcc).to eq('test@example.com')
96
96
  end
97
97
 
98
98
  it 'handles one bcc email with display name' do
99
99
  mail = mail(:bcc => ['test <test1@example.com>', 'test2 <test2@example.com>'])
100
100
  message = described_class.new(location, mail)
101
- message.bcc.should eq('test <test1@example.com>, test2 <test2@example.com>')
101
+ expect(message.bcc).to eq('test <test1@example.com>, test2 <test2@example.com>')
102
102
  end
103
103
 
104
104
  it 'handles array of bcc emails' do
105
105
  mail = mail(:bcc => ['test1@example.com', 'test2@example.com'])
106
106
  message = described_class.new(location, mail)
107
- message.bcc.should eq('test1@example.com, test2@example.com')
107
+ expect(message.bcc).to eq('test1@example.com, test2@example.com')
108
108
  end
109
109
 
110
110
  it 'handles array of bcc emails with display names' do
111
111
  mail = mail(:bcc => ['test <test1@example.com>', 'test2 <test2@example.com>'])
112
112
  message = described_class.new(location, mail)
113
- message.bcc.should eq('test <test1@example.com>, test2 <test2@example.com>')
113
+ expect(message.bcc).to eq('test <test1@example.com>, test2 <test2@example.com>')
114
114
  end
115
115
 
116
116
  end
@@ -119,34 +119,49 @@ describe LetterOpener::Message do
119
119
  it 'handles one email as a string' do
120
120
  mail = mail(:sender => 'sender@example.com')
121
121
  message = described_class.new(location, mail)
122
- message.sender.should eq('sender@example.com')
122
+ expect(message.sender).to eq('sender@example.com')
123
123
  end
124
124
 
125
125
  it 'handles one email as a string with display name' do
126
126
  mail = mail(:sender => 'test <test@example.com>')
127
127
  message = described_class.new(location, mail)
128
- message.sender.should eq('test <test@example.com>')
128
+ expect(message.sender).to eq('test <test@example.com>')
129
129
  end
130
130
 
131
131
  it 'handles array of emails' do
132
132
  mail = mail(:sender => ['sender1@example.com', 'sender2@example.com'])
133
133
  message = described_class.new(location, mail)
134
- message.sender.should eq('sender1@example.com, sender2@example.com')
134
+ expect(message.sender).to eq('sender1@example.com, sender2@example.com')
135
135
  end
136
136
 
137
137
  it 'handles array of emails with display names' do
138
138
  mail = mail(:sender => ['test <test1@example.com>', 'test2 <test2@example.com>'])
139
139
  message = described_class.new(location, mail)
140
- message.sender.should eq('test <test1@example.com>, test2 <test2@example.com>')
140
+ expect(message.sender).to eq('test <test1@example.com>, test2 <test2@example.com>')
141
141
  end
142
142
 
143
143
  end
144
144
 
145
145
  describe '#<=>' do
146
146
  it 'sorts rich type before plain type' do
147
- plain = described_class.new(location, mock(content_type: 'text/plain'))
148
- rich = described_class.new(location, mock(content_type: 'text/html'))
149
- [plain, rich].sort.should eq([rich, plain])
147
+ plain = described_class.new(location, double(content_type: 'text/plain'))
148
+ rich = described_class.new(location, double(content_type: 'text/html'))
149
+ expect([plain, rich].sort).to eq([rich, plain])
150
+ end
151
+ end
152
+
153
+ describe '#auto_link' do
154
+ let(:message){ described_class.new(location, mail) }
155
+
156
+ it 'does not modify unlinkable text' do
157
+ text = 'the quick brown fox jumped over the lazy dog'
158
+ expect(message.auto_link(text)).to eq(text)
159
+ end
160
+
161
+ it 'adds links for http' do
162
+ raw = "Link to http://localhost:3000/example/path path"
163
+ linked = "Link to <a href=\"http://localhost:3000/example/path\">http://localhost:3000/example/path</a> path"
164
+ expect(message.auto_link(raw)).to eq(linked)
150
165
  end
151
166
  end
152
167
  end
data/spec/spec_helper.rb CHANGED
@@ -6,6 +6,5 @@ require "mail"
6
6
 
7
7
  RSpec.configure do |config|
8
8
  config.treat_symbols_as_metadata_keys_with_true_values = true
9
- config.filter_run :focus => true
10
9
  config.run_all_when_everything_filtered = true
11
10
  end
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: letter_opener
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
5
- prerelease:
4
+ version: 1.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ryan Bates
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-06-28 00:00:00.000000000 Z
11
+ date: 2013-12-11 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: launchy
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
@@ -30,23 +27,20 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
37
- version: 2.12.0
33
+ version: 2.14.0
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
45
- version: 2.12.0
40
+ version: 2.14.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: mail
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ~>
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ~>
60
53
  - !ruby/object:Gem::Version
@@ -81,29 +74,25 @@ files:
81
74
  - README.rdoc
82
75
  homepage: http://github.com/ryanb/letter_opener
83
76
  licenses: []
77
+ metadata: {}
84
78
  post_install_message:
85
79
  rdoc_options: []
86
80
  require_paths:
87
81
  - lib
88
82
  required_ruby_version: !ruby/object:Gem::Requirement
89
- none: false
90
83
  requirements:
91
- - - ! '>='
84
+ - - '>='
92
85
  - !ruby/object:Gem::Version
93
86
  version: '0'
94
- segments:
95
- - 0
96
- hash: -3398976380396960324
97
87
  required_rubygems_version: !ruby/object:Gem::Requirement
98
- none: false
99
88
  requirements:
100
- - - ! '>='
89
+ - - '>='
101
90
  - !ruby/object:Gem::Version
102
91
  version: 1.3.4
103
92
  requirements: []
104
93
  rubyforge_project: letter_opener
105
- rubygems_version: 1.8.24
94
+ rubygems_version: 2.1.11
106
95
  signing_key:
107
- specification_version: 3
96
+ specification_version: 4
108
97
  summary: Preview mail in browser instead of sending.
109
98
  test_files: []