createsend 6.0.0 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/client_test.rb CHANGED
@@ -4,189 +4,189 @@ class ClientTest < Test::Unit::TestCase
4
4
  multiple_contexts "authenticated_using_oauth_context", "authenticated_using_api_key_context" do
5
5
  setup do
6
6
  @client = CreateSend::Client.new(@auth, '321iuhiuhi1u23hi2u3')
7
- @client.client_id.should == '321iuhiuhi1u23hi2u3'
7
+ @client.client_id.should be == '321iuhiuhi1u23hi2u3'
8
8
  end
9
9
 
10
10
  should "create a client" do
11
11
  stub_post(@auth, "clients.json", "create_client.json")
12
12
  client_id = CreateSend::Client.create @auth, "Client Company Name", "(GMT+10:00) Canberra, Melbourne, Sydney", "Australia"
13
- client_id.parsed_response.should == "32a381c49a2df99f1d0c6f3c112352b9"
13
+ client_id.parsed_response.should be == "32a381c49a2df99f1d0c6f3c112352b9"
14
14
  end
15
15
 
16
16
  should "get details of a client" do
17
17
  stub_get(@auth, "clients/#{@client.client_id}.json", "client_details.json")
18
18
  cl = @client.details
19
- cl.ApiKey.should == "639d8cc27198202f5fe6037a8b17a29a59984b86d3289bc9"
20
- cl.BasicDetails.ClientID.should == "4a397ccaaa55eb4e6aa1221e1e2d7122"
21
- cl.BasicDetails.ContactName.should == "Client One (contact)"
22
- cl.AccessDetails.Username.should == "clientone"
23
- cl.AccessDetails.AccessLevel.should == 23
24
- cl.BillingDetails.MonthlyScheme.should == "Basic"
25
- cl.BillingDetails.Credits.should == 500
19
+ cl.ApiKey.should be == "639d8cc27198202f5fe6037a8b17a29a59984b86d3289bc9"
20
+ cl.BasicDetails.ClientID.should be == "4a397ccaaa55eb4e6aa1221e1e2d7122"
21
+ cl.BasicDetails.ContactName.should be == "Client One (contact)"
22
+ cl.AccessDetails.Username.should be == "clientone"
23
+ cl.AccessDetails.AccessLevel.should be == 23
24
+ cl.BillingDetails.MonthlyScheme.should be == "Basic"
25
+ cl.BillingDetails.Credits.should be == 500
26
26
  end
27
27
 
28
28
  should "get all campaigns" do
29
29
  stub_get(@auth, "clients/#{@client.client_id}/campaigns.json?page=1&pagesize=1000&orderdirection=desc&sentfromdate=&senttodate=&tags=", "campaigns.json")
30
30
  campaigns = @client.campaigns
31
- campaigns.Results.size.should == 2
32
- campaigns.ResultsOrderedBy == 'sentdate'
33
- campaigns.OrderDirection = 'desc'
34
- campaigns.PageNumber == 1
35
- campaigns.PageSize == 1000
36
- campaigns.RecordsOnThisPage == 2
37
- campaigns.TotalNumberOfRecords == 2
38
- campaigns.NumberOfPages == 1
31
+ campaigns.Results.size.should be == 2
32
+ campaigns.ResultsOrderedBy be == 'sentdate'
33
+ campaigns.OrderDirection be == 'desc'
34
+ campaigns.PageNumber be == 1
35
+ campaigns.PageSize be == 1000
36
+ campaigns.RecordsOnThisPage be == 2
37
+ campaigns.TotalNumberOfRecords be == 2
38
+ campaigns.NumberOfPages be == 1
39
39
 
40
40
  campaign = campaigns.Results.first
41
- campaign.CampaignID.should == 'fc0ce7105baeaf97f47c99be31d02a91'
42
- campaign.WebVersionURL.should == 'http://createsend.com/t/r-765E86829575EE2C'
43
- campaign.WebVersionTextURL.should == 'http://createsend.com/t/r-765E86829575EE2C/t'
44
- campaign.Subject.should == 'Campaign One'
45
- campaign.Name.should == 'Campaign One'
46
- campaign.SentDate.should == '2010-10-12 12:58:00'
47
- campaign.TotalRecipients.should == 2245
48
- campaign.FromName.should == 'My Name'
49
- campaign.FromEmail.should == 'myemail@example.com'
50
- campaign.ReplyTo.should == 'myemail@example.com'
51
- campaign.Tags.should == []
41
+ campaign.CampaignID.should be == 'fc0ce7105baeaf97f47c99be31d02a91'
42
+ campaign.WebVersionURL.should be == 'http://createsend.com/t/r-765E86829575EE2C'
43
+ campaign.WebVersionTextURL.should be == 'http://createsend.com/t/r-765E86829575EE2C/t'
44
+ campaign.Subject.should be == 'Campaign One'
45
+ campaign.Name.should be == 'Campaign One'
46
+ campaign.SentDate.should be == '2010-10-12 12:58:00'
47
+ campaign.TotalRecipients.should be == 2245
48
+ campaign.FromName.should be == 'My Name'
49
+ campaign.FromEmail.should be == 'myemail@example.com'
50
+ campaign.ReplyTo.should be == 'myemail@example.com'
51
+ campaign.Tags.should be == []
52
52
  end
