mail_spy_interceptor 0.0.1
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 +7 -0
- data/lib/mail_spy.rb +21 -0
- data/spec/mail_spy_spec.rb +49 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b3025871d1e5f3216ab280821a75ad72a327fcc5
|
4
|
+
data.tar.gz: 76964bbef66913f75d07b1edd8c1c59408c6873e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 710688e294a926b005e390561fa078d484f4f0efbc537938debede9f55b91001842c6d94dda12bb89fabcb54ed4c1bf4e5ad3ece669b2a6e9bff55b0667a254a
|
7
|
+
data.tar.gz: c425ce6d79deaf43cd4ab66ff0e259aac9533c064d93e1eb512ee916cc6aeef9404ba0de935da9227c88ae43dd8dd44c8c8ecb5f7dfd133cc102ef45dacd0701
|
data/lib/mail_spy.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'mail'
|
2
|
+
|
3
|
+
class MailSpy
|
4
|
+
def initialize(recipients)
|
5
|
+
@recipients = normalize_to_array(recipients)
|
6
|
+
end
|
7
|
+
|
8
|
+
def delivering_email(message)
|
9
|
+
message.bcc = @recipients
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def normalize_to_array(recipients)
|
15
|
+
if recipients.respond_to? :split
|
16
|
+
recipients.split ','
|
17
|
+
else
|
18
|
+
recipients
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'mail_spy')
|
2
|
+
|
3
|
+
describe MailSpy do
|
4
|
+
it 'overrides bcc field' do
|
5
|
+
Mail.register_interceptor MailSpy.new(recipient_string)
|
6
|
+
response = deliver_mail
|
7
|
+
expect(response.bcc).to eq [recipient_string]
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'accepts an array of recipients' do
|
11
|
+
Mail.register_interceptor MailSpy.new(recipient_array)
|
12
|
+
response = deliver_mail
|
13
|
+
expect(response.bcc).to eq recipient_array
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'accepts a string of recipients' do
|
17
|
+
Mail.register_interceptor MailSpy.new(recipient_string)
|
18
|
+
response = deliver_mail
|
19
|
+
expect(response.bcc).to eq [recipient_string]
|
20
|
+
end
|
21
|
+
|
22
|
+
def recipient_string
|
23
|
+
'lorem@ipsum.com'
|
24
|
+
end
|
25
|
+
|
26
|
+
def recipient_array
|
27
|
+
['one@example.com', 'two@example.com']
|
28
|
+
end
|
29
|
+
|
30
|
+
def deliver_mail
|
31
|
+
Mail.defaults do
|
32
|
+
delivery_method :test
|
33
|
+
end
|
34
|
+
|
35
|
+
Mail.deliver do
|
36
|
+
from 'original.from@example.com'
|
37
|
+
to 'original.to@example.com'
|
38
|
+
cc 'original.cc@example.com'
|
39
|
+
bcc 'original.bcc@example.com'
|
40
|
+
subject 'some subject'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
after do
|
45
|
+
module Mail
|
46
|
+
@@delivery_interceptors = []
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mail_spy_interceptor
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Juanda Zapata
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mail
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.6'
|
69
|
+
description: |2
|
70
|
+
Use MailSpy when you want to BCC yourself in every
|
71
|
+
email sent out by your application. I've found it very
|
72
|
+
useful when running a startup in a very early stage.
|
73
|
+
email:
|
74
|
+
- juanzuluaga@gmail.com
|
75
|
+
executables: []
|
76
|
+
extensions: []
|
77
|
+
extra_rdoc_files: []
|
78
|
+
files:
|
79
|
+
- lib/mail_spy.rb
|
80
|
+
- spec/mail_spy_spec.rb
|
81
|
+
homepage: https://gitub.com/juandazapata/mail_spy
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata: {}
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 2.2.2
|
102
|
+
signing_key:
|
103
|
+
specification_version: 4
|
104
|
+
summary: Send BCC to yourself
|
105
|
+
test_files:
|
106
|
+
- spec/mail_spy_spec.rb
|