Sha256: 1e33b645be28bd3ad752a87b86a714bed5b09ac42f72440365e114ab242a9794

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

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

class TestNotify < Test::Unit::TestCase
  include Biobot::Periodicals::Notify

  def setup
    @model = Biobot::Periodicals::Notify::Notification
    @model.stubs(:inspect).returns('Notification')
    @client = stub('Jabber::Client')
    @server = 'localhost'
  end

  def test_handling_notifications
    notification_1 = mock("notification", :to => 'foo@localhost', :body => 'huge')
    notification_2 = mock("notification", :to => 'bar', :body => 'small')
    @model.expects(:count).returns(2)
    @model.expects(:all).returns([notification_1, notification_2])
    outgoing_1 = mock_message('biobot@localhost', 'huge')
    outgoing_2 = mock_message('biobot@localhost', 'small')
    Jabber::Message.expects(:new).with('foo@localhost', 'huge').returns(outgoing_1)
    Jabber::Message.expects(:new).with('bar@localhost', 'small').returns(outgoing_2)
    @client.expects(:send).with(outgoing_1)
    @client.expects(:send).with(outgoing_2)
    @model.expects(:delete_all)

    handle_notifications
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
viking-biobot-0.0.3 test/biobot/periodicals/test_notify.rb
viking-biobot-0.0.4 test/biobot/periodicals/test_notify.rb