53
53
 
54
54
  should "get scheduled campaigns" do
55
55
  stub_get(@auth, "clients/#{@client.client_id}/scheduled.json", "scheduled_campaigns.json")
56
56
  campaigns = @client.scheduled
57
- campaigns.size.should == 2
57
+ campaigns.size.should be == 2
58
58
  campaign = campaigns.first
59
- campaign.DateScheduled.should == "2011-05-25 10:40:00"
60
- campaign.ScheduledTimeZone.should == "(GMT+10:00) Canberra, Melbourne, Sydney"
61
- campaign.CampaignID.should == "827dbbd2161ea9989fa11ad562c66937"
62
- campaign.Name.should == "Magic Issue One"
63
- campaign.Subject.should == "Magic Issue One"
64
- campaign.DateCreated.should == "2011-05-24 10:37:00"
65
- campaign.PreviewURL.should == "http://createsend.com/t/r-DD543521A87C9B8B"
66
- campaign.PreviewTextURL.should == "http://createsend.com/t/r-DD543521A87C9B8B/t"
67
- campaign.FromName.should == 'My Name'
68
- campaign.FromEmail.should == 'myemail@example.com'
69
- campaign.ReplyTo.should == 'myemail@example.com'
70
- campaign.Tags.should == ['tagexample']
59
+ campaign.DateScheduled.should be == "2011-05-25 10:40:00"
60
+ campaign.ScheduledTimeZone.should be == "(GMT+10:00) Canberra, Melbourne, Sydney"
61
+ campaign.CampaignID.should be == "827dbbd2161ea9989fa11ad562c66937"
62
+ campaign.Name.should be == "Magic Issue One"
63
+ campaign.Subject.should be == "Magic Issue One"
64
+ campaign.DateCreated.should be == "2011-05-24 10:37:00"
65
+ campaign.PreviewURL.should be == "http://createsend.com/t/r-DD543521A87C9B8B"
66
+ campaign.PreviewTextURL.should be == "http://createsend.com/t/r-DD543521A87C9B8B/t"
67
+ campaign.FromName.should be == 'My Name'
68
+ campaign.FromEmail.should be == 'myemail@example.com'
69
+ campaign.ReplyTo.should be == 'myemail@example.com'
70
+ campaign.Tags.should be == ['tagexample']
71
71
  end
72
72
 
73
73
  should "get all drafts" do
74
74
  stub_get(@auth, "clients/#{@client.client_id}/drafts.json", "drafts.json")
75
75
  drafts = @client.drafts
76
- drafts.size.should == 2
76
+ drafts.size.should be == 2
77
77
  draft = drafts.first
78
- draft.CampaignID.should == '7c7424792065d92627139208c8c01db1'
79
- draft.Name.should == 'Draft One'
80
- draft.Subject.should == 'Draft One'
81
- draft.DateCreated.should == '2010-08-19 16:08:00'
82
- draft.PreviewURL.should == 'http://createsend.com/t/r-E97A7BB2E6983DA1'
83
- draft.PreviewTextURL.should == 'http://createsend.com/t/r-E97A7BB2E6983DA1/t'
84
- draft.FromName.should == 'My Name'
85
- draft.FromEmail.should == 'myemail@example.com'
86
- draft.ReplyTo.should == 'myemail@example.com'
87
- draft.Tags.should == ['tagexample']
78
+ draft.CampaignID.should be == '7c7424792065d92627139208c8c01db1'
79
+ draft.Name.should be == 'Draft One'
80
+ draft.Subject.should be == 'Draft One'
81
+ draft.DateCreated.should be == '2010-08-19 16:08:00'
82
+ draft.PreviewURL.should be == 'http://createsend.com/t/r-E97A7BB2E6983DA1'
83
+ draft.PreviewTextURL.should be == 'http://createsend.com/t/r-E97A7BB2E6983DA1/t'
84
+ draft.FromName.should be == 'My Name'
85
+ draft.FromEmail.should be == 'myemail@example.com'
86
+ draft.ReplyTo.should be == 'myemail@example.com'
87
+ draft.Tags.should be == ['tagexample']
88
88
  end
89
89
 
90
90
  should "get all client tags" do
91
91
  stub_get(@auth, "clients/#{@client.client_id}/tags.json", "tags.json")
92
92
  tags = @client.tags
93
- tags.size.should == 2
93
+ tags.size.should be == 2
94
94
  tag = tags.first
95
- tag.Name.should == 'Tag One'
96
- tag.NumberOfCampaigns.should == '120'
95
+ tag.Name.should be == 'Tag One'
96
+ tag.NumberOfCampaigns.should be == '120'
97
97
  end
98
98
 
