Sha256: bd3fb2f0b7ee839bab2db2509549256d8319ac12388d910bb25679dc55440017

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

require File.dirname(__FILE__) + '/helper'

class TestEmail < Test::Unit::TestCase
  def test_exists
    Monitr::Contacts::Email
  end

  def test_unknown_delivery_method_for_notify
    assert_nothing_raised do
      Monitr::Contacts::Email.any_instance.expects(:notify_smtp).never
      Monitr::Contacts::Email.any_instance.expects(:notify_sendmail).never
      Monitr::Contacts::Email.delivery_method = :foo_protocol
      LOG.expects(:log).times(2)
 
      g = Monitr::Contacts::Email.new
      g.notify(:a, :b, :c, :d, :e)
      assert_nil g.info
    end
  end

  def test_smtp_delivery_method_for_notify
    assert_nothing_raised do
      Monitr::Contacts::Email.any_instance.expects(:notify_sendmail).never
      Monitr::Contacts::Email.any_instance.expects(:notify_smtp).once.returns(nil)
      Monitr::Contacts::Email.delivery_method = :smtp
      g = Monitr::Contacts::Email.new
      g.email = 'joe@example.com'
      g.notify(:a, :b, :c, :d, :e)
      assert_equal "sent email to joe@example.com", g.info
    end
  end
  
  def test_sendmail_delivery_method_for_notify
    assert_nothing_raised do
      Monitr::Contacts::Email.any_instance.expects(:notify_smtp).never
      Monitr::Contacts::Email.any_instance.expects(:notify_sendmail).once.returns(nil)
      Monitr::Contacts::Email.delivery_method = :sendmail
      g = Monitr::Contacts::Email.new
      g.email = 'joe@example.com'
      g.notify(:a, :b, :c, :d, :e)
      assert_equal "sent email to joe@example.com", g.info
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
monitr-0.0.1 test/test_email.rb