-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathdescription_spec.rb
39 lines (25 loc) · 1 KB
/
description_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require 'spec_helper'
describe SparkPostRails::DeliveryMethod do
before(:each) do
@delivery_method = SparkPostRails::DeliveryMethod.new
end
context "Description" do
it "handles value from message" do
test_email = Mailer.test_email sparkpost_data: {description: "Test Email"}
@delivery_method.deliver!(test_email)
expect(@delivery_method.data[:description]).to eq("Test Email")
end
it "truncates values longer than 1024 characters" do
raw_description = "X" * 1050
truncated_description = ("X" * 1021) + "..."
test_email = Mailer.test_email sparkpost_data: {description: raw_description}
@delivery_method.deliver!(test_email)
expect(@delivery_method.data[:description]).to eq(truncated_description)
end
it "does not include description element if not supplied" do
test_email = Mailer.test_email
@delivery_method.deliver!(test_email)
expect(@delivery_method.data.has_key?(:description)).to eq(false)
end
end
end