99
99
  should "get all lists" do
100
100
  stub_get(@auth, "clients/#{@client.client_id}/lists.json", "lists.json")
101
101
  lists = @client.lists
102
- lists.size.should == 2
103
- lists.first.ListID.should == 'a58ee1d3039b8bec838e6d1482a8a965'
104
- lists.first.Name.should == 'List One'
102
+ lists.size.should be == 2
103
+ lists.first.ListID.should be == 'a58ee1d3039b8bec838e6d1482a8a965'
104
+ lists.first.Name.should be == 'List One'
105
105
  end
106
106
 
107
107
  should "get all lists to which a subscriber with a particular email address belongs" do
108
108
  email = "valid@example.com"
109
109
  stub_get(@auth, "clients/#{@client.client_id}/listsforemail.json?email=#{ERB::Util.url_encode(email)}", "listsforemail.json")
110
110
  lists = @client.lists_for_email(email)
111
- lists.size.should == 2
112
- lists.first.ListID.should == 'ab4a2b57c7c8f1ba62f898a1af1a575b'
113
- lists.first.ListName.should == 'List Number One'
114
- lists.first.SubscriberState.should == 'Active'
115
- lists.first.DateSubscriberAdded.should == '2012-08-20 22:32:00'
111
+ lists.size.should be == 2
112
+ lists.first.ListID.should be == 'ab4a2b57c7c8f1ba62f898a1af1a575b'
113
+ lists.first.ListName.should be == 'List Number One'
114
+ lists.first.SubscriberState.should be == 'Active'
115
+ lists.first.DateSubscriberAdded.should be == '2012-08-20 22:32:00'
116
116
  end
117
117
 
118
118
  should "get all segments for a client" do
119
119
  stub_get(@auth, "clients/#{@client.client_id}/segments.json", "segments.json")
120
120
  segments = @client.segments
121
- segments.size.should == 2
122
- segments.first.ListID.should == 'a58ee1d3039b8bec838e6d1482a8a965'
123
- segments.first.SegmentID.should == '46aa5e01fd43381863d4e42cf277d3a9'
124
- segments.first.Title.should == 'Segment One'
121
+ segments.size.should be == 2
122
+ segments.first.ListID.should be == 'a58ee1d3039b8bec838e6d1482a8a965'
123
+ segments.first.SegmentID.should be == '46aa5e01fd43381863d4e42cf277d3a9'
124
+ segments.first.Title.should be == 'Segment One'
125
125
  end
126
126
 
127
127
  should "get suppression list" do
128
128
  stub_get(@auth, "clients/#{@client.client_id}/suppressionlist.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc", "suppressionlist.json")
129
129
  res = @client.suppressionlist
130
- res.ResultsOrderedBy.should == "email"
131
- res.OrderDirection.should == "asc"
132
- res.PageNumber.should == 1
133
- res.PageSize.should == 1000
134
- res.RecordsOnThisPage.should == 5
135
- res.TotalNumberOfRecords.should == 5
136
- res.NumberOfPages.should == 1
137
- res.Results.size.should == 5
138
- res.Results.first.SuppressionReason.should == "Unsubscribed"
139
- res.Results.first.EmailAddress.should == "example+1@example.com"
140
- res.Results.first.Date.should == "2010-10-26 10:55:31"
141
- res.Results.first.State.should == "Suppressed"
130
+ res.ResultsOrderedBy.should be == "email"
131
+ res.OrderDirection.should be == "asc"
132
+ res.PageNumber.should be == 1
133
+ res.PageSize.should be == 1000
134
+ res.RecordsOnThisPage.should be == 5
135
+ res.TotalNumberOfRecords.should be == 5
136
+ res.NumberOfPages.should be == 1
137
+ res.Results.size.should be == 5
138
+ res.Results.first.SuppressionReason.should be == "Unsubscribed"
139
+ res.Results.first.EmailAddress.should be == "example+1@example.com"
140
+ res.Results.first.Date.should be == "2010-10-26 10:55:31"
141
+ res.Results.first.State.should be == "Suppressed"
142
142
  end
143
143
 
144
144
  should "suppress a single email address" do
145
145
  email = "example@example.com"
146
146
  stub_post(@auth, "clients/#{@client.client_id}/suppress.json", nil)
147
- result = @client.suppress email
147
+ @client.suppress email
148
148
  end
149
149
 
150
150
  should "suppress multiple email address" do
151
151
  stub_post(@auth, "clients/#{@client.client_id}/suppress.json", nil)
152
- result = @client.suppress [ "one@example.com", "two@example.com" ]
152
+ @client.suppress [ "one@example.com", "two@example.com" ]
153
153
  end
154
154
 
155
155
  should "unsuppress an email address" do
156
156
  email = "example@example.com"
157
157
  stub_put(@auth, "clients/#{@client.client_id}/unsuppress.json?email=#{ERB::Util.url_encode(email)}", nil)
158
- result = @client.unsuppress email
158
+ @client.unsuppress email
159
159
  end
160
160
 
