Sha256: fe4ad8bd4f022137cb8f26e5d982d63ce8490d4cfe655795e7febdda1ede1bcb

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

require 'test_helper'
require 'robut/plugin/later'

class Robut::Plugin::LaterTest < Test::Unit::TestCase

  def setup
    @connection = Robut::ConnectionMock.new
    @plugin = Robut::Plugin::Later.new(@connection)
    @plugin.instance_eval do
      def threader; yield; end # no threads
      def sleep(*prms); end # just skip the whole sleeping part
    end
  end

  def test_replies_with_minutes
    @plugin.handle(Time.now, "@john", "@robut in 0 minutes msg me")
    assert_equal ["Ok, see you in 0 minutes"], @plugin.connection.replies
    message = @plugin.connection.messages.first
    assert message
    assert_equal message[1], "@john"
    assert_equal message[2], "@robut msg me"
  end

  def test_replies_with_sec
    @plugin.handle(Time.now, "@john", "@robut in 1 sec msg me")
    assert_equal ["Ok, see you in 1 sec"], @plugin.connection.replies
  end
  
  def test_replies_with_hr
    @plugin.handle(Time.now, "@john", "@robut in 1 hr msg me")
    assert_equal ["Ok, see you in 1 hr"], @plugin.connection.replies
  end

  def test_replies_with_hrs
    @plugin.handle(Time.now, "@john", "@robut in 2 hrs msg me")
    assert_equal ["Ok, see you in 2 hrs"], @plugin.connection.replies
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
robut-0.3.0 test/unit/plugin/later_test.rb
robut-0.2.1 test/unit/plugin/later_test.rb
robut-0.2.0 test/unit/plugin/later_test.rb