pew_pew 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/.rspec +2 -0
- data/.yardopts +1 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +84 -0
- data/Rakefile +3 -0
- data/lib/pew_pew.rb +32 -0
- data/lib/pew_pew/client.rb +90 -0
- data/lib/pew_pew/config.rb +15 -0
- data/lib/pew_pew/domain.rb +9 -0
- data/lib/pew_pew/resource.rb +52 -0
- data/lib/pew_pew/resources/bounces.rb +41 -0
- data/lib/pew_pew/resources/campaigns.rb +141 -0
- data/lib/pew_pew/resources/complaints.rb +40 -0
- data/lib/pew_pew/resources/lists.rb +121 -0
- data/lib/pew_pew/resources/logs.rb +12 -0
- data/lib/pew_pew/resources/mailboxes.rb +41 -0
- data/lib/pew_pew/resources/messages.rb +37 -0
- data/lib/pew_pew/resources/routes.rb +57 -0
- data/lib/pew_pew/resources/stats.rb +12 -0
- data/lib/pew_pew/resources/unsubscribes.rb +43 -0
- data/lib/pew_pew/response.rb +11 -0
- data/lib/pew_pew/version.rb +3 -0
- data/pew_pew.gemspec +20 -0
- data/spec/fixtures/bounces.yml +144 -0
- data/spec/fixtures/campaigns.yml +368 -0
- data/spec/fixtures/complaints.yml +142 -0
- data/spec/fixtures/image.png +0 -0
- data/spec/fixtures/lists.yml +403 -0
- data/spec/fixtures/logs.yml +133 -0
- data/spec/fixtures/mailboxes.yml +141 -0
- data/spec/fixtures/messages.yml +196 -0
- data/spec/fixtures/mime.eml +34 -0
- data/spec/fixtures/routes.yml +225 -0
- data/spec/fixtures/stats.yml +61 -0
- data/spec/fixtures/unsubscribes.yml +219 -0
- data/spec/pew_pew/client_spec.rb +51 -0
- data/spec/pew_pew/config_spec.rb +38 -0
- data/spec/pew_pew/resource_spec.rb +46 -0
- data/spec/pew_pew/resources/bounces_spec.rb +78 -0
- data/spec/pew_pew/resources/campaigns_spec.rb +228 -0
- data/spec/pew_pew/resources/complaints_spec.rb +69 -0
- data/spec/pew_pew/resources/lists_spec.rb +283 -0
- data/spec/pew_pew/resources/logs_spec.rb +28 -0
- data/spec/pew_pew/resources/mailboxes_spec.rb +59 -0
- data/spec/pew_pew/resources/messages_spec.rb +53 -0
- data/spec/pew_pew/resources/routes_spec.rb +135 -0
- data/spec/pew_pew/resources/stats_spec.rb +26 -0
- data/spec/pew_pew/resources/unsubscribes_spec.rb +99 -0
- data/spec/pew_pew/response_spec.rb +21 -0
- data/spec/pew_pew_spec.rb +13 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/support/contexts/api_requests.rb +23 -0
- data/spec/support/contexts/domain_resource.rb +17 -0
- data/spec/support/vcr.rb +6 -0
- metadata +211 -0
@@ -0,0 +1,61 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.mailgun.net/v2/<%= domain %>/stats
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- PewPew Ruby Gem 0.0.1
|
12
|
+
Authorization:
|
13
|
+
- Basic <%= basic_auth %>
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 200
|
17
|
+
message:
|
18
|
+
headers:
|
19
|
+
server:
|
20
|
+
- nginx/1.0.14
|
21
|
+
date:
|
22
|
+
- Fri, 01 Jun 2012 20:01:54 GMT
|
23
|
+
content-type:
|
24
|
+
- application/json
|
25
|
+
connection:
|
26
|
+
- close
|
27
|
+
content-length:
|
28
|
+
- '1817'
|
29
|
+
content-disposition:
|
30
|
+
- inline
|
31
|
+
body:
|
32
|
+
encoding: US-ASCII
|
33
|
+
string: ! "{\n \"total_count\": 10, \n \"items\": [\n {\n \"total_count\":
|
34
|
+
11, \n \"created_at\": \"Fri, 01 Jun 2012 00:00:00 GMT\", \n \"tags\":
|
35
|
+
{}, \n \"id\": \"4fc837558393c1618263d76c\", \n \"event\": \"sent\"\n
|
36
|
+
\ }, \n {\n \"total_count\": 11, \n \"created_at\": \"Fri,
|
37
|
+
01 Jun 2012 00:00:00 GMT\", \n \"tags\": {}, \n \"id\": \"4fc837568393c1618263d76d\",
|
38
|
+
\n \"event\": \"delivered\"\n }, \n {\n \"total_count\": 6,
|
39
|
+
\n \"created_at\": \"Tue, 29 May 2012 00:00:00 GMT\", \n \"tags\":
|
40
|
+
{}, \n \"id\": \"4fc55a2e8393c161826132b5\", \n \"event\": \"sent\"\n
|
41
|
+
\ }, \n {\n \"total_count\": 6, \n \"created_at\": \"Tue, 29
|
42
|
+
May 2012 00:00:00 GMT\", \n \"tags\": {}, \n \"id\": \"4fc55a2f8393c161826132b7\",
|
43
|
+
\n \"event\": \"delivered\"\n }, \n {\n \"total_count\": 5,
|
44
|
+
\n \"created_at\": \"Sat, 26 May 2012 00:00:00 GMT\", \n \"tags\":
|
45
|
+
{}, \n \"id\": \"4fc01d548393c161825f53a7\", \n \"event\": \"sent\"\n
|
46
|
+
\ }, \n {\n \"total_count\": 5, \n \"created_at\": \"Sat, 26
|
47
|
+
May 2012 00:00:00 GMT\", \n \"tags\": {}, \n \"id\": \"4fc01d558393c161825f53aa\",
|
48
|
+
\n \"event\": \"delivered\"\n }, \n {\n \"total_count\": 4,
|
49
|
+
\n \"created_at\": \"Fri, 25 May 2012 00:00:00 GMT\", \n \"tags\":
|
50
|
+
{}, \n \"id\": \"4fc01c7c8393c161825f5233\", \n \"event\": \"sent\"\n
|
51
|
+
\ }, \n {\n \"total_count\": 4, \n \"created_at\": \"Fri, 25
|
52
|
+
May 2012 00:00:00 GMT\", \n \"tags\": {}, \n \"id\": \"4fc01c7d8393c161825f5235\",
|
53
|
+
\n \"event\": \"delivered\"\n }, \n {\n \"total_count\": 1,
|
54
|
+
\n \"created_at\": \"Thu, 24 May 2012 00:00:00 GMT\", \n \"tags\":
|
55
|
+
{}, \n \"id\": \"4fbdeaac8393c161825e5f99\", \n \"event\": \"sent\"\n
|
56
|
+
\ }, \n {\n \"total_count\": 1, \n \"created_at\": \"Thu, 24
|
57
|
+
May 2012 00:00:00 GMT\", \n \"tags\": {}, \n \"id\": \"4fbdeaad8393c161825e5f9a\",
|
58
|
+
\n \"event\": \"delivered\"\n }\n ]\n}"
|
59
|
+
http_version:
|
60
|
+
recorded_at: Fri, 01 Jun 2012 20:01:54 GMT
|
61
|
+
recorded_with: VCR 2.2.0
|
@@ -0,0 +1,219 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.mailgun.net/v2/<%= domain %>/unsubscribes
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: address=test%40example.com&tag=newsletter
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- PewPew Ruby Gem 0.0.1
|
12
|
+
Authorization:
|
13
|
+
- Basic <%= basic_auth %>
|
14
|
+
Content-Type:
|
15
|
+
- application/x-www-form-urlencoded
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message:
|
20
|
+
headers:
|
21
|
+
server:
|
22
|
+
- nginx/1.0.14
|
23
|
+
date:
|
24
|
+
- Sat, 02 Jun 2012 02:53:29 GMT
|
25
|
+
content-type:
|
26
|
+
- application/json
|
27
|
+
connection:
|
28
|
+
- close
|
29
|
+
content-length:
|
30
|
+
- '101'
|
31
|
+
content-disposition:
|
32
|
+
- inline
|
33
|
+
body:
|
34
|
+
encoding: US-ASCII
|
35
|
+
string: ! "{\n \"message\": \"Address has been added to the unsubscribes table\",
|
36
|
+
\n \"address\": \"test@example.com\"\n}"
|
37
|
+
http_version:
|
38
|
+
recorded_at: Sat, 02 Jun 2012 02:53:29 GMT
|
39
|
+
- request:
|
40
|
+
method: post
|
41
|
+
uri: https://api.mailgun.net/v2/<%= domain %>/unsubscribes
|
42
|
+
body:
|
43
|
+
encoding: US-ASCII
|
44
|
+
string: address=test%40example.com&tag=%2A
|
45
|
+
headers:
|
46
|
+
User-Agent:
|
47
|
+
- PewPew Ruby Gem 0.0.1
|
48
|
+
Authorization:
|
49
|
+
- Basic <%= basic_auth %>
|
50
|
+
Content-Type:
|
51
|
+
- application/x-www-form-urlencoded
|
52
|
+
response:
|
53
|
+
status:
|
54
|
+
code: 200
|
55
|
+
message:
|
56
|
+
headers:
|
57
|
+
server:
|
58
|
+
- nginx/1.0.14
|
59
|
+
date:
|
60
|
+
- Sat, 02 Jun 2012 02:54:37 GMT
|
61
|
+
content-type:
|
62
|
+
- application/json
|
63
|
+
connection:
|
64
|
+
- close
|
65
|
+
content-length:
|
66
|
+
- '100'
|
67
|
+
content-disposition:
|
68
|
+
- inline
|
69
|
+
body:
|
70
|
+
encoding: US-ASCII
|
71
|
+
string: ! "{\n \"message\": \"Address has been added to the unsubscribes table\",\n
|
72
|
+
\ \"address\": \"test@example.com\"\n}"
|
73
|
+
http_version:
|
74
|
+
recorded_at: Sat, 02 Jun 2012 02:54:37 GMT
|
75
|
+
- request:
|
76
|
+
method: get
|
77
|
+
uri: https://api.mailgun.net/v2/<%= domain %>/unsubscribes/test@example.com
|
78
|
+
body:
|
79
|
+
encoding: US-ASCII
|
80
|
+
string: ''
|
81
|
+
headers:
|
82
|
+
User-Agent:
|
83
|
+
- PewPew Ruby Gem 0.0.1
|
84
|
+
Authorization:
|
85
|
+
- Basic <%= basic_auth %>
|
86
|
+
response:
|
87
|
+
status:
|
88
|
+
code: 200
|
89
|
+
message:
|
90
|
+
headers:
|
91
|
+
server:
|
92
|
+
- nginx/1.0.14
|
93
|
+
date:
|
94
|
+
- Sat, 02 Jun 2012 02:55:33 GMT
|
95
|
+
content-type:
|
96
|
+
- application/json
|
97
|
+
connection:
|
98
|
+
- close
|
99
|
+
content-length:
|
100
|
+
- '368'
|
101
|
+
content-disposition:
|
102
|
+
- inline
|
103
|
+
body:
|
104
|
+
encoding: US-ASCII
|
105
|
+
string: ! "{\n \"total_count\": 2,\n \"items\": [\n {\n \"created_at\":
|
106
|
+
\"Sat, 02 Jun 2012 02:54:37 GMT\",\n \"tag\": \"*\",\n \"id\": \"4fc9806d8393c1618264c360\",\n
|
107
|
+
\ \"address\": \"test@example.com\"\n },\n {\n \"created_at\":
|
108
|
+
\"Sat, 02 Jun 2012 02:53:29 GMT\",\n \"tag\": \"newsletter\",\n \"id\":
|
109
|
+
\"4fc980298393c1618264c34d\",\n \"address\": \"test@example.com\"\n }\n
|
110
|
+
\ ]\n}"
|
111
|
+
http_version:
|
112
|
+
recorded_at: Sat, 02 Jun 2012 02:55:33 GMT
|
113
|
+
- request:
|
114
|
+
method: get
|
115
|
+
uri: https://api.mailgun.net/v2/<%= domain %>/unsubscribes
|
116
|
+
body:
|
117
|
+
encoding: US-ASCII
|
118
|
+
string: ''
|
119
|
+
headers:
|
120
|
+
User-Agent:
|
121
|
+
- PewPew Ruby Gem 0.0.1
|
122
|
+
Authorization:
|
123
|
+
- Basic <%= basic_auth %>
|
124
|
+
response:
|
125
|
+
status:
|
126
|
+
code: 200
|
127
|
+
message:
|
128
|
+
headers:
|
129
|
+
server:
|
130
|
+
- nginx/1.0.14
|
131
|
+
date:
|
132
|
+
- Sat, 02 Jun 2012 02:58:24 GMT
|
133
|
+
content-type:
|
134
|
+
- application/json
|
135
|
+
connection:
|
136
|
+
- close
|
137
|
+
content-length:
|
138
|
+
- '376'
|
139
|
+
content-disposition:
|
140
|
+
- inline
|
141
|
+
body:
|
142
|
+
encoding: US-ASCII
|
143
|
+
string: ! "{\n \"total_count\": 2, \n \"items\": [\n {\n \"created_at\":
|
144
|
+
\"Sat, 02 Jun 2012 02:54:37 GMT\", \n \"tag\": \"*\", \n \"id\":
|
145
|
+
\"4fc9806d8393c1618264c360\", \n \"address\": \"test@example.com\"\n
|
146
|
+
\ }, \n {\n \"created_at\": \"Sat, 02 Jun 2012 02:53:29 GMT\", \n
|
147
|
+
\ \"tag\": \"newsletter\", \n \"id\": \"4fc980298393c1618264c34d\",
|
148
|
+
\n \"address\": \"test@example.com\"\n }\n ]\n}"
|
149
|
+
http_version:
|
150
|
+
recorded_at: Sat, 02 Jun 2012 02:58:24 GMT
|
151
|
+
- request:
|
152
|
+
method: delete
|
153
|
+
uri: https://api.mailgun.net/v2/<%= domain %>/unsubscribes/4fc9806d8393c1618264c360
|
154
|
+
body:
|
155
|
+
encoding: US-ASCII
|
156
|
+
string: ''
|
157
|
+
headers:
|
158
|
+
User-Agent:
|
159
|
+
- PewPew Ruby Gem 0.0.1
|
160
|
+
Authorization:
|
161
|
+
- Basic <%= basic_auth %>
|
162
|
+
response:
|
163
|
+
status:
|
164
|
+
code: 200
|
165
|
+
message:
|
166
|
+
headers:
|
167
|
+
server:
|
168
|
+
- nginx/1.0.14
|
169
|
+
date:
|
170
|
+
- Sat, 02 Jun 2012 02:59:33 GMT
|
171
|
+
content-type:
|
172
|
+
- application/json
|
173
|
+
connection:
|
174
|
+
- close
|
175
|
+
content-length:
|
176
|
+
- '94'
|
177
|
+
content-disposition:
|
178
|
+
- inline
|
179
|
+
body:
|
180
|
+
encoding: US-ASCII
|
181
|
+
string: ! "{\n \"message\": \"Unsubscribe event has been removed\",\n \"address\":
|
182
|
+
\"4fc9806d8393c1618264c360\"\n}"
|
183
|
+
http_version:
|
184
|
+
recorded_at: Sat, 02 Jun 2012 02:59:33 GMT
|
185
|
+
- request:
|
186
|
+
method: delete
|
187
|
+
uri: https://api.mailgun.net/v2/<%= domain %>/unsubscribes/test@example.com
|
188
|
+
body:
|
189
|
+
encoding: US-ASCII
|
190
|
+
string: ''
|
191
|
+
headers:
|
192
|
+
User-Agent:
|
193
|
+
- PewPew Ruby Gem 0.0.1
|
194
|
+
Authorization:
|
195
|
+
- Basic <%= basic_auth %>
|
196
|
+
response:
|
197
|
+
status:
|
198
|
+
code: 200
|
199
|
+
message:
|
200
|
+
headers:
|
201
|
+
server:
|
202
|
+
- nginx/1.0.14
|
203
|
+
date:
|
204
|
+
- Sat, 02 Jun 2012 02:59:52 GMT
|
205
|
+
content-type:
|
206
|
+
- application/json
|
207
|
+
connection:
|
208
|
+
- close
|
209
|
+
content-length:
|
210
|
+
- '86'
|
211
|
+
content-disposition:
|
212
|
+
- inline
|
213
|
+
body:
|
214
|
+
encoding: US-ASCII
|
215
|
+
string: ! "{\n \"message\": \"Unsubscribe event has been removed\",\n \"address\":
|
216
|
+
\"test@example.com\"\n}"
|
217
|
+
http_version:
|
218
|
+
recorded_at: Sat, 02 Jun 2012 02:59:52 GMT
|
219
|
+
recorded_with: VCR 2.2.0
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PewPew::Client do
|
4
|
+
context '#config' do
|
5
|
+
subject { described_class.new.config }
|
6
|
+
|
7
|
+
its(:adapter) { should == Faraday.default_adapter }
|
8
|
+
its(:base_uri) { should == PewPew::Config::BASE_URI }
|
9
|
+
its(:user_agent) { should == PewPew::Config::USER_AGENT }
|
10
|
+
|
11
|
+
its(:api_key) { should be_nil }
|
12
|
+
its(:domain) { should be_nil }
|
13
|
+
end
|
14
|
+
|
15
|
+
context '#configure' do
|
16
|
+
subject do
|
17
|
+
described_class.new.configure do |config|
|
18
|
+
config.adapter = :typhoeus
|
19
|
+
config.base_uri = 'https://api.mailgun.com/v2'
|
20
|
+
config.user_agent = 'A PewPew Application'
|
21
|
+
|
22
|
+
config.api_key = 'key-02n9f3ijl9sm9u97-8p7r-d7-15q-ui1'
|
23
|
+
config.domain = 'pewpew.mailgun.org'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
its(:adapter) { should == :typhoeus }
|
28
|
+
its(:base_uri) { should == 'https://api.mailgun.com/v2' }
|
29
|
+
its(:user_agent) { should == 'A PewPew Application' }
|
30
|
+
|
31
|
+
its(:api_key) { should == 'key-02n9f3ijl9sm9u97-8p7r-d7-15q-ui1' }
|
32
|
+
its(:domain) { should == 'pewpew.mailgun.org' }
|
33
|
+
end
|
34
|
+
|
35
|
+
{
|
36
|
+
bounces: PewPew::Resources::Bounces,
|
37
|
+
campaigns: PewPew::Resources::Campaigns,
|
38
|
+
complaints: PewPew::Resources::Complaints,
|
39
|
+
lists: PewPew::Resources::Lists,
|
40
|
+
logs: PewPew::Resources::Logs,
|
41
|
+
mailboxes: PewPew::Resources::Mailboxes,
|
42
|
+
messages: PewPew::Resources::Messages,
|
43
|
+
routes: PewPew::Resources::Routes,
|
44
|
+
stats: PewPew::Resources::Stats,
|
45
|
+
unsubscribes: PewPew::Resources::Unsubscribes,
|
46
|
+
}.each do |method, resource_class|
|
47
|
+
context "##{method}" do
|
48
|
+
specify { subject.send(method).should be_a(resource_class) }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PewPew::Config do
|
4
|
+
{
|
5
|
+
BASE_URI: 'https://api.mailgun.net/v2',
|
6
|
+
USER_AGENT: "PewPew Ruby Gem #{PewPew::VERSION}",
|
7
|
+
USERNAME: 'api'
|
8
|
+
}.each do |constant, value|
|
9
|
+
context constant do
|
10
|
+
subject { described_class.const_get(constant) }
|
11
|
+
|
12
|
+
it { should == value }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
subject { Class.new { include PewPew::Config }.new }
|
17
|
+
|
18
|
+
context 'defaults' do
|
19
|
+
its(:api_key) { should be_nil }
|
20
|
+
its(:domain) { should be_nil }
|
21
|
+
end
|
22
|
+
|
23
|
+
context '#api_key=' do
|
24
|
+
specify do
|
25
|
+
expect {
|
26
|
+
subject.api_key = 'key-02n9f3ijl9sm9u97-8p7r-d7-15q-ui1'
|
27
|
+
}.to change(subject, :api_key).to('key-02n9f3ijl9sm9u97-8p7r-d7-15q-ui1')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context '#domain=' do
|
32
|
+
specify do
|
33
|
+
expect {
|
34
|
+
subject.domain = 'pewpew.mailgun.org'
|
35
|
+
}.to change(subject, :domain).to('pewpew.mailgun.org')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PewPew::Resource do
|
4
|
+
let(:client) { PewPew::Client.new }
|
5
|
+
let(:resource) { Class.new { include PewPew::Resource }.new(client) }
|
6
|
+
|
7
|
+
context '#connection' do
|
8
|
+
subject { resource.send(:connection) }
|
9
|
+
|
10
|
+
context 'middleware' do
|
11
|
+
let(:handlers) { subject.builder.handlers }
|
12
|
+
|
13
|
+
[
|
14
|
+
PewPew::Resource::ResponseDecorator,
|
15
|
+
FaradayMiddleware::Mashify,
|
16
|
+
FaradayMiddleware::ParseJson,
|
17
|
+
Faraday::Request::Multipart,
|
18
|
+
Faraday::Request::UrlEncoded,
|
19
|
+
Faraday::Adapter::NetHttp
|
20
|
+
].each.with_index do |middleware, index|
|
21
|
+
it "uses #{middleware}" do
|
22
|
+
handlers.index(middleware).should == index
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe PewPew::Resource::ResponseDecorator do
|
30
|
+
it { should be_a(Faraday::Response::Middleware) }
|
31
|
+
|
32
|
+
it 'converts an array response into a mash' do
|
33
|
+
env = { body: [:response] }
|
34
|
+
subject.on_complete(env)
|
35
|
+
env[:body].total_count.should == 1
|
36
|
+
env[:body].items.should == [:response]
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'stores the request status on the response body' do
|
40
|
+
env = { body: PewPew::Response.new, status: 200 }
|
41
|
+
|
42
|
+
expect {
|
43
|
+
subject.on_complete(env)
|
44
|
+
}.to change(env[:body], :status).from(nil).to(200)
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PewPew::Resources::Bounces, :resource, :domain do
|
4
|
+
let(:resource) { described_class.new(client) }
|
5
|
+
|
6
|
+
context '#all' do
|
7
|
+
let(:response) { resource.all }
|
8
|
+
|
9
|
+
subject { response }
|
10
|
+
|
11
|
+
specify { should be_success }
|
12
|
+
|
13
|
+
its(:status) { should == 200 }
|
14
|
+
its(:total_count) { should == 1 }
|
15
|
+
|
16
|
+
context 'item' do
|
17
|
+
subject { response.items.first }
|
18
|
+
|
19
|
+
its(:address) { should == 'test@example.com' }
|
20
|
+
its(:code) { should == '554' }
|
21
|
+
its(:error) { should == 'Relay access denied' }
|
22
|
+
its(:created_at) { should == 'Sat, 02 Jun 2012 07:24:08 GMT' }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context '#find' do
|
27
|
+
let(:response) { resource.find('test@example.com') }
|
28
|
+
|
29
|
+
subject { response }
|
30
|
+
|
31
|
+
specify { should be_success }
|
32
|
+
|
33
|
+
its(:status) { should == 200 }
|
34
|
+
|
35
|
+
context 'bounce' do
|
36
|
+
subject { response.bounce }
|
37
|
+
|
38
|
+
its(:address) { should == 'test@example.com' }
|
39
|
+
its(:code) { should == '554' }
|
40
|
+
its(:error) { should == 'Relay access denied' }
|
41
|
+
its(:created_at) { should == 'Sat, 02 Jun 2012 07:24:08 GMT' }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
context '#create' do
|
46
|
+
let(:params) do
|
47
|
+
{
|
48
|
+
address: 'test@example.com',
|
49
|
+
code: 554,
|
50
|
+
error: 'Relay access denied',
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
let(:response) { resource.create(params) }
|
55
|
+
|
56
|
+
subject { response }
|
57
|
+
|
58
|
+
specify { should be_success }
|
59
|
+
|
60
|
+
its(:status) { should == 200 }
|
61
|
+
its(:message) { should == 'Address has been added to the bounces table' }
|
62
|
+
|
63
|
+
its(:address) { should == 'test@example.com' }
|
64
|
+
end
|
65
|
+
|
66
|
+
context '#remove' do
|
67
|
+
subject { response }
|
68
|
+
|
69
|
+
let(:response) { resource.remove('test@example.com') }
|
70
|
+
|
71
|
+
specify { should be_success }
|
72
|
+
|
73
|
+
its(:status) { should == 200 }
|
74
|
+
its(:message) { should == 'Bounced address has been removed' }
|
75
|
+
|
76
|
+
its(:address) { should == 'test@example.com' }
|
77
|
+
end
|
78
|
+
end
|