mailstro 0.0.7 → 0.0.8
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.
- data/Readme.md +12 -4
- data/lib/mailstro/rspec.rb +1 -1
- data/lib/mailstro/test_strategy.rb +21 -6
- data/lib/mailstro/version.rb +1 -1
- data/spec/mailstro/configuration_spec.rb +15 -0
- data/spec/mailstro/test_strategy_spec.rb +68 -30
- data/spec/spec_helper.rb +1 -0
- metadata +1 -3
- data/spec/mailstro_spec.rb +0 -19
data/Readme.md
CHANGED
@@ -45,7 +45,7 @@ Mailstro.deliver(
|
|
45
45
|
Sending an email to a list of users, with subscription management.
|
46
46
|
|
47
47
|
```ruby
|
48
|
-
Mailstro.subscribe('
|
48
|
+
Mailstro.subscribe('shanon@mailstroapp.com', :build_watchers, project_id)
|
49
49
|
|
50
50
|
Mailstro.deliver(
|
51
51
|
:to => [:build_watchers, project_id]
|
@@ -55,10 +55,10 @@ Mailstro.deliver(
|
|
55
55
|
}
|
56
56
|
)
|
57
57
|
|
58
|
-
Mailstro.unsubscribe('
|
58
|
+
Mailstro.unsubscribe('shanon@mailstroapp.com', :build_watchers, project_id)
|
59
59
|
```
|
60
60
|
|
61
|
-
## RSpec
|
61
|
+
## RSpec
|
62
62
|
|
63
63
|
Require the mailstro spec helper to automatically enable test mode.
|
64
64
|
|
@@ -75,11 +75,19 @@ Mailstro.deliver(
|
|
75
75
|
)
|
76
76
|
|
77
77
|
Mailstro.should have_delivered(:welcome)
|
78
|
+
Mailstro.should have_delivered(
|
79
|
+
:to => 'shanon@mailstroapp.com',
|
80
|
+
:template_name => :welcome
|
81
|
+
)
|
78
82
|
|
79
83
|
Mailstro.should have_subscribed('a@a.com', :watchers, 2)
|
80
84
|
Mailstro.should have_unsubscribed('a@a.com', :watchers, 2)
|
81
|
-
```
|
82
85
|
|
86
|
+
Mailstro.should have_delivered(
|
87
|
+
:to => [:build_watchers, project_name],
|
88
|
+
:template_name => :build_failed
|
89
|
+
)
|
90
|
+
```
|
83
91
|
|
84
92
|
## Contributing
|
85
93
|
|
data/lib/mailstro/rspec.rb
CHANGED
@@ -8,10 +8,6 @@ module Mailstro
|
|
8
8
|
@@subscribes = []
|
9
9
|
@@unsubscribes = []
|
10
10
|
|
11
|
-
def self.deliveries
|
12
|
-
@@deliveries
|
13
|
-
end
|
14
|
-
|
15
11
|
def self.clear
|
16
12
|
@@deliveries = []
|
17
13
|
@@subscribes = []
|
@@ -34,8 +30,27 @@ module Mailstro
|
|
34
30
|
@@unsubscribes << ListUnsubscribe.new(contact_email, list_type, list_name)
|
35
31
|
end
|
36
32
|
|
37
|
-
def self.has_delivered?(
|
38
|
-
@@deliveries.
|
33
|
+
def self.has_delivered?(conditions)
|
34
|
+
@@deliveries.any? do |delivery|
|
35
|
+
result = true
|
36
|
+
if conditions.is_a?(Hash)
|
37
|
+
if conditions[:template_name]
|
38
|
+
result = result && delivery.template_name == conditions[:template_name]
|
39
|
+
end
|
40
|
+
if conditions[:to]
|
41
|
+
result = result && delivery.contact_email == conditions[:to]
|
42
|
+
end
|
43
|
+
if conditions[:to_list_type]
|
44
|
+
result = result && delivery.list_type == conditions[:to_list_type]
|
45
|
+
end
|
46
|
+
if conditions[:to_list_name]
|
47
|
+
result = result && delivery.list_name == conditions[:to_list_name]
|
48
|
+
end
|
49
|
+
else
|
50
|
+
result = delivery.template_name == conditions
|
51
|
+
end
|
52
|
+
result
|
53
|
+
end
|
39
54
|
end
|
40
55
|
|
41
56
|
def self.has_subscribed?(contact_email, list_type, list_name)
|
data/lib/mailstro/version.rb
CHANGED
@@ -14,4 +14,19 @@ describe Mailstro::Configuration do
|
|
14
14
|
}.to raise_error(Mailstro::Error::ConfigurationError)
|
15
15
|
end
|
16
16
|
end
|
17
|
+
|
18
|
+
describe ".configure" do
|
19
|
+
after do
|
20
|
+
Mailstro.configuration = Mailstro::Configuration.new
|
21
|
+
end
|
22
|
+
|
23
|
+
it "allows you to pass a block to configure Mailstro" do
|
24
|
+
Mailstro.configure do |config|
|
25
|
+
config.api_key = 'x'
|
26
|
+
config.api_endpoint = 'mailstro.dev'
|
27
|
+
end
|
28
|
+
|
29
|
+
Mailstro.configuration.api_endpoint.should == 'mailstro.dev'
|
30
|
+
end
|
31
|
+
end
|
17
32
|
end
|
@@ -29,39 +29,77 @@ describe Mailstro::TestStrategy do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
describe '.clear' do
|
33
|
-
before do
|
34
|
-
Mailstro.deliver(
|
35
|
-
:to => 'a@a.com',
|
36
|
-
:template_name => :welcome
|
37
|
-
)
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'empties out the .deliveries array' do
|
41
|
-
Mailstro::TestStrategy.deliveries.should_not be_empty
|
42
|
-
Mailstro::TestStrategy.clear
|
43
|
-
|
44
|
-
Mailstro::TestStrategy.deliveries.should be_empty
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
32
|
describe '.has_delivered?' do
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
33
|
+
context "with a delivery" do
|
34
|
+
before do
|
35
|
+
Mailstro.deliver(
|
36
|
+
:to => 'a@a.com',
|
37
|
+
:template_name => :welcome
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'matches template name' do
|
42
|
+
Mailstro.should have_delivered(:welcome)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'matches contact email and template name' do
|
46
|
+
Mailstro.should have_delivered(
|
47
|
+
:to => 'a@a.com',
|
48
|
+
:template_name => :welcome,
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'does not match an invalid template name' do
|
53
|
+
Mailstro.should_not have_delivered(:build_failed)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'does not match an invalid contact email' do
|
57
|
+
Mailstro.should_not have_delivered(
|
58
|
+
:to => 'b@a.com',
|
59
|
+
:template_name => :welcome,
|
60
|
+
)
|
61
|
+
end
|
56
62
|
end
|
57
63
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
64
|
+
context "with a list delivery" do
|
65
|
+
before do
|
66
|
+
Mailstro.deliver(
|
67
|
+
:to => [:build_watchers, 'mailstro/mailstro-ruby'],
|
68
|
+
:template_name => :build_failed
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "matches against list type, name and template name" do
|
73
|
+
Mailstro.should have_delivered(
|
74
|
+
:to_list_type => :build_watchers,
|
75
|
+
:to_list_name => 'mailstro/mailstro-ruby',
|
76
|
+
:template_name => :build_failed,
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "does not match an invalid list type" do
|
81
|
+
Mailstro.should_not have_delivered(
|
82
|
+
:to_list_type => :customers,
|
83
|
+
:to_list_name => 'mailstro/mailstro-ruby',
|
84
|
+
:template_name => :build_failed,
|
85
|
+
)
|
86
|
+
end
|
87
|
+
|
88
|
+
it "does not match an invalid list name" do
|
89
|
+
Mailstro.should_not have_delivered(
|
90
|
+
:to_list_type => :build_watchers,
|
91
|
+
:to_list_name => 'mailstro/mailstro',
|
92
|
+
:template_name => :build_failed,
|
93
|
+
)
|
94
|
+
end
|
95
|
+
|
96
|
+
it "does not match an invalid template name" do
|
97
|
+
Mailstro.should_not have_delivered(
|
98
|
+
:to_list_type => :build_watchers,
|
99
|
+
:to_list_name => 'mailstro/mailstro-ruby',
|
100
|
+
:template_name => :welcome,
|
101
|
+
)
|
102
|
+
end
|
65
103
|
end
|
66
104
|
end
|
67
105
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailstro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -160,7 +160,6 @@ files:
|
|
160
160
|
- spec/mailstro/configuration_spec.rb
|
161
161
|
- spec/mailstro/test_strategy_spec.rb
|
162
162
|
- spec/mailstro/version_spec.rb
|
163
|
-
- spec/mailstro_spec.rb
|
164
163
|
- spec/spec_helper.rb
|
165
164
|
- spec/support/fixtures.rb
|
166
165
|
- spec/support/webmock.rb
|
@@ -198,7 +197,6 @@ test_files:
|
|
198
197
|
- spec/mailstro/configuration_spec.rb
|
199
198
|
- spec/mailstro/test_strategy_spec.rb
|
200
199
|
- spec/mailstro/version_spec.rb
|
201
|
-
- spec/mailstro_spec.rb
|
202
200
|
- spec/spec_helper.rb
|
203
201
|
- spec/support/fixtures.rb
|
204
202
|
- spec/support/webmock.rb
|
data/spec/mailstro_spec.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Mailstro do
|
4
|
-
|
5
|
-
after do
|
6
|
-
Mailstro.configuration = Mailstro::Configuration.new
|
7
|
-
end
|
8
|
-
|
9
|
-
describe ".configure" do
|
10
|
-
it "allows you to pass a block to configure Mailstro" do
|
11
|
-
Mailstro.configure do |config|
|
12
|
-
config.api_key = 'x'
|
13
|
-
config.api_endpoint = 'mailstro.dev'
|
14
|
-
end
|
15
|
-
|
16
|
-
Mailstro.configuration.api_endpoint.should == 'mailstro.dev'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|