sendgrid-newsletter 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.
- data/.gitignore +19 -0
- data/.rspec +1 -0
- data/.simplecov +7 -0
- data/Gemfile +11 -0
- data/Guardfile +19 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +15 -0
- data/lib/sendgrid-newsletter.rb +16 -0
- data/lib/sendgrid-newsletter/base.rb +20 -0
- data/lib/sendgrid-newsletter/config.rb +9 -0
- data/lib/sendgrid-newsletter/email.rb +26 -0
- data/lib/sendgrid-newsletter/errors.rb +8 -0
- data/lib/sendgrid-newsletter/list.rb +22 -0
- data/lib/sendgrid-newsletter/newsletter.rb +29 -0
- data/lib/sendgrid-newsletter/recipient.rb +22 -0
- data/lib/sendgrid-newsletter/schedule.rb +22 -0
- data/lib/sendgrid-newsletter/version.rb +5 -0
- data/sendgrid-newsletter.gemspec +22 -0
- data/spec/fixtures/vcr_cassettes/adding_bulk_emails_on_list.yml +806 -0
- data/spec/fixtures/vcr_cassettes/adding_emails_on_list.yml +31 -0
- data/spec/fixtures/vcr_cassettes/adding_emails_with_data_on_list.yml +32 -0
- data/spec/fixtures/vcr_cassettes/adding_recipients_to_newsletter.yml +30 -0
- data/spec/fixtures/vcr_cassettes/adding_schedule_to_newsletter.yml +30 -0
- data/spec/fixtures/vcr_cassettes/check_newsletter.yml +30 -0
- data/spec/fixtures/vcr_cassettes/create_list_successfully.yml +30 -0
- data/spec/fixtures/vcr_cassettes/delete_list_successfully.yml +30 -0
- data/spec/fixtures/vcr_cassettes/error_adding_emails_on_list.yml +31 -0
- data/spec/fixtures/vcr_cassettes/error_adding_recipients_to_newsletter.yml +30 -0
- data/spec/fixtures/vcr_cassettes/error_adding_schedule_to_newsletter.yml +30 -0
- data/spec/fixtures/vcr_cassettes/error_removing_recipients_to_newsletter.yml +30 -0
- data/spec/fixtures/vcr_cassettes/error_removing_schedule_to_newsletter.yml +30 -0
- data/spec/fixtures/vcr_cassettes/existent_check_newsletter.yml +30 -0
- data/spec/fixtures/vcr_cassettes/existent_identity.yml +30 -0
- data/spec/fixtures/vcr_cassettes/existent_identity_on_edit.yml +30 -0
- data/spec/fixtures/vcr_cassettes/inexistent_identity.yml +30 -0
- data/spec/fixtures/vcr_cassettes/inexistent_identity_on_edit.yml +30 -0
- data/spec/fixtures/vcr_cassettes/list_exist.yml +30 -0
- data/spec/fixtures/vcr_cassettes/list_newsletter.yml +30 -0
- data/spec/fixtures/vcr_cassettes/list_non_exist_on_deletion.yml +30 -0
- data/spec/fixtures/vcr_cassettes/removing_recipients_from_newsletter.yml +30 -0
- data/spec/fixtures/vcr_cassettes/removing_schedule_from_newsletter.yml +30 -0
- data/spec/sendgrid-newsletter/config_spec.rb +20 -0
- data/spec/sendgrid-newsletter/email_spec.rb +63 -0
- data/spec/sendgrid-newsletter/list_spec.rb +54 -0
- data/spec/sendgrid-newsletter/newsletter_spec.rb +115 -0
- data/spec/sendgrid-newsletter/recipient_spec.rb +65 -0
- data/spec/sendgrid-newsletter/schedule_spec.rb +52 -0
- data/spec/spec_helper.rb +16 -0
- metadata +180 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://sendgrid.com/api/newsletter/add.json?api_key=testnewsletter&api_user=news_test
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: text=Text&html=Text&name=Beatiful%20news&identity=Beatiful%20Girl&subject=Text
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 401
|
13
|
+
message: Unauthorized
|
14
|
+
headers:
|
15
|
+
Server:
|
16
|
+
- nginx/0.7.65
|
17
|
+
Date:
|
18
|
+
- Tue, 20 Mar 2012 21:02:42 GMT
|
19
|
+
Content-Type:
|
20
|
+
- text/html
|
21
|
+
Transfer-Encoding:
|
22
|
+
- chunked
|
23
|
+
Connection:
|
24
|
+
- keep-alive
|
25
|
+
body:
|
26
|
+
encoding: US-ASCII
|
27
|
+
string: ! '{"error": "Identity Beatiful Girl does not exist"}'
|
28
|
+
http_version: !!null
|
29
|
+
recorded_at: Tue, 20 Mar 2012 21:02:43 GMT
|
30
|
+
recorded_with: VCR 2.0.0
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://sendgrid.com/api/newsletter/edit.json?api_key=testnewsletter&api_user=news_test
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: text=Text&html=Text&name=Beatiful%20news&newname=Beatiful%20news&identity=Beatiful%20Girl&subject=Text
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 401
|
13
|
+
message: Unauthorized
|
14
|
+
headers:
|
15
|
+
Server:
|
16
|
+
- nginx/0.7.65
|
17
|
+
Date:
|
18
|
+
- Sat, 31 Mar 2012 14:10:21 GMT
|
19
|
+
Content-Type:
|
20
|
+
- text/html
|
21
|
+
Transfer-Encoding:
|
22
|
+
- chunked
|
23
|
+
Connection:
|
24
|
+
- keep-alive
|
25
|
+
body:
|
26
|
+
encoding: US-ASCII
|
27
|
+
string: ! '{"error": "Beatiful news does not exist"}'
|
28
|
+
http_version: !!null
|
29
|
+
recorded_at: Sat, 31 Mar 2012 14:10:21 GMT
|
30
|
+
recorded_with: VCR 2.0.0
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://sendgrid.com/api/newsletter/lists/add.json?api_key=testnewsletter&api_user=news_test
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: list=Cool%20List
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Server:
|
16
|
+
- nginx/0.7.65
|
17
|
+
Date:
|
18
|
+
- Tue, 20 Mar 2012 22:14:39 GMT
|
19
|
+
Content-Type:
|
20
|
+
- text/html
|
21
|
+
Transfer-Encoding:
|
22
|
+
- chunked
|
23
|
+
Connection:
|
24
|
+
- keep-alive
|
25
|
+
body:
|
26
|
+
encoding: US-ASCII
|
27
|
+
string: ! '{"error": "Cool List already exists"}'
|
28
|
+
http_version: !!null
|
29
|
+
recorded_at: Tue, 20 Mar 2012 22:14:39 GMT
|
30
|
+
recorded_with: VCR 2.0.0
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://sendgrid.com/api/newsletter/list.json?api_key=testnewsletter&api_user=news_test
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Server:
|
16
|
+
- nginx/0.7.65
|
17
|
+
Date:
|
18
|
+
- Tue, 20 Mar 2012 19:53:45 GMT
|
19
|
+
Content-Type:
|
20
|
+
- text/html
|
21
|
+
Transfer-Encoding:
|
22
|
+
- chunked
|
23
|
+
Connection:
|
24
|
+
- keep-alive
|
25
|
+
body:
|
26
|
+
encoding: US-ASCII
|
27
|
+
string: ! '[{"name": "Teste"},{"name": "Teste API"}]'
|
28
|
+
http_version: !!null
|
29
|
+
recorded_at: Tue, 20 Mar 2012 19:53:45 GMT
|
30
|
+
recorded_with: VCR 2.0.0
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://sendgrid.com/api/newsletter/lists/delete.json?api_key=testnewsletter&api_user=news_test
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: list=Cool%20List
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Server:
|
16
|
+
- nginx/0.7.65
|
17
|
+
Date:
|
18
|
+
- Tue, 20 Mar 2012 22:31:58 GMT
|
19
|
+
Content-Type:
|
20
|
+
- text/html
|
21
|
+
Transfer-Encoding:
|
22
|
+
- chunked
|
23
|
+
Connection:
|
24
|
+
- keep-alive
|
25
|
+
body:
|
26
|
+
encoding: US-ASCII
|
27
|
+
string: ! '{"error": "List does not exist"}'
|
28
|
+
http_version: !!null
|
29
|
+
recorded_at: Tue, 20 Mar 2012 22:31:58 GMT
|
30
|
+
recorded_with: VCR 2.0.0
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://sendgrid.com/api/newsletter/recipients/delete.json?api_key=testnewsletter&api_user=news_test
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: name=Cool%20News&list=cool_list
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Server:
|
16
|
+
- nginx/0.7.65
|
17
|
+
Date:
|
18
|
+
- Thu, 22 Mar 2012 02:01:35 GMT
|
19
|
+
Content-Type:
|
20
|
+
- text/html
|
21
|
+
Transfer-Encoding:
|
22
|
+
- chunked
|
23
|
+
Connection:
|
24
|
+
- keep-alive
|
25
|
+
body:
|
26
|
+
encoding: US-ASCII
|
27
|
+
string: ! '{"message": "success"}'
|
28
|
+
http_version: !!null
|
29
|
+
recorded_at: Thu, 22 Mar 2012 02:01:35 GMT
|
30
|
+
recorded_with: VCR 2.0.0
|
@@ -0,0 +1,30 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://sendgrid.com/api/newsletter/schedule/delete.json?api_key=testnewsletter&api_user=news_test
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: name=Cool%20News
|
9
|
+
headers: {}
|
10
|
+
response:
|
11
|
+
status:
|
12
|
+
code: 200
|
13
|
+
message: OK
|
14
|
+
headers:
|
15
|
+
Server:
|
16
|
+
- nginx/0.7.65
|
17
|
+
Date:
|
18
|
+
- Thu, 22 Mar 2012 02:40:27 GMT
|
19
|
+
Content-Type:
|
20
|
+
- text/html
|
21
|
+
Transfer-Encoding:
|
22
|
+
- chunked
|
23
|
+
Connection:
|
24
|
+
- keep-alive
|
25
|
+
body:
|
26
|
+
encoding: US-ASCII
|
27
|
+
string: ! '{"message": "success"}'
|
28
|
+
http_version: !!null
|
29
|
+
recorded_at: Thu, 22 Mar 2012 02:40:25 GMT
|
30
|
+
recorded_with: VCR 2.0.0
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sendgrid::Newsletter::Config do
|
4
|
+
subject { Sendgrid::Newsletter::Config }
|
5
|
+
describe '.api_user' do
|
6
|
+
it 'should return previously stored api_user' do
|
7
|
+
subject.api_user = 'testing_user'
|
8
|
+
|
9
|
+
subject.api_user.should eql('testing_user')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '.api_key' do
|
14
|
+
it 'should return previously stored api_key' do
|
15
|
+
subject.api_key = 'testing_key'
|
16
|
+
|
17
|
+
subject.api_key.should eql 'testing_key'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sendgrid::Newsletter::Email do
|
4
|
+
before do
|
5
|
+
Sendgrid::Newsletter::Config.api_user = 'news_test'
|
6
|
+
Sendgrid::Newsletter::Config.api_key = 'testnewsletter'
|
7
|
+
end
|
8
|
+
subject { Sendgrid::Newsletter::Email.new }
|
9
|
+
describe '#add' do
|
10
|
+
it 'should require list param' do
|
11
|
+
lambda {
|
12
|
+
subject.add
|
13
|
+
}.should raise_error ArgumentError
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should require data param' do
|
17
|
+
lambda {
|
18
|
+
subject.add list: 'cool_list'
|
19
|
+
}.should raise_error ArgumentError
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should require data param to be an hash or an array' do
|
23
|
+
lambda {
|
24
|
+
subject.add list: 'cool_list', data: 'asdf'
|
25
|
+
}.should raise_error ArgumentError
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should raise Sendgrid::Newsletter::FieldsRequired if email or name in data param' do
|
29
|
+
lambda {
|
30
|
+
subject.add list: 'cool_list', data: { foo: 'bar' }
|
31
|
+
}.should raise_error Sendgrid::Newsletter::FieldsRequired
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should return {"inserted": X} where X is the number of emails' do
|
35
|
+
VCR.use_cassette('adding_emails_on_list') do
|
36
|
+
subject.add(list: 'cool_list', data: [{name: 'foo bar', email: 'foo@bar.com'}, {name: 'foo2 bar', email: 'foo2@bar.com'}]).should eql({'inserted' => 2})
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should send multiple data parameters' do
|
41
|
+
VCR.use_cassette('adding_emails_with_data_on_list') do
|
42
|
+
subject.add(list: 'cool_list', data: [{name: 'foo bar', email: 'foo@bar.com', address:'2 Street, 0'}, {name: 'foo2 bar', email: 'foo2@bar.com', address:'1 Street, 2'}]).should eql({'inserted' => 2})
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should raise APIError if API return {"error": "message"}' do
|
47
|
+
VCR.use_cassette('error_adding_emails_on_list') do
|
48
|
+
lambda {
|
49
|
+
subject.add(list: 'bad_list', data: [{name: 'foo bar', email: 'foo@bar.com'}, {name: 'foo2 bar', email: 'foo2@bar.com'}])
|
50
|
+
}.should raise_error Sendgrid::Newsletter::APIError
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should treat adding more than 1000 emails" do
|
55
|
+
VCR.use_cassette('adding_bulk_emails_on_list') do
|
56
|
+
data = (1..1500).to_a.map { |i| { name: "foo bar #{i}", email: "foo#{i}@bar.com" } }
|
57
|
+
subject.add(list: 'cool_list', data: data).should eql({'inserted' => 1499})
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sendgrid::Newsletter::List do
|
4
|
+
before do
|
5
|
+
Sendgrid::Newsletter::Config.api_user = 'news_test'
|
6
|
+
Sendgrid::Newsletter::Config.api_key = 'testnewsletter'
|
7
|
+
end
|
8
|
+
subject { Sendgrid::Newsletter::List.new }
|
9
|
+
|
10
|
+
describe '.add' do
|
11
|
+
it 'should require :list param' do
|
12
|
+
lambda {
|
13
|
+
subject.add
|
14
|
+
}.should raise_error ArgumentError
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should raise APIError when error is received' do
|
18
|
+
VCR.use_cassette('list_exist') do
|
19
|
+
lambda {
|
20
|
+
subject.add(list: 'Cool List')
|
21
|
+
}.should raise_error Sendgrid::Newsletter::APIError
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should return message: "success" on successful creation' do
|
26
|
+
VCR.use_cassette('create_list_successfully') do
|
27
|
+
subject.add(list: 'Cool List').should eql({'message' => 'success'})
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '.del' do
|
33
|
+
it 'should require :list param' do
|
34
|
+
lambda {
|
35
|
+
subject.delete
|
36
|
+
}.should raise_error ArgumentError
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should raise APIError when error is received' do
|
40
|
+
VCR.use_cassette('list_non_exist_on_deletion') do
|
41
|
+
lambda {
|
42
|
+
subject.delete(list: 'Cool List')
|
43
|
+
}.should raise_error Sendgrid::Newsletter::APIError
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should return message: "success" on successful deletion' do
|
48
|
+
VCR.use_cassette('delete_list_successfully') do
|
49
|
+
subject.delete(list: 'Cool List').should eql({'message' => 'success'})
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sendgrid::Newsletter::Newsletter do
|
4
|
+
before do
|
5
|
+
Sendgrid::Newsletter::Config.api_user='news_test'
|
6
|
+
Sendgrid::Newsletter::Config.api_key='testnewsletter'
|
7
|
+
end
|
8
|
+
|
9
|
+
subject {Sendgrid::Newsletter::Newsletter.new}
|
10
|
+
|
11
|
+
describe '.list' do
|
12
|
+
it 'should return a list of all newsletters' do
|
13
|
+
VCR.use_cassette('list_newsletter') do
|
14
|
+
subject.list.should eql [{'name' => 'Teste'}, {'name' => 'Teste API'}]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should check if a list exist within all newsletters' do
|
19
|
+
VCR.use_cassette('check_newsletter') do
|
20
|
+
subject.list(:name => 'Inexistent News').should eql []
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should check if a list exist within all newsletters' do
|
25
|
+
VCR.use_cassette('existent_check_newsletter') do
|
26
|
+
subject.list(:name => 'Cool News').should eql [{'name' => 'Cool News'}]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '.add' do
|
32
|
+
it 'should require text' do
|
33
|
+
lambda {
|
34
|
+
subject.add
|
35
|
+
}.should raise_error ArgumentError
|
36
|
+
end
|
37
|
+
it 'should require html' do
|
38
|
+
lambda {
|
39
|
+
subject.add text: 'Text'
|
40
|
+
}.should raise_error ArgumentError
|
41
|
+
end
|
42
|
+
it 'should require name' do
|
43
|
+
lambda {
|
44
|
+
subject.add text: 'Text', html: 'Text'
|
45
|
+
}.should raise_error ArgumentError
|
46
|
+
end
|
47
|
+
it 'should require identity' do
|
48
|
+
lambda {
|
49
|
+
subject.add text: 'Text', html: 'Text', name: 'Beatiful news'
|
50
|
+
}.should raise_error ArgumentError
|
51
|
+
end
|
52
|
+
it 'should require subject' do
|
53
|
+
lambda {
|
54
|
+
subject.add text: 'Text', html: 'Text', name: 'Beatiful news', identity: 'Beatiful Girl'
|
55
|
+
}.should raise_error ArgumentError
|
56
|
+
end
|
57
|
+
it 'should return error: "Identity %id% does not exist" with inexistent identity' do
|
58
|
+
VCR.use_cassette('inexistent_identity') do
|
59
|
+
lambda {
|
60
|
+
subject.add text: 'Text', html: 'Text', name: 'Beatiful news', identity: 'Beatiful Girl', subject: 'Text'
|
61
|
+
}.should raise_error Sendgrid::Newsletter::APIError
|
62
|
+
end
|
63
|
+
end
|
64
|
+
it 'should return message: "success" on successful creation' do
|
65
|
+
VCR.use_cassette('existent_identity') do
|
66
|
+
subject.add(text: 'Text', html: 'Text', name: 'Beatiful news', identity: 'Grubster Tech TEST', subject: 'Text').should eql({'message' => 'success'})
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '.edit' do
|
72
|
+
it 'should require text' do
|
73
|
+
lambda {
|
74
|
+
subject.edit
|
75
|
+
}.should raise_error ArgumentError
|
76
|
+
end
|
77
|
+
it 'should require html' do
|
78
|
+
lambda {
|
79
|
+
subject.edit text: 'Text'
|
80
|
+
}.should raise_error ArgumentError
|
81
|
+
end
|
82
|
+
it 'should require name' do
|
83
|
+
lambda {
|
84
|
+
subject.edit text: 'Text', html: 'Text'
|
85
|
+
}.should raise_error ArgumentError
|
86
|
+
end
|
87
|
+
it 'should require newname' do
|
88
|
+
lambda {
|
89
|
+
subject.edit text: 'Text', html: 'Text', name: 'Beatiful news'
|
90
|
+
}.should raise_error ArgumentError
|
91
|
+
end
|
92
|
+
it 'should require identity' do
|
93
|
+
lambda {
|
94
|
+
subject.edit text: 'Text', html: 'Text', name: 'Beatiful news', newname: 'Beatiful news'
|
95
|
+
}.should raise_error ArgumentError
|
96
|
+
end
|
97
|
+
it 'should require subject' do
|
98
|
+
lambda {
|
99
|
+
subject.edit text: 'Text', html: 'Text', name: 'Beatiful news', newname: 'Beatiful news', identity: 'Beatiful Girl'
|
100
|
+
}.should raise_error ArgumentError
|
101
|
+
end
|
102
|
+
it 'should return error: "Identity %id% does not exist" with inexistent identity' do
|
103
|
+
VCR.use_cassette('inexistent_identity_on_edit') do
|
104
|
+
lambda {
|
105
|
+
subject.edit text: 'Text', html: 'Text', name: 'Beatiful news', newname: 'Beatiful news', identity: 'Beatiful Girl', subject: 'Text'
|
106
|
+
}.should raise_error Sendgrid::Newsletter::APIError
|
107
|
+
end
|
108
|
+
end
|
109
|
+
it 'should return message: "success" on successful creation' do
|
110
|
+
VCR.use_cassette('existent_identity_on_edit') do
|
111
|
+
subject.edit(text: 'Text', html: 'Text', name: 'Beatiful news', newname: 'Beatiful news', identity: 'From Grubster', subject: 'Text').should eql({'message' => 'success'})
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|