Sha256: a8129fe808ca79bb0e5c6f68f2bb27e3e15ad50b45383eccb4f578cce018d051

Contents?: true

Size: 996 Bytes

Versions: 1

Compression:

Stored size: 996 Bytes

Contents

require 'test_helper'
require 'robut/plugin/say'

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

  def setup
    @connection = Robut::ConnectionMock.new
    @plugin = Robut::Plugin::Say.new(@connection)
    @plugin.instance_eval do
      # Stub out system
      def system(c); system_calls << c; end
      def system_calls; @system_calls ||= []; end;
    end
  end

  def test_says_stuff
    @plugin.handle(Time.now, "@john", "@robut say stuff")
    assert_equal [], @plugin.connection.replies # shouldn't reply to the chat room
    assert_equal ["say stuff"], @plugin.system_calls
  end
  
  def test_doesnt_say_stuff
    @plugin.handle(Time.now, "@john", "@robut ok don't say stuff")
    assert_equal [], @plugin.connection.replies
    assert_equal [], @plugin.system_calls
  end
  
  def test_strips_bad_chars
    @plugin.handle(Time.now, "@john", "@robut say it's time for $%@ more_test 123 p\"")
    assert_equal ["say its time for more test 123 p"], @plugin.system_calls
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
robut-0.3.0 test/unit/plugin/say_test.rb