test/test.rb in smtpapi-0.1.0 vs test/test.rb in smtpapi-0.1.1
- old
+ new
@@ -1,15 +1,14 @@
-# -*- encoding: utf-8 -*-
require 'test/unit'
require './lib/smtpapi'
#
# SmtpapiTest implementation
#
class SmtpapiTest < Test::Unit::TestCase
def test_version
- assert_equal('0.1.0', Smtpapi::VERSION)
+ assert_equal('0.1.1', Smtpapi::VERSION)
end
def test_empty
header = Smtpapi::Header.new
assert_equal('{}', header.json_string)
@@ -19,36 +18,40 @@
header = Smtpapi::Header.new
header.add_to('you@youremail.com')
header.add_to('other@otheremail.com', 'Other Name')
assert_equal(
'{"to":["you@youremail.com","Other Name <other@otheremail.com>"]}',
- header.json_string)
+ header.json_string
+ )
end
def test_add_to_array
header = Smtpapi::Header.new
header.add_to(['you@youremail.com', 'my@myemail.com'])
assert_equal(
'{"to":["you@youremail.com","my@myemail.com"]}',
- header.json_string)
+ header.json_string
+ )
end
def test_set_tos
header = Smtpapi::Header.new
header.set_tos(['you@youremail.com', 'other@otheremail.com'])
assert_equal(
'{"to":["you@youremail.com","other@otheremail.com"]}',
- header.json_string)
+ header.json_string
+ )
end
def test_add_substitution
header = Smtpapi::Header.new
header.add_substitution('keep', ['secret'])
header.add_substitution('other', %w(one two))
assert_equal(
'{"sub":{"keep":["secret"],"other":["one","two"]}}',
- header.json_string)
+ header.json_string
+ )
end
def test_set_substitutions
header = Smtpapi::Header.new
header.set_substitutions('keep' => ['secret'])
@@ -61,11 +64,12 @@
header.add_section('-bomber-', 'Only for sad vikings.')
assert_equal(
'{"section":'\
'{"-charge-":"This ship is useless.",'\
'"-bomber-":"Only for sad vikings."}}',
- header.json_string)
+ header.json_string
+ )
end
def test_set_sections
header = Smtpapi::Header.new
header.set_sections('-charge-' => 'This ship is useless.')
@@ -173,13 +177,13 @@
assert_equal("{\"send_at\":#{localtime.to_i}}", header.json_string)
end
def test_send_each_at
header = Smtpapi::Header.new
- localtime1 = Time.local(2014, 8, 29, 17, 56, 35)
- localtime2 = Time.local(2013, 12, 31, 0, 0, 0)
- localtime3 = Time.local(2015, 9, 1, 4, 5, 6)
+ localtime1 = Time.local(2014, 8, 29, 17, 56, 35)
+ localtime2 = Time.local(2013, 12, 31, 0, 0, 0)
+ localtime3 = Time.local(2015, 9, 1, 4, 5, 6)
header.set_send_each_at([localtime1, localtime2, localtime3])
assert_equal(
'{"send_each_at":'\
"[#{localtime1.to_i},#{localtime2.to_i},#{localtime3.to_i}]"\
@@ -198,7 +202,83 @@
def test_ip_pool
header = Smtpapi::Header.new
header.set_ip_pool('test_pool')
assert_equal('{"ip_pool":"test_pool"}', header.json_string)
+ end
+
+ # def test_docker_exists
+ # assert(File.file?('./Dockerfile') || File.file?('./docker/Dockerfile'))
+ # end
+
+ # def test_docker_compose_exists
+ # assert(
+ # File.file?('./docker-compose.yml') ||
+ # File.file?('./docker/docker-compose.yml')
+ # )
+ # end
+
+ def test_env_sample_exists
+ assert(File.file?('./.env_sample'))
+ end
+
+ def test_gitignore_exists
+ assert(File.file?('./.gitignore'))
+ end
+
+ def test_travis_exists
+ assert(File.file?('./.travis.yml'))
+ end
+
+ def test_codeclimate_exists
+ assert(File.file?('./.codeclimate.yml'))
+ end
+
+ def test_changelog_exists
+ assert(File.file?('./CHANGELOG.md'))
+ end
+
+ def test_code_of_conduct_exists
+ assert(File.file?('./CODE_OF_CONDUCT.md'))
+ end
+
+ def test_contributing_exists
+ assert(File.file?('./CONTRIBUTING.md'))
+ end
+
+ def test_issue_template_exists
+ assert(File.file?('./.github/ISSUE_TEMPLATE'))
+ end
+
+ def test_license_exists
+ assert(File.file?('./LICENSE.md') || File.file?('./LICENSE.txt'))
+ end
+
+ def test_pull_request_template_exists
+ assert(File.file?('./.github/PULL_REQUEST_TEMPLATE'))
+ end
+
+ def test_readme_exists
+ assert(File.file?('./README.md'))
+ end
+
+ def test_troubleshooting_exists
+ assert(File.file?('./TROUBLESHOOTING.md'))
+ end
+
+ # def test_usage_exists
+ # assert(File.file?('./USAGE.md'))
+ # end
+
+ # def test_use_cases_exists
+ # assert(File.file?('./USE_CASES.md'))
+ # end
+
+ def test_license_date_is_updated
+ license_end_year = IO.read('LICENSE.txt').match(
+ /Copyright \(c\) \d{4}-(\d{4}) Twilio SendGrid/
+ )[1]
+ current_year = Time.new.year
+
+ assert_equal(current_year, license_end_year.to_i)
end
end