161
161
  should "get all people" do
162
162
  stub_get(@auth, "clients/#{@client.client_id}/people.json", "people.json")
163
163
  people = @client.people
164
- people.size.should == 2
165
- people.first.EmailAddress.should == "person1@blackhole.com"
166
- people.first.Name.should == "Person One"
167
- people.first.Status.should == "Active"
168
- people.first.AccessLevel.should == 31
164
+ people.size.should be == 2
165
+ people.first.EmailAddress.should be == "person1@blackhole.com"
166
+ people.first.Name.should be == "Person One"
167
+ people.first.Status.should be == "Active"
168
+ people.first.AccessLevel.should be == 31
169
169
  end
170
170
 
171
171
  should "get all templates" do
172
172
  stub_get(@auth, "clients/#{@client.client_id}/templates.json", "templates.json")
173
173
  templates = @client.templates
174
- templates.size.should == 2
175
- templates.first.TemplateID.should == '5cac213cf061dd4e008de5a82b7a3621'
176
- templates.first.Name.should == 'Template One'
174
+ templates.size.should be == 2
175
+ templates.first.TemplateID.should be == '5cac213cf061dd4e008de5a82b7a3621'
176
+ templates.first.Name.should be == 'Template One'
177
177
  end
178
178
 
179
179
  should "set primary contact" do
180
180
  email = 'person@blackhole.com'
181
181
  stub_put(@auth, "clients/#{@client.client_id}/primarycontact.json?email=#{ERB::Util.url_encode(email)}", 'client_set_primary_contact.json')
182
182
  result = @client.set_primary_contact email
183
- result.EmailAddress.should == email
183
+ result.EmailAddress.should be == email
184
184
  end
185
185
 
186
186
  should "get primary contact" do
187
187
  stub_get(@auth, "clients/#{@client.client_id}/primarycontact.json", 'client_get_primary_contact.json')
188
188
  result = @client.get_primary_contact
189
- result.EmailAddress.should == 'person@blackhole.com'
189
+ result.EmailAddress.should be == 'person@blackhole.com'
190
190
  end
191
191
 
192
192
  should "set basics" do
@@ -203,37 +203,37 @@ class ClientTest < Test::Unit::TestCase
203
203
  stub_put(@auth, "clients/#{@client.client_id}/setmonthlybilling.json", nil)
204
204
  @client.set_monthly_billing "CAD", true, 150
205
205
  request = FakeWeb.last_request.body
206
- request.include?("\"Currency\":\"CAD\"").should == true
207
- request.include?("\"ClientPays\":true").should == true
208
- request.include?("\"MarkupPercentage\":150").should == true
209
- request.include?("\"MonthlyScheme\":null").should == true
206
+ request.include?("\"Currency\":\"CAD\"").should be == true
207
+ request.include?("\"ClientPays\":true").should be == true
208
+ request.include?("\"MarkupPercentage\":150").should be == true
209
+ request.include?("\"MonthlyScheme\":null").should be == true
210
210
  end
211
211
 
212
212
  should "set monthly billing (basic)" do
213
213
  stub_put(@auth, "clients/#{@client.client_id}/setmonthlybilling.json", nil)
214
214
  @client.set_monthly_billing "CAD", true, 150, "Basic"
215
215
  request = FakeWeb.last_request.body
216
- request.include?("\"Currency\":\"CAD\"").should == true
217
- request.include?("\"ClientPays\":true").should == true
218
- request.include?("\"MarkupPercentage\":150").should == true
219
- request.include?("\"MonthlyScheme\":\"Basic\"").should == true
216
+ request.include?("\"Currency\":\"CAD\"").should be == true
217
+ request.include?("\"ClientPays\":true").should be == true
218
+ request.include?("\"MarkupPercentage\":150").should be == true
219
+ request.include?("\"MonthlyScheme\":\"Basic\"").should be == true
220
220
  end
221
221
 
222
222
  should "set monthly billing (unlimited)" do
223
223
  stub_put(@auth, "clients/#{@client.client_id}/setmonthlybilling.json", nil)
224
224
  @client.set_monthly_billing "CAD", false, 120, "Unlimited"
225
225
  request = FakeWeb.last_request.body
226
- request.include?("\"Currency\":\"CAD\"").should == true
227
- request.include?("\"ClientPays\":false").should == true
228
- request.include?("\"MarkupPercentage\":120").should == true
229
- request.include?("\"MonthlyScheme\":\"Unlimited\"").should == true
226
+ request.include?("\"Currency\":\"CAD\"").should be == true
227
+ request.include?("\"ClientPays\":false").should be == true
228
+ request.include?("\"MarkupPercentage\":120").should be == true
229
+ request.include?("\"MonthlyScheme\":\"Unlimited\"").should be == true
230
230
  end
231
231
 
232
232
  should "transfer credits to a client" do
233
233
  stub_post(@auth, "clients/#{@client.client_id}/credits.json", "transfer_credits.json")
234
234
  result = @client.transfer_credits 200, false
