pew_pew 0.0.2 → 0.1.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 +7 -0
- data/.github/workflows/build.yml +36 -0
- data/.gitignore +1 -0
- data/.rspec +1 -2
- data/Appraisals +7 -0
- data/CHANGELOG.md +7 -2
- data/README.md +6 -0
- data/gemfiles/faraday_2.0.gemfile +7 -0
- data/gemfiles/faraday_2.7.gemfile +7 -0
- data/lib/pew_pew/resource.rb +12 -10
- data/lib/pew_pew/version.rb +1 -1
- data/pew_pew.gemspec +20 -16
- data/spec/fixtures/messages.yml +153 -111
- data/spec/pew_pew/client_spec.rb +47 -39
- data/spec/pew_pew/config_spec.rb +28 -28
- data/spec/pew_pew/resource_spec.rb +42 -36
- data/spec/pew_pew/resources/bounces_spec.rb +57 -53
- data/spec/pew_pew/resources/campaigns_spec.rb +169 -167
- data/spec/pew_pew/resources/complaints_spec.rb +49 -45
- data/spec/pew_pew/resources/lists_spec.rb +209 -195
- data/spec/pew_pew/resources/logs_spec.rb +30 -25
- data/spec/pew_pew/resources/mailboxes_spec.rb +41 -39
- data/spec/pew_pew/resources/messages_spec.rb +49 -45
- data/spec/pew_pew/resources/routes_spec.rb +105 -103
- data/spec/pew_pew/resources/stats_spec.rb +19 -17
- data/spec/pew_pew/resources/unsubscribes_spec.rb +71 -65
- data/spec/pew_pew/response_spec.rb +25 -13
- data/spec/pew_pew_spec.rb +4 -5
- data/spec/spec_helper.rb +1 -1
- data/spec/support/contexts/api_requests.rb +5 -3
- data/spec/support/contexts/domain_resource.rb +1 -1
- data/spec/support/vcr.rb +36 -1
- metadata +84 -50
@@ -1,53 +1,57 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
1
|
+
module PewPew
|
2
|
+
module Resources
|
3
|
+
RSpec.describe Messages, :resource, :domain do
|
4
|
+
let(:resource) { described_class.new(client) }
|
5
|
+
|
6
|
+
context '#send_email' do
|
7
|
+
let(:params) {
|
8
|
+
{
|
9
|
+
to: 'pewpew@devoh.com',
|
10
|
+
from: 'pewpew@devoh.com',
|
11
|
+
subject: 'Test',
|
12
|
+
text: 'This is a test message.'
|
13
|
+
}
|
14
|
+
}
|
15
|
+
|
16
|
+
let(:file) {
|
17
|
+
Faraday::UploadIO.new('spec/fixtures/image.png', 'image/png')
|
18
|
+
}
|
19
|
+
|
20
|
+
subject { resource.send_email(params) }
|
21
|
+
|
22
|
+
specify { should be_success }
|
23
|
+
|
24
|
+
context 'with an attachment' do
|
25
|
+
before do
|
26
|
+
params.merge!(attachment: file)
|
27
|
+
end
|
28
|
+
|
29
|
+
specify { should be_success }
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'with an inline attachment' do
|
33
|
+
before do
|
34
|
+
params.merge!(
|
35
|
+
html: "#{params[:text]} <img src=\"cid:image.png\">",
|
36
|
+
inline: file
|
37
|
+
)
|
38
|
+
end
|
39
|
+
|
40
|
+
specify { should be_success }
|
41
|
+
end
|
25
42
|
end
|
26
43
|
|
27
|
-
|
28
|
-
|
44
|
+
context '#send_mime' do
|
45
|
+
let(:message) do
|
46
|
+
Faraday::UploadIO.new('spec/fixtures/mime.eml', 'message/rfc822')
|
47
|
+
end
|
29
48
|
|
30
|
-
|
31
|
-
before do
|
32
|
-
params.merge!(
|
33
|
-
html: "#{params[:text]} <img src=\"cid:image.png\">",
|
34
|
-
inline: file
|
35
|
-
)
|
36
|
-
end
|
49
|
+
let(:params) { { to: 'pewpew@devoh.com', message: message } }
|
37
50
|
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
51
|
+
subject { resource.send_mime(params) }
|
41
52
|
|
42
|
-
|
43
|
-
|
44
|
-
Faraday::UploadIO.new('spec/fixtures/mime.eml', 'message/rfc822')
|
53
|
+
specify { should be_success }
|
54
|
+
end
|
45
55
|
end
|
46
|
-
|
47
|
-
let(:params) { { to: 'pewpew@devoh.com', message: message } }
|
48
|
-
|
49
|
-
subject { resource.send_mime(params) }
|
50
|
-
|
51
|
-
specify { should be_success }
|
52
56
|
end
|
53
57
|
end
|
@@ -1,135 +1,137 @@
|
|
1
|
-
|
1
|
+
module PewPew
|
2
|
+
module Resources
|
3
|
+
RSpec.describe Routes, :resource do
|
4
|
+
let(:resource) { described_class.new(client) }
|
2
5
|
|
3
|
-
|
4
|
-
|
6
|
+
context '#all' do
|
7
|
+
let(:response) { resource.all }
|
5
8
|
|
6
|
-
|
7
|
-
let(:response) { resource.all }
|
9
|
+
subject { response }
|
8
10
|
|
9
|
-
|
11
|
+
specify { should be_success }
|
10
12
|
|
11
|
-
|
13
|
+
its(:status) { should == 200 }
|
14
|
+
its(:total_count) { should == 1 }
|
12
15
|
|
13
|
-
|
14
|
-
|
16
|
+
context 'item' do
|
17
|
+
subject { response.items.first }
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
its(:created_at) { should == 'Fri, 01 Jun 2012 05:15:52 GMT' }
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context '#find' do
|
29
|
-
let(:response) { resource.find('4fc850083533542f7704bc05') }
|
19
|
+
its(:id) { should == '4fc850083533542f7704bc05' }
|
20
|
+
its(:priority) { should == 1 }
|
21
|
+
its(:description) { should == 'Forward Gmail' }
|
22
|
+
its(:expression) { should == "match_recipient('.*@gmail.com')" }
|
23
|
+
its(:actions) { should == ["forward('gmail@example.com')"] }
|
24
|
+
its(:created_at) { should == 'Fri, 01 Jun 2012 05:15:52 GMT' }
|
25
|
+
end
|
26
|
+
end
|
30
27
|
|
31
|
-
|
28
|
+
context '#find' do
|
29
|
+
let(:response) { resource.find('4fc850083533542f7704bc05') }
|
32
30
|
|
33
|
-
|
31
|
+
subject { response }
|
34
32
|
|
35
|
-
|
33
|
+
specify { should be_success }
|
36
34
|
|
37
|
-
|
38
|
-
subject { response.route }
|
35
|
+
its(:status) { should == 200 }
|
39
36
|
|
40
|
-
|
41
|
-
|
42
|
-
its(:description) { should == 'Forward Gmail' }
|
43
|
-
its(:expression) { should == "match_recipient('.*@gmail.com')" }
|
44
|
-
its(:actions) { should == ["forward('gmail@example.com')"] }
|
45
|
-
its(:created_at) { should == 'Fri, 01 Jun 2012 05:15:52 GMT' }
|
46
|
-
end
|
47
|
-
end
|
37
|
+
context 'route' do
|
38
|
+
subject { response.route }
|
48
39
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
40
|
+
its(:id) { should == '4fc850083533542f7704bc05' }
|
41
|
+
its(:priority) { should == 1 }
|
42
|
+
its(:description) { should == 'Forward Gmail' }
|
43
|
+
its(:expression) { should == "match_recipient('.*@gmail.com')" }
|
44
|
+
its(:actions) { should == ["forward('gmail@example.com')"] }
|
45
|
+
its(:created_at) { should == 'Fri, 01 Jun 2012 05:15:52 GMT' }
|
46
|
+
end
|
47
|
+
end
|
58
48
|
|
59
|
-
|
49
|
+
context '#create' do
|
50
|
+
let(:params) do
|
51
|
+
{
|
52
|
+
priority: 1,
|
53
|
+
description: 'Forward Gmail',
|
54
|
+
expression: "match_recipient('.*@gmail.com')",
|
55
|
+
action: "forward('gmail@example.com')"
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
let(:response) { resource.create(params) }
|
60
|
+
|
61
|
+
subject { response }
|
62
|
+
|
63
|
+
context 'with a single action' do
|
64
|
+
specify { should be_success }
|
65
|
+
|
66
|
+
its(:status) { should == 200 }
|
67
|
+
its(:message) { should == 'Route has been created' }
|
68
|
+
|
69
|
+
context 'route' do
|
70
|
+
subject { response.route }
|
71
|
+
|
72
|
+
its(:id) { should == '4fc850083533542f7704bc05' }
|
73
|
+
its(:priority) { should == params[:priority] }
|
74
|
+
its(:description) { should == params[:description] }
|
75
|
+
its(:expression) { should == params[:expression] }
|
76
|
+
its(:actions) { should == [params[:action]] }
|
77
|
+
its(:created_at) { should == 'Fri, 01 Jun 2012 05:15:52 GMT' }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'with multiple actions' do
|
82
|
+
before do
|
83
|
+
params.merge!(action: [params[:action], 'stop()'])
|
84
|
+
end
|
85
|
+
|
86
|
+
specify { should be_success }
|
87
|
+
|
88
|
+
its(:status) { should == 200 }
|
89
|
+
its(:message) { should == 'Route has been created' }
|
90
|
+
|
91
|
+
context 'route' do
|
92
|
+
subject { response.route }
|
93
|
+
|
94
|
+
its(:id) { should == '4fc854bd9d12a36fc504d4b3' }
|
95
|
+
its(:priority) { should == params[:priority] }
|
96
|
+
its(:description) { should == params[:description] }
|
97
|
+
its(:expression) { should == params[:expression] }
|
98
|
+
its(:actions) { should == params[:action] }
|
99
|
+
its(:created_at) { should == 'Fri, 01 Jun 2012 05:35:57 GMT' }
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
60
103
|
|
61
|
-
|
104
|
+
context '#update' do
|
105
|
+
let(:params) { { priority: 2 } }
|
106
|
+
let(:response) { resource.update('4fc850083533542f7704bc05', params) }
|
62
107
|
|
63
|
-
|
64
|
-
specify { should be_success }
|
108
|
+
subject { response }
|
65
109
|
|
66
|
-
|
67
|
-
its(:message) { should == 'Route has been created' }
|
110
|
+
specify { should be_success }
|
68
111
|
|
69
|
-
|
70
|
-
|
112
|
+
its(:status) { should == 200 }
|
113
|
+
its(:message) { should == 'Route has been updated' }
|
71
114
|
|
72
115
|
its(:id) { should == '4fc850083533542f7704bc05' }
|
73
116
|
its(:priority) { should == params[:priority] }
|
74
|
-
its(:description) { should ==
|
75
|
-
its(:expression) { should ==
|
76
|
-
its(:actions) { should == [
|
117
|
+
its(:description) { should == 'Forward Gmail' }
|
118
|
+
its(:expression) { should == "match_recipient('.*@gmail.com')" }
|
119
|
+
its(:actions) { should == ["forward('gmail@example.com')"] }
|
77
120
|
its(:created_at) { should == 'Fri, 01 Jun 2012 05:15:52 GMT' }
|
78
121
|
end
|
79
|
-
end
|
80
122
|
|
81
|
-
|
82
|
-
|
83
|
-
params.merge!(action: [params[:action], 'stop()'])
|
84
|
-
end
|
123
|
+
context '#remove' do
|
124
|
+
let(:response) { resource.remove('4fc854bd9d12a36fc504d4b3') }
|
85
125
|
|
86
|
-
|
126
|
+
subject { response }
|
87
127
|
|
88
|
-
|
89
|
-
its(:message) { should == 'Route has been created' }
|
128
|
+
specify { should be_success }
|
90
129
|
|
91
|
-
|
92
|
-
|
130
|
+
its(:status) { should == 200 }
|
131
|
+
its(:message) { should == 'Route has been deleted' }
|
93
132
|
|
94
133
|
its(:id) { should == '4fc854bd9d12a36fc504d4b3' }
|
95
|
-
its(:priority) { should == params[:priority] }
|
96
|
-
its(:description) { should == params[:description] }
|
97
|
-
its(:expression) { should == params[:expression] }
|
98
|
-
its(:actions) { should == params[:action] }
|
99
|
-
its(:created_at) { should == 'Fri, 01 Jun 2012 05:35:57 GMT' }
|
100
134
|
end
|
101
135
|
end
|
102
136
|
end
|
103
|
-
|
104
|
-
context '#update' do
|
105
|
-
let(:params) { { priority: 2 } }
|
106
|
-
let(:response) { resource.update('4fc850083533542f7704bc05', params) }
|
107
|
-
|
108
|
-
subject { response }
|
109
|
-
|
110
|
-
specify { should be_success }
|
111
|
-
|
112
|
-
its(:status) { should == 200 }
|
113
|
-
its(:message) { should == 'Route has been updated' }
|
114
|
-
|
115
|
-
its(:id) { should == '4fc850083533542f7704bc05' }
|
116
|
-
its(:priority) { should == params[:priority] }
|
117
|
-
its(:description) { should == 'Forward Gmail' }
|
118
|
-
its(:expression) { should == "match_recipient('.*@gmail.com')" }
|
119
|
-
its(:actions) { should == ["forward('gmail@example.com')"] }
|
120
|
-
its(:created_at) { should == 'Fri, 01 Jun 2012 05:15:52 GMT' }
|
121
|
-
end
|
122
|
-
|
123
|
-
context '#remove' do
|
124
|
-
let(:response) { resource.remove('4fc854bd9d12a36fc504d4b3') }
|
125
|
-
|
126
|
-
subject { response }
|
127
|
-
|
128
|
-
specify { should be_success }
|
129
|
-
|
130
|
-
its(:status) { should == 200 }
|
131
|
-
its(:message) { should == 'Route has been deleted' }
|
132
|
-
|
133
|
-
its(:id) { should == '4fc854bd9d12a36fc504d4b3' }
|
134
|
-
end
|
135
137
|
end
|
@@ -1,26 +1,28 @@
|
|
1
|
-
|
1
|
+
module PewPew
|
2
|
+
module Resources
|
3
|
+
RSpec.describe Stats, :resource, :domain do
|
4
|
+
let(:resource) { described_class.new(client) }
|
2
5
|
|
3
|
-
|
4
|
-
|
6
|
+
context '#all' do
|
7
|
+
let(:response) { resource.all }
|
5
8
|
|
6
|
-
|
7
|
-
let(:response) { resource.all }
|
9
|
+
subject { response }
|
8
10
|
|
9
|
-
|
11
|
+
specify { should be_success }
|
10
12
|
|
11
|
-
|
13
|
+
its(:status) { should == 200 }
|
14
|
+
its(:total_count) { should == 10 }
|
12
15
|
|
13
|
-
|
14
|
-
|
16
|
+
context 'item' do
|
17
|
+
subject { response.items.first }
|
15
18
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
its(:total_count) { should == 11 }
|
19
|
+
its(:created_at) { should == 'Fri, 01 Jun 2012 00:00:00 GMT' }
|
20
|
+
its(:event) { should == 'sent' }
|
21
|
+
its(:id) { should == '4fc837558393c1618263d76c' }
|
22
|
+
its(:tags) { should == {} }
|
23
|
+
its(:total_count) { should == 11 }
|
24
|
+
end
|
25
|
+
end
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
@@ -1,99 +1,105 @@
|
|
1
|
-
|
1
|
+
module PewPew
|
2
|
+
module Resources
|
3
|
+
RSpec.describe Unsubscribes, :resource, :domain do
|
4
|
+
let(:resource) { described_class.new(client) }
|
2
5
|
|
3
|
-
|
4
|
-
|
6
|
+
context '#all' do
|
7
|
+
let(:response) { resource.all }
|
5
8
|
|
6
|
-
|
7
|
-
let(:response) { resource.all }
|
9
|
+
subject { response }
|
8
10
|
|
9
|
-
|
11
|
+
specify { should be_success }
|
10
12
|
|
11
|
-
|
13
|
+
its(:status) { should == 200 }
|
14
|
+
its(:total_count) { should == 2 }
|
12
15
|
|
13
|
-
|
14
|
-
|
16
|
+
context 'item' do
|
17
|
+
subject { response.items.first }
|
15
18
|
|
16
|
-
|
17
|
-
|
19
|
+
its(:address) { should == 'test@example.com' }
|
20
|
+
its(:created_at) { should == 'Sat, 02 Jun 2012 02:54:37 GMT' }
|
21
|
+
its(:id) { should == '4fc9806d8393c1618264c360' }
|
22
|
+
its(:tag) { should == '*' }
|
23
|
+
end
|
24
|
+
end
|
18
25
|
|
19
|
-
|
20
|
-
|
21
|
-
its(:id) { should == '4fc9806d8393c1618264c360' }
|
22
|
-
its(:tag) { should == '*' }
|
23
|
-
end
|
24
|
-
end
|
26
|
+
context '#find' do
|
27
|
+
let(:response) { resource.find('test@example.com') }
|
25
28
|
|
26
|
-
|
27
|
-
let(:response) { resource.find('test@example.com') }
|
29
|
+
subject { response }
|
28
30
|
|
29
|
-
|
31
|
+
specify { should be_success }
|
30
32
|
|
31
|
-
|
33
|
+
its(:status) { should == 200 }
|
34
|
+
its(:total_count) { should == 2 }
|
32
35
|
|
33
|
-
|
34
|
-
|
36
|
+
context 'unsubscribe' do
|
37
|
+
subject { response.items.first }
|
35
38
|
|
36
|
-
|
37
|
-
|
39
|
+
its(:address) { should == 'test@example.com' }
|
40
|
+
its(:created_at) { should == 'Sat, 02 Jun 2012 02:54:37 GMT' }
|
41
|
+
its(:id) { should == '4fc9806d8393c1618264c360' }
|
42
|
+
its(:tag) { should == '*' }
|
43
|
+
end
|
44
|
+
end
|
38
45
|
|
39
|
-
|
40
|
-
|
41
|
-
its(:id) { should == '4fc9806d8393c1618264c360' }
|
42
|
-
its(:tag) { should == '*' }
|
43
|
-
end
|
44
|
-
end
|
46
|
+
context '#create' do
|
47
|
+
let(:response) { resource.create(params) }
|
45
48
|
|
46
|
-
|
47
|
-
let(:response) { resource.create(params) }
|
49
|
+
subject { response }
|
48
50
|
|
49
|
-
|
51
|
+
context 'with a tag' do
|
52
|
+
let(:params) { { address: 'test@example.com', tag: 'newsletter' } }
|
50
53
|
|
51
|
-
|
52
|
-
let(:params) { { address: 'test@example.com', tag: 'newsletter' } }
|
54
|
+
specify { should be_success }
|
53
55
|
|
54
|
-
|
56
|
+
its(:status) { should == 200 }
|
57
|
+
its(:message) {
|
58
|
+
should == 'Address has been added to the unsubscribes table'
|
59
|
+
}
|
55
60
|
|
56
|
-
|
57
|
-
|
61
|
+
its(:address) { should == 'test@example.com' }
|
62
|
+
end
|
58
63
|
|
59
|
-
|
60
|
-
|
64
|
+
context 'without a tag' do
|
65
|
+
let(:params) { { address: 'test@example.com' } }
|
61
66
|
|
62
|
-
|
63
|
-
let(:params) { { address: 'test@example.com' } }
|
67
|
+
specify { should be_success }
|
64
68
|
|
65
|
-
|
69
|
+
its(:status) { should == 200 }
|
70
|
+
its(:message) {
|
71
|
+
should == 'Address has been added to the unsubscribes table'
|
72
|
+
}
|
66
73
|
|
67
|
-
|
68
|
-
|
74
|
+
its(:address) { should == 'test@example.com' }
|
75
|
+
end
|
76
|
+
end
|
69
77
|
|
70
|
-
|
71
|
-
|
72
|
-
end
|
78
|
+
context '#remove' do
|
79
|
+
subject { response }
|
73
80
|
|
74
|
-
|
75
|
-
|
81
|
+
context 'with an address' do
|
82
|
+
let(:response) { resource.remove('test@example.com') }
|
76
83
|
|
77
|
-
|
78
|
-
let(:response) { resource.remove('test@example.com') }
|
84
|
+
specify { should be_success }
|
79
85
|
|
80
|
-
|
86
|
+
its(:status) { should == 200 }
|
87
|
+
its(:message) { should == 'Unsubscribe event has been removed' }
|
81
88
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
its(:address) { should == 'test@example.com' }
|
86
|
-
end
|
89
|
+
its(:address) { should == 'test@example.com' }
|
90
|
+
end
|
87
91
|
|
88
|
-
|
89
|
-
|
92
|
+
context 'with an unsubscribe event ID' do
|
93
|
+
let(:response) { resource.remove('4fc9806d8393c1618264c360') }
|
90
94
|
|
91
|
-
|
95
|
+
specify { should be_success }
|
92
96
|
|
93
|
-
|
94
|
-
|
97
|
+
its(:status) { should == 200 }
|
98
|
+
its(:message) { should == 'Unsubscribe event has been removed' }
|
95
99
|
|
96
|
-
|
100
|
+
its(:address) { should == '4fc9806d8393c1618264c360' }
|
101
|
+
end
|
102
|
+
end
|
97
103
|
end
|
98
104
|
end
|
99
105
|
end
|
@@ -1,21 +1,33 @@
|
|
1
|
-
|
1
|
+
module PewPew
|
2
|
+
RSpec.describe Response do
|
3
|
+
it { should be_a Hashie::Mash }
|
2
4
|
|
3
|
-
|
4
|
-
|
5
|
+
context '#count' do
|
6
|
+
subject(:response) { described_class.new(count: 2) }
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
-
|
8
|
+
it 'returns the value of the count attribute' do
|
9
|
+
expect(response.count).to eq 2
|
10
|
+
end
|
9
11
|
end
|
10
|
-
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
context '#success?' do
|
14
|
+
subject(:response) { described_class.new(status: status) }
|
15
|
+
|
16
|
+
context 'when the status is 200' do
|
17
|
+
let(:status) { 200 }
|
18
|
+
|
19
|
+
it 'returns true' do
|
20
|
+
expect(response).to be_success
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when the status is 400' do
|
25
|
+
let(:status) { 400 }
|
16
26
|
|
17
|
-
|
18
|
-
|
27
|
+
it 'returns false' do
|
28
|
+
expect(response).to_not be_success
|
29
|
+
end
|
30
|
+
end
|
19
31
|
end
|
20
32
|
end
|
21
33
|
end
|
data/spec/pew_pew_spec.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
describe PewPew do
|
1
|
+
RSpec.describe PewPew do
|
4
2
|
[
|
5
3
|
Relax::Client.instance_methods(false),
|
6
4
|
PewPew::Client.instance_methods(false)
|
7
5
|
].flatten.each do |method|
|
8
6
|
it "delegates .#{method} to .client" do
|
9
|
-
described_class.send(:client).
|
10
|
-
|
7
|
+
expect(described_class.send(:client)).to receive(method)
|
8
|
+
|
9
|
+
described_class.send method
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'pew_pew'
|
2
|
+
require 'rspec/its'
|
2
3
|
|
3
4
|
# These defaults are only for use when developing this client library. Please
|
4
5
|
# do not use them in your own applications. Sign up for your own account here:
|
@@ -7,7 +8,6 @@ ENV['MAILGUN_API_KEY'] ||= 'key-02n9f3ijl9sm9u97-8p7r-d7-15q-ui1'
|
|
7
8
|
ENV['MAILGUN_DOMAIN'] ||= 'pewpew.mailgun.org'
|
8
9
|
|
9
10
|
RSpec.configure do |config|
|
10
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
11
11
|
config.run_all_when_everything_filtered = true
|
12
12
|
config.filter_run :focus
|
13
13
|
end
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
RSpec.shared_context 'API request', :resource do
|
2
4
|
let(:cassette_name) { described_class.name.split(/::/).last.downcase }
|
3
5
|
let(:client) { PewPew::Client.new }
|
4
6
|
|
@@ -14,7 +16,7 @@ shared_context 'API request', :resource do
|
|
14
16
|
|
15
17
|
vcr_options = {
|
16
18
|
record: (ENV['VCR_RECORD'] || :none).to_sym,
|
17
|
-
match_requests_on: [:method, :uri, :
|
19
|
+
match_requests_on: [:method, :uri, :multipart_headers, :multipart_body],
|
18
20
|
erb: {
|
19
21
|
basic_auth: basic_auth,
|
20
22
|
domain: client.config.domain,
|
@@ -22,6 +24,6 @@ shared_context 'API request', :resource do
|
|
22
24
|
}
|
23
25
|
}
|
24
26
|
|
25
|
-
VCR.use_cassette
|
27
|
+
VCR.use_cassette cassette_name, vcr_options, &example
|
26
28
|
end
|
27
29
|
end
|