Sha256: 35054c9e9c72b49e02539b90883bb5c8154dc5110d69df1a57637f41cb5fb60d
Contents?: true
Size: 1.81 KB
Versions: 2
Compression:
Stored size: 1.81 KB
Contents
require "#{File.dirname(__FILE__)}/test_helper" require 'mail' module Messenger class EmailTest < Test::Unit::TestCase context "Email notification" do setup do Mail.defaults do delivery_method :test end end should "send an email" do Email.send("mailto:to_test@example.com", "Test message", :email_from => "from_test@example.com", :email_subject => "Test") assert_equal 1, Mail::TestMailer.deliveries.length assert_equal ["to_test@example.com"], Mail::TestMailer.deliveries.first.to assert_equal ["from_test@example.com"], Mail::TestMailer.deliveries.first.from assert_equal "Test", Mail::TestMailer.deliveries.first.subject assert_equal "Test message", Mail::TestMailer.deliveries.first.body.to_s end should "raise if trying to send to an invalid URL" do assert_raises URLError do Email.send("mailto:test", :body => "whatever", :email_from => "from_test@example.com", :email_subject => "Test") end end should "obfuscate the URL" do assert_equal "mailto:test@example.com", Email.obfuscate("mailto:test@example.com") end should "raise if trying obfuscate an invalid URL" do assert_raises URLError do Email.obfuscate("mailto:test") end end end context "Email notificaiton URL validation" do should "return true for good URLs" do assert true, Email.valid_url?("mailto:test@example.com") end should "return false for bad URLs" do assert_equal false, Email.valid_url?("mailto:") assert_equal false, Email.valid_url?("mailto:test") assert_equal false, Email.valid_url?("mailto:@example.com") assert_equal false, Email.valid_url?("mailto:example.com") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
messenger-0.1.1 | test/test_email.rb |
messenger-0.1.0 | test/test_email.rb |