235
- result.AccountCredits.should == 800
236
- result.ClientCredits.should == 200
235
+ result.AccountCredits.should be == 800
236
+ result.ClientCredits.should be == 200
237
237
  end
238
238
 
239
239
  should "delete a client" do
@@ -244,10 +244,10 @@ class ClientTest < Test::Unit::TestCase
244
244
  should "get all journeys" do
245
245
  stub_get(@auth, "clients/#{@client.client_id}/journeys.json", "journeys.json")
246
246
  lists = @client.journeys
247
- lists.size.should == 3
248
- lists.first.ListID.should == 'a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a'
249
- lists.first.Name.should == 'Journey One'
250
- lists.first.Status.should == 'Not started'
247
+ lists.size.should be == 3
248
+ lists.first.ListID.should be == 'a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a'
249
+ lists.first.Name.should be == 'Journey One'
250
+ lists.first.Status.should be == 'Not started'
251
251
  end
252
252
  end
253
253
  end
@@ -15,13 +15,13 @@ class CreateSendTest < Test::Unit::TestCase
15
15
  :refresh_token => @refresh_token
16
16
  }
17
17
  cs = CreateSend::CreateSend.new auth
18
- cs.auth_details.should == auth
18
+ cs.auth_details.should be == auth
19
19
  end
20
20
 
21
21
  should "authenticate using an api key" do
22
22
  auth = {:api_key => @api_key}
23
23
  cs = CreateSend::CreateSend.new auth
24
- cs.auth_details.should == auth
24
+ cs.auth_details.should be == auth
25
25
  end
26
26
 
27
27
  should "get the authorization url without state included" do
@@ -29,7 +29,7 @@ class CreateSendTest < Test::Unit::TestCase
29
29
  redirect_uri = 'http://example.com/auth'
30
30
  scope = 'ViewReports,CreateCampaigns,SendCampaigns'
31
31
  url = CreateSend::CreateSend.authorize_url(client_id, redirect_uri, scope)
32
- url.should == "https://api.createsend.com/oauth?client_id=8998879&redirect_uri=http%3A%2F%2Fexample.com%2Fauth&scope=ViewReports%2CCreateCampaigns%2CSendCampaigns"
32
+ url.should be == "https://api.createsend.com/oauth?client_id=8998879&redirect_uri=http%3A%2F%2Fexample.com%2Fauth&scope=ViewReports%2CCreateCampaigns%2CSendCampaigns"
33
33
  end
34
34
 
35
35
  should "get the authorization url with state included" do
@@ -38,7 +38,7 @@ class CreateSendTest < Test::Unit::TestCase
38
38
  scope = 'ViewReports,CreateCampaigns,SendCampaigns'
39
39
  state = 89879287
40
40
  url = CreateSend::CreateSend.authorize_url(client_id, redirect_uri, scope, state)
41
- url.should == "https://api.createsend.com/oauth?client_id=8998879&redirect_uri=http%3A%2F%2Fexample.com%2Fauth&scope=ViewReports%2CCreateCampaigns%2CSendCampaigns&state=89879287"
41
+ url.should be == "https://api.createsend.com/oauth?client_id=8998879&redirect_uri=http%3A%2F%2Fexample.com%2Fauth&scope=ViewReports%2CCreateCampaigns%2CSendCampaigns&state=89879287"
42
42
  end
43
43
 
44
44
  should "exchange an OAuth token for an access token, 'expires in' value, and refresh token" do
@@ -53,10 +53,10 @@ class CreateSendTest < Test::Unit::TestCase
53
53
  access_token, expires_in, refresh_token = CreateSend::CreateSend.exchange_token(
54
54
  client_id, client_secret, redirect_uri, code)
55
55
 
56
- FakeWeb.last_request.body.should == "grant_type=authorization_code&client_id=8998879&client_secret=iou0q9wud0q9wd0q9wid0q9iwd0q9wid0q9wdqwd&redirect_uri=http%3A%2F%2Fexample.com%2Fauth&code=jdiwouo8uowi9o9o"
57
- access_token.should == "SlAV32hkKG"
58
- expires_in.should == 1209600
59
- refresh_token.should == "tGzv3JOkF0XG5Qx2TlKWIA"
56
+ FakeWeb.last_request.body.should be == "grant_type=authorization_code&client_id=8998879&client_secret=iou0q9wud0q9wd0q9wid0q9iwd0q9wid0q9wdqwd&redirect_uri=http%3A%2F%2Fexample.com%2Fauth&code=jdiwouo8uowi9o9o"
57
+ access_token.should be == "SlAV32hkKG"
58
+ expires_in.should be == 1209600
59
+ refresh_token.should be == "tGzv3JOkF0XG5Qx2TlKWIA"
60
60
  end
61
61
 
62
62
  should "raise an error when an attempt to exchange an OAuth token for an access token fails" do
@@ -68,10 +68,10 @@ class CreateSendTest < Test::Unit::TestCase
68
68
  :body => fixture_file("oauth_exchange_token_error.json"),
