sendgrid_ruby 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,506 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require "test/unit"
3
+ require "./lib/sendgrid_ruby"
4
+ require "./lib/sendgrid_ruby/email"
5
+
6
+ class EmailTest < Test::Unit::TestCase
7
+
8
+ def test_initialize
9
+ email = SendgridRuby::Email.new
10
+ assert_equal(SendgridRuby::Email, email.class)
11
+ end
12
+
13
+ def test_add_to
14
+ email = SendgridRuby::Email.new
15
+
16
+ email.add_to('p1@mailinator.com')
17
+ assert_equal(['p1@mailinator.com'], email.get_tos)
18
+
19
+ email.add_to('p2@mailinator.com')
20
+ assert_equal(['p1@mailinator.com', 'p2@mailinator.com'], email.get_tos)
21
+ end
22
+
23
+ def test_remove_to
24
+ email = SendgridRuby::Email.new
25
+
26
+ email.add_to('p1@mailinator.com')
27
+ assert_equal(1, email.get_tos.length)
28
+ email.remove_to('p1@mailinator.com')
29
+ assert_equal(0, email.get_tos.length)
30
+ end
31
+
32
+ def test_add_to_with_name
33
+ email = SendgridRuby::Email.new
34
+
35
+ email.add_to('p1@mailinator.com', 'Person One')
36
+ assert_equal(['Person One <p1@mailinator.com>'], email.get_tos)
37
+
38
+ email.add_to('p2@mailinator.com')
39
+ assert_equal(['Person One <p1@mailinator.com>', 'p2@mailinator.com'], email.get_tos)
40
+ end
41
+
42
+ def test_set_to
43
+ email = SendgridRuby::Email.new
44
+ email.set_tos(['p1@mailinator.com'])
45
+ assert_equal(['p1@mailinator.com'], email.get_tos)
46
+ end
47
+
48
+ def test_set_tos
49
+ email = SendgridRuby::Email.new
50
+ email.set_tos(['p1@mailinator.com'])
51
+ assert_equal(['p1@mailinator.com'], email.get_tos)
52
+ end
53
+
54
+ def test_set_from
55
+ email = SendgridRuby::Email.new
56
+
57
+ email.set_from("foo@bar.com")
58
+ email.set_from_name("John Doe")
59
+
60
+ assert_equal("foo@bar.com", email.get_from)
61
+ assert_equal({"foo@bar.com" => "John Doe"}, email.get_from(true))
62
+ end
63
+
64
+ def test_set_from_name
65
+ email = SendgridRuby::Email.new
66
+
67
+ assert_equal(nil, email.get_from_name)
68
+ email.set_from_name("Swift")
69
+ assert_equal("Swift", email.get_from_name)
70
+ end
71
+
72
+ def test_set_reply_to
73
+ email = SendgridRuby::Email.new
74
+
75
+ assert_equal(nil, email.get_reply_to)
76
+ email.set_reply_to("swift@sendgrid.com")
77
+ assert_equal("swift@sendgrid.com", email.get_reply_to)
78
+ end
79
+
80
+ # def test_set_cc
81
+ # email = SendgridRuby::Email.new
82
+
83
+ # email.set_cc('p1@mailinator.com')
84
+ # email.set_cc('p2@mailinator.com')
85
+
86
+ # assert_equal(1, email.get_ccs.length)
87
+ # cc_list = email.get_ccs
88
+ # assert_equal('p2@mailinator.com', cc_list[0])
89
+ # end
90
+
91
+ # def test_set_ccs
92
+ # email = SendgridRuby::Email.new
93
+
94
+ # email.set_ccs(['raz@mailinator.com', 'ber@mailinator.com'])
95
+
96
+ # assert_equal(2, email.get_ccs.length)
97
+
98
+ # cc_list = email.get_ccs
99
+
100
+ # assert_equal('raz@mailinator.com', cc_list[0])
101
+ # assert_equal('ber@mailinator.com', cc_list[1])
102
+ # end
103
+
104
+ # def test_add_cc
105
+ # email = SendgridRuby::Email.new
106
+
107
+ # email.add_cc('foo')
108
+ # email.add_cc('raz')
109
+
110
+ # assert_equal(2, email.get_ccs.length)
111
+
112
+ # cc_list = email.get_ccs
113
+
114
+ # assert_equal('foo', cc_list[0])
115
+ # assert_equal('raz', cc_list[1])
116
+
117
+ # # removeTo removes all occurences of data
118
+ # email.remove_cc('raz')
119
+
120
+ # assert_equal(1, email.get_ccs.length)
121
+
122
+ # cc_list = email.get_ccs
123
+
124
+ # assert_equal('foo', cc_list[0])
125
+ # end
126
+
127
+ # def test_set_bcc
128
+ # email = SendgridRuby::Email.new
129
+
130
+ # email.set_bcc('bar')
131
+ # email.set_bcc('foo')
132
+ # assert_equal(1, email.get_bccs.length)
133
+
134
+ # bcc_list = email.get_bccs
135
+ # assert_equal('foo', bcc_list[0])
136
+ # end
137
+
138
+ # def test_set_bccs
139
+ # email = SendgridRuby::Email.new
140
+
141
+ # email.set_bccs(['raz', 'ber'])
142
+ # assert_equal(2, email.get_bccs.length)
143
+
144
+ # bcc_list = email.get_bccs
145
+ # assert_equal('raz', bcc_list[0])
146
+ # assert_equal('ber', bcc_list[1])
147
+ # end
148
+
149
+ # def test_add_bcc
150
+ # email = SendgridRuby::Email.new
151
+
152
+ # email.add_bcc('foo')
153
+ # email.add_bcc('raz')
154
+ # assert_equal(2, email.get_bccs.length)
155
+
156
+ # bcc_list = email.get_bccs
157
+ # assert_equal('foo', bcc_list[0])
158
+ # assert_equal('raz', bcc_list[1])
159
+
160
+ # email.remove_bcc('raz')
161
+
162
+ # assert_equal(1, email.get_bccs.length)
163
+ # bcc_list = email.get_bccs
164
+ # assert_equal('foo', bcc_list[0])
165
+ # end
166
+
167
+ def test_set_subject
168
+ email = SendgridRuby::Email.new
169
+
170
+ email.set_subject("Test Subject")
171
+ assert_equal("Test Subject", email.get_subject)
172
+ end
173
+
174
+ def test_set_text
175
+ email = SendgridRuby::Email.new
176
+
177
+ text = "sample plain text"
178
+ email.set_text(text)
179
+ assert_equal(text, email.get_text)
180
+ end
181
+
182
+ def test_set_html
183
+ email = SendgridRuby::Email.new
184
+
185
+ html = "<p style = 'color:red;'>Sample HTML text</p>"
186
+ email.set_html(html)
187
+ assert_equal(html, email.get_html)
188
+ end
189
+
190
+ def test_set_attachments
191
+ email = SendgridRuby::Email.new
192
+
193
+ attachments =
194
+ [
195
+ "test/file1.txt",
196
+ "test/file2.txt",
197
+ "test/file3.txt"
198
+ ]
199
+
200
+ email.set_attachments(attachments)
201
+ msg_attachments = email.get_attachments
202
+ assert_equal(attachments.length, msg_attachments.length)
203
+
204
+ for i in 0...attachments.length
205
+ assert_equal(attachments[i], msg_attachments[i]['file'])
206
+ end
207
+ end
208
+
209
+ def test_set_attachments_with_custom_filename
210
+ email = SendgridRuby::Email.new
211
+
212
+ attachments =
213
+ {
214
+ "customName.txt" => "test/file1.txt",
215
+ 'another_name_|.txt' => "test/file2.txt",
216
+ 'custom_name_2.zip' => "test/file3.txt"
217
+ }
218
+
219
+ email.set_attachments(attachments)
220
+ msg_attachments = email.get_attachments
221
+
222
+ assert_equal('customName.txt', msg_attachments[0]['custom_filename'])
223
+ assert_equal('another_name_|.txt', msg_attachments[1]['custom_filename'])
224
+ assert_equal('custom_name_2.zip', msg_attachments[2]['custom_filename'])
225
+ end
226
+
227
+ def test_add_attachment
228
+ email = SendgridRuby::Email.new
229
+
230
+ email.add_attachment("test/file1.txt")
231
+ attachments = ["test/file1.txt"]
232
+ msg_attachments = email.get_attachments
233
+ assert_equal(attachments.length, msg_attachments.length)
234
+ assert_equal(attachments[-1], msg_attachments[-1]['file'])
235
+ assert_equal("test", msg_attachments[-1]['dirname'])
236
+ assert_equal("file1.txt", msg_attachments[-1]['basename'])
237
+ assert_equal(".txt", msg_attachments[-1]['extension'])
238
+ assert_equal("file1", msg_attachments[-1]['filename'])
239
+ end
240
+
241
+ def test_add_attachment_custom_filename
242
+ email = SendgridRuby::Email.new
243
+
244
+ email.add_attachment("test/file1.txt", "different.txt")
245
+
246
+ attachments = email.get_attachments
247
+ assert_equal('different.txt', attachments[0]['custom_filename'])
248
+ assert_equal('file1', attachments[0]['filename'])
249
+ end
250
+
251
+ def test_set_attachment
252
+ email = SendgridRuby::Email.new
253
+
254
+ # Setting an attachment removes all other files
255
+ email.set_attachment("only_attachment.sad")
256
+
257
+ assert_equal(1, email.get_attachments.length)
258
+
259
+ # Remove an attachment
260
+ email.remove_attachment("only_attachment.sad")
261
+ assert_equal(0, email.get_attachments.length)
262
+ end
263
+
264
+ def test_set_attachment_custom_filename
265
+ email = SendgridRuby::Email.new
266
+
267
+ # Setting an attachment removes all other files
268
+ email.set_attachment("only_attachment.sad", "different")
269
+
270
+ attachments = email.get_attachments
271
+ assert_equal(1, attachments.length)
272
+ assert_equal('different', attachments[0]['custom_filename'])
273
+
274
+ # Remove an attachment
275
+ email.remove_attachment("only_attachment.sad")
276
+ assert_equal(0, email.get_attachments.length)
277
+ end
278
+
279
+
280
+ def test_add_attachment_without_extension
281
+ email = SendgridRuby::Email.new
282
+
283
+ # ensure that addAttachment appends to the list of attachments
284
+ email.add_attachment("../file_4")
285
+
286
+ attachments = ["../file_4"]
287
+
288
+ msg_attachments = email.get_attachments
289
+ assert_equal(attachments[-1], msg_attachments[-1]['file'])
290
+ end
291
+
292
+ def test_category_accessors
293
+ email = SendgridRuby::Email.new
294
+
295
+ email.set_categories(['category_0'])
296
+ assert_equal('{"category":["category_0"]}', email.smtpapi.json_string)
297
+
298
+ categories = [
299
+ "category_1",
300
+ "category_2",
301
+ "category_3",
302
+ "category_4"
303
+ ]
304
+
305
+ email.set_categories(categories)
306
+
307
+ # uses valid json
308
+ assert_equal('{"category":["category_1","category_2","category_3","category_4"]}', email.smtpapi.json_string)
309
+ end
310
+
311
+ def test_substitution_accessors
312
+ email = SendgridRuby::Email.new
313
+
314
+ substitutions = {
315
+ "sub_1" => ["val_1.1", "val_1.2", "val_1.3"],
316
+ "sub_2" => ["val_2.1", "val_2.2"],
317
+ "sub_3" => ["val_3.1", "val_3.2", "val_3.3", "val_3.4"],
318
+ "sub_4" => ["val_4.1", "val_4.2", "val_4.3"]
319
+ }
320
+
321
+ email.set_substitutions(substitutions)
322
+
323
+ assert_equal('{"sub":{"sub_1":["val_1.1","val_1.2","val_1.3"],"sub_2":["val_2.1","val_2.2"],"sub_3":["val_3.1","val_3.2","val_3.3","val_3.4"],"sub_4":["val_4.1","val_4.2","val_4.3"]}}', email.smtpapi.json_string)
324
+ end
325
+
326
+ def test_section_accessors
327
+ email = SendgridRuby::Email.new
328
+
329
+ sections = {
330
+ "sub_1" => ["val_1.1", "val_1.2", "val_1.3"],
331
+ "sub_2" => ["val_2.1", "val_2.2"],
332
+ "sub_3" => ["val_3.1", "val_3.2", "val_3.3", "val_3.4"],
333
+ "sub_4" => ["val_4.1", "val_4.2", "val_4.3"]
334
+ }
335
+
336
+ email.set_sections(sections)
337
+
338
+ assert_equal('{"section":{"sub_1":["val_1.1","val_1.2","val_1.3"],"sub_2":["val_2.1","val_2.2"],"sub_3":["val_3.1","val_3.2","val_3.3","val_3.4"],"sub_4":["val_4.1","val_4.2","val_4.3"]}}', email.smtpapi.json_string)
339
+ end
340
+
341
+ def test_unique_args_accessors
342
+ email = SendgridRuby::Email.new
343
+
344
+ unique_arguments = {
345
+ "sub_1" => ["val_1.1", "val_1.2", "val_1.3"],
346
+ "sub_2" => ["val_2.1", "val_2.2"],
347
+ "sub_3" => ["val_3.1", "val_3.2", "val_3.3", "val_3.4"],
348
+ "sub_4" => ["val_4.1", "val_4.2", "val_4.3"]
349
+ }
350
+
351
+ email.set_unique_args(unique_arguments)
352
+
353
+ assert_equal('{"unique_args":{"sub_1":["val_1.1","val_1.2","val_1.3"],"sub_2":["val_2.1","val_2.2"],"sub_3":["val_3.1","val_3.2","val_3.3","val_3.4"],"sub_4":["val_4.1","val_4.2","val_4.3"]}}', email.smtpapi.json_string)
354
+
355
+ email.add_unique_arg('uncle', 'bob')
356
+
357
+ assert_equal('{"unique_args":{"sub_1":["val_1.1","val_1.2","val_1.3"],"sub_2":["val_2.1","val_2.2"],"sub_3":["val_3.1","val_3.2","val_3.3","val_3.4"],"sub_4":["val_4.1","val_4.2","val_4.3"],"uncle":"bob"}}', email.smtpapi.json_string)
358
+ end
359
+
360
+ def test_header_accessors
361
+ # A new message shouldn't have any RFC-822 headers set
362
+ message = SendgridRuby::Email.new
363
+ assert_equal('{}', message.smtpapi.json_string)
364
+
365
+ # Add some message headers, check they are correctly stored
366
+ headers = {
367
+ 'X-Sent-Using' => 'SendgridRuby-API',
368
+ 'X-Transport' => 'web',
369
+ }
370
+ message.set_headers(headers)
371
+ assert_equal(headers, message.get_headers)
372
+
373
+ # Add another header, check if it is stored
374
+ message.add_header('X-Another-Header', 'first_value')
375
+ headers['X-Another-Header'] = 'first_value'
376
+ assert_equal(headers, message.get_headers)
377
+
378
+ # Replace a header
379
+ message.add_header('X-Another-Header', 'second_value')
380
+ headers['X-Another-Header'] = 'second_value'
381
+ assert_equal(headers, message.get_headers)
382
+
383
+ # Get the encoded headers; they must be a valid JSON
384
+ json = message.get_headers_json
385
+ decoded = JSON.parse(json)
386
+ assert_equal(true, decoded.instance_of?(Hash))
387
+ # Test we get the same message headers we put in the message
388
+ assert_equal(headers, decoded)
389
+
390
+ # Remove a header
391
+ message.remove_header('X-Transport')
392
+ headers.delete('X-Transport')
393
+ assert_equal(headers, message.get_headers)
394
+ end
395
+
396
+ def test_to_web_format_empty
397
+ email = SendgridRuby::Email.new
398
+ json = email.to_web_format
399
+ xsmtpapi = JSON.parse(json["x-smtpapi"])
400
+ assert_equal(nil, xsmtpapi['to'])
401
+ assert_equal(nil, json['to'])
402
+ assert_equal(nil, json['from'])
403
+ assert_equal(nil, json['subject'])
404
+ assert_equal(nil, json['text'])
405
+ assert_equal(nil, json['html'])
406
+ assert_equal("{}", json['headers'])
407
+ # assert_equal([], json['cc'])
408
+ # assert_equal([], json['bcc'])
409
+ assert_equal(nil, json['fromname'])
410
+ assert_equal(nil, json['replyto'])
411
+ end
412
+
413
+ def test_to_web_format_with_to
414
+ email = SendgridRuby::Email.new
415
+ email.add_to('foo@bar.com')
416
+ email.set_from('from@site.com')
417
+ json = email.to_web_format
418
+ xsmtpapi = JSON.parse(json["x-smtpapi"])
419
+
420
+ assert_equal(['foo@bar.com'], xsmtpapi['to'])
421
+ assert_equal('from@site.com', json['to'])
422
+ assert_equal('from@site.com', json['from'])
423
+ end
424
+
425
+ def test_to_web_format_with_multi_to
426
+ email = SendgridRuby::Email.new
427
+ email.add_to('foo@bar.com')
428
+ email.add_to('bar@site.com')
429
+ json = email.to_web_format
430
+ xsmtpapi = JSON.parse(json["x-smtpapi"])
431
+
432
+ assert_equal(['foo@bar.com','bar@site.com'], xsmtpapi['to'])
433
+ assert_equal(nil, json['to'])
434
+ end
435
+
436
+ def test_to_web_format_with_to_fromname_and_replyto
437
+ email = SendgridRuby::Email.new
438
+ email.add_to('foo@bar.com')
439
+ email.set_from('from@site.com')
440
+ email.set_from_name('From Taro')
441
+ email.set_reply_to('replyto@site.com')
442
+ json = email.to_web_format
443
+
444
+ assert_equal('From Taro', json['fromname'])
445
+ assert_equal('replyto@site.com', json['replyto'])
446
+ end
447
+
448
+ # def test_to_web_format_with_to_cc_and_bcc
449
+ # email = SendgridRuby::Email.new
450
+ # email.add_to('p1@mailinator.com')
451
+ # email.add_bcc('p2@mailinator.com')
452
+ # email.add_cc('p3@mailinator.com')
453
+ # json = email.to_web_format
454
+
455
+ # assert_equal(['p2@mailinator.com'], json['bcc'])
456
+ # assert_equal(['p3@mailinator.com'], json['cc'])
457
+ # assert_equal('{"to":["p1@mailinator.com"]}', json["x-smtpapi"])
458
+ # end
459
+
460
+ def test_to_web_format_with_attachment
461
+ email = SendgridRuby::Email.new
462
+ email.add_attachment('./test/gif.gif')
463
+ json = email.to_web_format
464
+
465
+ assert_equal(File.new("./test/gif.gif").path, json["files[gif.gif]"].path)
466
+ end
467
+
468
+ def test_to_web_format_with_attachment_custom_filename
469
+ email = SendgridRuby::Email.new
470
+ email.add_attachment('./test/gif.gif', 'different.jpg')
471
+ json = email.to_web_format
472
+
473
+ assert_equal(File.new("./test/gif.gif").path, json["files[different.jpg]"].path)
474
+ end
475
+
476
+ def test_to_web_format_with_subject_and_body
477
+ email = SendgridRuby::Email.new
478
+ email.set_subject("This is the subject")
479
+ email.set_text("This is the text of body")
480
+ email.set_html("<strong>This is the html of body</strong>")
481
+ json = email.to_web_format
482
+
483
+ assert_equal("This is the subject", json['subject'])
484
+ assert_equal("This is the text of body", json['text'])
485
+ assert_equal("<strong>This is the html of body</strong>", json['html'])
486
+ end
487
+
488
+ def test_to_web_format_with_headers
489
+ email = SendgridRuby::Email.new
490
+ email.add_header('X-Sent-Using', 'SendgridRuby-API')
491
+ json = email.to_web_format
492
+
493
+ headers = JSON.parse(json['headers'])
494
+ assert_equal('SendgridRuby-API', headers['X-Sent-Using'])
495
+ end
496
+
497
+ def test_to_web_format_with_filters
498
+ email = SendgridRuby::Email.new
499
+ email.add_filter("footer", "text/plain", "Here is a plain text footer")
500
+ json = email.to_web_format
501
+
502
+ xsmtpapi = JSON.parse(json['x-smtpapi'])
503
+ assert_equal('Here is a plain text footer', xsmtpapi['filters']['footer']['settings']['text/plain'])
504
+ end
505
+
506
+ end
@@ -0,0 +1,130 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require "test/unit"
3
+ require "./lib/sendgrid_ruby"
4
+ require "./lib/sendgrid_ruby/version"
5
+ require "./lib/sendgrid_ruby/email"
6
+
7
+ class SendgridRubyTest < Test::Unit::TestCase
8
+
9
+ def test_version
10
+ assert_equal("0.0.1", SendgridRuby::VERSION)
11
+ end
12
+
13
+ def test_initialize
14
+ sendgrid = SendgridRuby::Sendgrid.new("user", "pass")
15
+ assert_equal(SendgridRuby::Sendgrid, sendgrid.class)
16
+ end
17
+
18
+ def test_send_bad_credential
19
+ email = SendgridRuby::Email.new
20
+ email.set_from('bar@foo.com').
21
+ set_subject('test_send_bad_credential subject').
22
+ set_text('foobar text').
23
+ add_to('foo@bar.com')
24
+
25
+ sendgrid = SendgridRuby::Sendgrid.new("user", "pass")
26
+ sendgrid.debug_output = true
27
+ assert_raise RestClient::BadRequest do
28
+ sendgrid.send(email)
29
+ end
30
+ end
31
+
32
+ def test_send
33
+ email = SendgridRuby::Email.new
34
+ email.set_from(@from).
35
+ set_subject('test_send subject').
36
+ set_text('foobar text').
37
+ add_to(@to)
38
+
39
+ sendgrid = SendgridRuby::Sendgrid.new("user", "pass")
40
+ sendgrid.debug_output = true
41
+ assert_raise RestClient::BadRequest do
42
+ sendgrid.send(email)
43
+ end
44
+ end
45
+
46
+ def test_send_with_attachment_text
47
+ email = SendgridRuby::Email.new
48
+ email.set_from(@from).
49
+ set_subject('test_send_with_attachment_text subject').
50
+ set_text('foobar text').
51
+ add_to(@to).
52
+ add_attachment('./test/file1.txt')
53
+
54
+ sendgrid = SendgridRuby::Sendgrid.new("user", "pass")
55
+ sendgrid.debug_output = true
56
+ assert_raise RestClient::BadRequest do
57
+ sendgrid.send(email)
58
+ end
59
+ end
60
+
61
+ def test_send_with_attachment_binary
62
+ email = SendgridRuby::Email.new
63
+ email.set_from(@from).
64
+ set_subject('test_send_with_attachment subject').
65
+ set_text('foobar text').
66
+ add_to(@to).
67
+ add_attachment('./test/gif.gif')
68
+
69
+ sendgrid = SendgridRuby::Sendgrid.new("user", "pass")
70
+ sendgrid.debug_output = true
71
+ assert_raise RestClient::BadRequest do
72
+ sendgrid.send(email)
73
+ end
74
+ end
75
+
76
+ def test_send_with_attachment_missing_extension
77
+ email = SendgridRuby::Email.new
78
+ email.set_from(@from).
79
+ set_subject('test_send_with_attachment_missing_extension subject').
80
+ set_text('foobar text').
81
+ add_to(@to).
82
+ add_attachment('./test/gif')
83
+
84
+ sendgrid = SendgridRuby::Sendgrid.new("user", "pass")
85
+ sendgrid.debug_output = true
86
+ assert_raise RestClient::BadRequest do
87
+ sendgrid.send(email)
88
+ end
89
+ end
90
+
91
+ def test_send_with_ssl_option_false
92
+ email = SendgridRuby::Email.new
93
+ email.set_from(@from).
94
+ set_subject('test_send_with_ssl_option_false subject').
95
+ set_text('foobar text').
96
+ add_to(@to)
97
+
98
+ sendgrid = SendgridRuby::Sendgrid.new("user", "pass", {"turn_off_ssl_verification" => true})
99
+ sendgrid.debug_output = true
100
+ assert_raise RestClient::BadRequest do
101
+ sendgrid.send(email)
102
+ end
103
+ end
104
+
105
+ def test_send_unicode
106
+ email = SendgridRuby::Email.new
107
+ email.add_to(@to)
108
+ .set_from(@from)
109
+ .set_from_name("送信者名")
110
+ .set_subject("[sendgrid-ruby-example] フクロウのお名前はfullnameさん")
111
+ .set_text("familyname さんは何をしていますか?\r\n 彼はplaceにいます。")
112
+ .set_html("<strong> familyname さんは何をしていますか?</strong><br />彼はplaceにいます。")
113
+ .add_substitution("fullname", ["田中 太郎", "佐藤 次郎", "鈴木 三郎"])
114
+ .add_substitution("familyname", ["田中", "佐藤", "鈴木"])
115
+ .add_substitution("place", ["office", "home", "office"])
116
+ .add_section('office', '中野')
117
+ .add_section('home', '目黒')
118
+ .add_category('カテゴリ1')
119
+ .add_header('X-Sent-Using', 'SendgridRuby-API')
120
+ .add_attachment('./test/gif.gif', 'owl.gif')
121
+
122
+ sendgrid = SendgridRuby::Sendgrid.new("user", "pass")
123
+ sendgrid.debug_output = true
124
+ assert_raise RestClient::BadRequest do
125
+ sendgrid.send(email)
126
+ end
127
+
128
+ end
129
+
130
+ end