69
69
  :content_type => "application/json; charset=utf-8" }
70
70
  FakeWeb.register_uri(:post, "https://api.createsend.com/oauth/token", options)
71
- lambda { access_token, expires_in, refresh_token = CreateSend::CreateSend.exchange_token(
71
+ lambda { CreateSend::CreateSend.exchange_token(
72
72
  client_id, client_secret, redirect_uri, code) }.should raise_error(
73
73
  Exception, 'Error exchanging code for access token: invalid_grant - Specified code was invalid or expired')
74
- FakeWeb.last_request.body.should == "grant_type=authorization_code&client_id=8998879&client_secret=iou0q9wud0q9wd0q9wid0q9iwd0q9wid0q9wdqwd&redirect_uri=http%3A%2F%2Fexample.com%2Fauth&code=invalidcode"
74
+ FakeWeb.last_request.body.should be == "grant_type=authorization_code&client_id=8998879&client_secret=iou0q9wud0q9wd0q9wid0q9iwd0q9wid0q9wdqwd&redirect_uri=http%3A%2F%2Fexample.com%2Fauth&code=invalidcode"
75
75
  end
76
76
 
77
77
  should "refresh an access token given a refresh token" do
@@ -82,10 +82,10 @@ class CreateSendTest < Test::Unit::TestCase
82
82
  FakeWeb.register_uri(:post, "https://api.createsend.com/oauth/token", options)
83
83
  new_access_token, new_expires_in, new_refresh_token = CreateSend::CreateSend.refresh_access_token refresh_token
84
84
 
85
- FakeWeb.last_request.body.should == "grant_type=refresh_token&refresh_token=#{ERB::Util.url_encode(refresh_token)}"
86
- new_access_token.should == "SlAV32hkKG2e12e"
87
- new_expires_in.should == 1209600
88
- new_refresh_token.should == "tGzv3JOkF0XG5Qx2TlKWIA"
85
+ FakeWeb.last_request.body.should be == "grant_type=refresh_token&refresh_token=#{ERB::Util.url_encode(refresh_token)}"
86
+ new_access_token.should be == "SlAV32hkKG2e12e"
87
+ new_expires_in.should be == 1209600
88
+ new_refresh_token.should be == "tGzv3JOkF0XG5Qx2TlKWIA"
89
89
  end
90
90
 
91
91
  should "raise an error when an attempt to refresh an access token fails" do
@@ -94,10 +94,10 @@ class CreateSendTest < Test::Unit::TestCase
94
94
  :body => fixture_file("oauth_refresh_token_error.json"),
95
95
  :content_type => "application/json; charset=utf-8" }
96
96
  FakeWeb.register_uri(:post, "https://api.createsend.com/oauth/token", options)
97
- lambda { access_token, expires_in, refresh_token = CreateSend::CreateSend.refresh_access_token(
97
+ lambda { CreateSend::CreateSend.refresh_access_token(
98
98
  refresh_token) }.should raise_error(
99
99
  Exception, 'Error refreshing access token: invalid_grant - Specified refresh_token was invalid or expired')
100
- FakeWeb.last_request.body.should == "grant_type=refresh_token&refresh_token=#{ERB::Util.url_encode(refresh_token)}"
100
+ FakeWeb.last_request.body.should be == "grant_type=refresh_token&refresh_token=#{ERB::Util.url_encode(refresh_token)}"
101
101
  end
102
102
 
103
103
  end
@@ -120,11 +120,11 @@ class CreateSendTest < Test::Unit::TestCase
120
120
  cs = CreateSend::CreateSend.new @auth
121
121
  new_access_token, new_expires_in, new_refresh_token = cs.refresh_token
122
122
 
123
- FakeWeb.last_request.body.should == "grant_type=refresh_token&refresh_token=#{ERB::Util.url_encode(@auth[:refresh_token])}"
124
- new_access_token.should == "SlAV32hkKG2e12e"
125
- new_expires_in.should == 1209600
126
- new_refresh_token.should == "tGzv3JOkF0XG5Qx2TlKWIA"
127
- cs.auth_details.should == {
123
+ FakeWeb.last_request.body.should be == "grant_type=refresh_token&refresh_token=#{ERB::Util.url_encode(@auth[:refresh_token])}"
124
+ new_access_token.should be == "SlAV32hkKG2e12e"
125
+ new_expires_in.should be == 1209600
126
+ new_refresh_token.should be == "tGzv3JOkF0XG5Qx2TlKWIA"
127
+ cs.auth_details.should be == {
128
128
  :access_token => new_access_token,
129
129
  :refresh_token => new_refresh_token
130
130
  }
@@ -132,19 +132,19 @@ class CreateSendTest < Test::Unit::TestCase
132
132
 
133
133
  should "raise an error when an attempt to refresh the access token is made but refresh token is nil" do
134
134
  cs = CreateSend::CreateSend.new :access_token => 'any token', :refresh_token => nil
135
- lambda { new_access_token, new_refresh_token = cs.refresh_token }.should raise_error(
135
+ lambda { cs.refresh_token }.should raise_error(
136
136
  Exception, '@auth_details[:refresh_token] does not contain a refresh token.')
137
137
  end
138
138
 
139
139
  should "raise an error when an attempt to refresh the access token is made but no there was no refresh token passed in" do
140
140
  cs = CreateSend::CreateSend.new :access_token => 'any token'
141
- lambda { new_access_token, new_refresh_token = cs.refresh_token }.should raise_error(
141
+ lambda { cs.refresh_token }.should raise_error(
142
142
  Exception, '@auth_details[:refresh_token] does not contain a refresh token.')
143
143
  end
144
144
 
145
145
  should "raise an error when an attempt to refresh the access token is made but no there was no auth hash passed in" do
146
146
  cs = CreateSend::CreateSend.new
147
- lambda { new_access_token, new_refresh_token = cs.refresh_token }.should raise_error(
147
+ lambda { cs.refresh_token }.should raise_error(
148
148
  Exception, '@auth_details[:refresh_token] does not contain a refresh token.')
149
149
  end
150
150
 
@@ -155,26 +155,26 @@ class CreateSendTest < Test::Unit::TestCase
155
155
  :body => fixture_file("oauth_refresh_token_error.json"),
156
156
  :content_type => "application/json; charset=utf-8" }
157
157
  FakeWeb.register_uri(:post, "https://api.createsend.com/oauth/token", options)
158
- lambda { access_token, expires_in, refresh_token = cs.refresh_token }.should raise_error(
158
+ lambda { refresh_token = cs.refresh_token }.should raise_error(
159
159
  Exception, 'Error refreshing access token: invalid_grant - Specified refresh_token was invalid or expired')
160
160
  end
161
161
 
162
162
  should "raise a CreateSend::InvalidOAuthToken error when an access token is invalid" do
163
163
  cs = CreateSend::CreateSend.new @auth
164
164
  stub_get(@auth, "countries.json", "invalid_oauth_token_api_error.json", ["401", "Unauthorized"])
165
- lambda { c = cs.countries }.should raise_error(CreateSend::InvalidOAuthToken)
165
+ lambda { cs.countries }.should raise_error(CreateSend::InvalidOAuthToken)
166
166
  end
167
167
 
168
168
  should "raise a CreateSend::ExpiredOAuthToken error when an access token is expired" do
169
169
  cs = CreateSend::CreateSend.new @auth
170
170
  stub_get(@auth, "countries.json", "expired_oauth_token_api_error.json", ["401", "Unauthorized"])
171
- lambda { c = cs.countries }.should raise_error(CreateSend::ExpiredOAuthToken)
171
+ lambda { cs.countries }.should raise_error(CreateSend::ExpiredOAuthToken)
172
172
  end
173
173
 
174
174
  should "raise a CreateSend::RevokedOAuthToken error when an access token is revoked" do
175
175
  cs = CreateSend::CreateSend.new @auth
176
176
  stub_get(@auth, "countries.json", "revoked_oauth_token_api_error.json", ["401", "Unauthorized"])
177
- lambda { c = cs.countries }.should raise_error(CreateSend::RevokedOAuthToken)
177
+ lambda { cs.countries }.should raise_error(CreateSend::RevokedOAuthToken)
178
178
  end
179
179
 
180
180
  end
@@ -185,76 +185,76 @@ class CreateSendTest < Test::Unit::TestCase
185
185
  end
186
186
 
187
187
  should "include the correct user agent string when making a call" do
188
- CreateSend::CreateSend.headers["User-Agent"].should ==
188
+ CreateSend::CreateSend.headers["User-Agent"].should be ==
189
189
  "createsend-ruby-#{CreateSend::VERSION}-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}-#{RUBY_PLATFORM}"
190
190
  stub_get(@auth, "clients.json", "clients.json")
191
191
  clients = @cs.clients
192
- clients.size.should == 2
192
+ clients.size.should be == 2
193
193
  end
194
194
 
195
195
  should "allow a custom user agent string to be set when making a call" do
196
196
  CreateSend::CreateSend.user_agent "custom user agent"
197
- CreateSend::CreateSend.headers["User-Agent"].should == "custom user agent"
197
+ CreateSend::CreateSend.headers["User-Agent"].should be == "custom user agent"
198
198
  stub_get(@auth, "clients.json", "clients.json")
199
199
  clients = @cs.clients
200
- clients.size.should == 2
200
+ clients.size.should be == 2
201
201
  CreateSend::CreateSend.user_agent nil
202
202
  end
203
203
 
204
204
  should "get all clients" do
205
205
  stub_get(@auth, "clients.json", "clients.json")
206
206
  clients = @cs.clients
207
- clients.size.should == 2
208
- clients.first.ClientID.should == '4a397ccaaa55eb4e6aa1221e1e2d7122'
209
- clients.first.Name.should == 'Client One'
207
+ clients.size.should be == 2
208
+ clients.first.ClientID.should be == '4a397ccaaa55eb4e6aa1221e1e2d7122'
209
+ clients.first.Name.should be == 'Client One'
210
210
  end
211
211
 
212
212
  should "get billing details" do
213
213
  stub_get(@auth, "billingdetails.json", "billingdetails.json")
214
214
  bd = @cs.billing_details
215
- bd.Credits.should == 3021
215
+ bd.Credits.should be == 3021
216
216
  end
217
217
 
218
218
  should "get all countries" do
219
219
  stub_get(@auth, "countries.json", "countries.json")
220
220
  countries = @cs.countries
221
- countries.size.should == 245
221
+ countries.size.should be == 245
222
222
  assert countries.include? "Australia"
223
223
  end
224
224
 
225
225
  should "get system date" do
226
226
  stub_get(@auth, "systemdate.json", "systemdate.json")
227
227
  systemdate = @cs.systemdate.SystemDate
228
- systemdate.should == "2010-10-15 09:27:00"
228
+ systemdate.should be == "2010-10-15 09:27:00"
229
229
  end
230
230
 
231
231
  should "get all timezones" do
232
232
  stub_get(@auth, "timezones.json", "timezones.json")
233
233
  timezones = @cs.timezones
234
- timezones.size.should == 97
234
+ timezones.size.should be == 97
235
235
  assert timezones.include? "(GMT+12:00) Fiji"
236
236
  end
237
237
 
238
238
  should "get all administrators" do
239
239
  stub_get(@auth, "admins.json", "administrators.json")
240
240
  administrators = @cs.administrators
241
- administrators.size.should == 2
242
- administrators.first.EmailAddress.should == "admin1@blackhole.com"
243
- administrators.first.Name.should == 'Admin One'
244
- administrators.first.Status.should == 'Active'
241
+ administrators.size.should be == 2
242
+ administrators.first.EmailAddress.should be == "admin1@blackhole.com"
243
+ administrators.first.Name.should be == 'Admin One'
244
+ administrators.first.Status.should be == 'Active'
245
245
  end
246
246
 
247
247
  should "set primary contact" do
248
248
  email = 'admin@blackhole.com'
249
249
  stub_put(@auth, "primarycontact.json?email=#{ERB::Util.url_encode(email)}", 'admin_set_primary_contact.json')
250
250
  result = @cs.set_primary_contact email
251
- result.EmailAddress.should == email
251
+ result.EmailAddress.should be == email
252
252
  end
253
253
 
254
254
  should "get primary contact" do
255
255
  stub_get(@auth, "primarycontact.json", 'admin_get_primary_contact.json')
256
256
  result = @cs.get_primary_contact
257
- result.EmailAddress.should == 'admin@blackhole.com'
257
+ result.EmailAddress.should be == 'admin@blackhole.com'
258
258
  end
259
259
 
260
260
  should "get an external session url" do
@@ -265,7 +265,7 @@ class CreateSendTest < Test::Unit::TestCase
265
265
  client_id = "9q8uw9d8u9wud"
266
266
  stub_put(@auth, "externalsession.json", "external_session.json")
267
267
  result = @cs.external_session_url email, chrome, url, integrator_id, client_id
268
- result.SessionUrl.should == "https://external1.createsend.com/cd/create/ABCDEF12/DEADBEEF?url=FEEDDAD1"
268
+ result.SessionUrl.should be == "https://external1.createsend.com/cd/create/ABCDEF12/DEADBEEF?url=FEEDDAD1"
269
269
  end
270
270
 
271
271
  end
@@ -287,7 +287,7 @@ class CreateSendTest < Test::Unit::TestCase
287
287
  context "#{status.first}, a get" do
288
288
  should "raise a #{exception.name} error" do
289
289
  stub_get(@auth, "countries.json", (status.first == '400' or status.first == '401') ? 'custom_api_error.json' : nil, status)
290
- lambda { c = @cs.countries }.should raise_error(exception)
290
+ lambda { @cs.countries }.should raise_error(exception)
291
291
  end
292
292
  end
293
293
 
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "EmailAddress": "subscriber@example.com",
3
3
  "Name": "Subscriber One",
4
+ "MobileNumber": "+61423153526",
4
5
  "Date": "2010-10-25 10:28:00",
5
6
  "ListJoinedDate": "2010-10-25 10:28:00",
6
7
  "State": "Active",
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "EmailAddress": "subscriber@example.com",
3
3
  "Name": "Subscriber One",
4
+ "MobileNumber": "+61423153526",
4
5
  "Date": "2010-10-25 10:28:00",
5
6
  "ListJoinedDate": "2010-10-25 10:28:00",
6
7
  "State": "Active",
@@ -19,5 +20,6 @@
19
20
  }
20
21
  ],
21
22
  "ReadsEmailWith": "Gmail",
22
- "ConsentToTrack": "Yes"
23
+ "ConsentToTrack": "Yes",
24
+ "ConsentToSendSms": "No"
23
25
  }