Sha256: 11d0516a9b2972c5313d2e5743473ad73340582b7b61ab22b4a83be0edca4837

Contents?: true

Size: 1.02 KB

Versions: 11

Compression:

Stored size: 1.02 KB

Contents

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

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

  def setup
    @connection = Robut::ConnectionMock.new
    @presence = Robut::PresenceMock.new(@connection)
    @plugin = Robut::Plugin::Say.new(@presence)
    @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.reply_to.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.reply_to.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

11 entries across 11 versions & 2 rubygems

Version Path
sclemmer-robut-0.6.3 test/unit/plugin/say_test.rb
sclemmer-robut-0.6.2 test/unit/plugin/say_test.rb
sclemmer-robut-0.6.1 test/unit/plugin/say_test.rb
sclemmer-robut-0.6.0 test/unit/plugin/say_test.rb
sclemmer-robut-0.5.4 test/unit/plugin/say_test.rb
sclemmer-robut-0.5.3 test/unit/plugin/say_test.rb
sclemmer-robut-0.5.2 test/unit/plugin/say_test.rb
robut-0.5.2 test/unit/plugin/say_test.rb
robut-0.5.1 test/unit/plugin/say_test.rb
robut-0.5.0 test/unit/plugin/say_test.rb
robut-0.4.0 test/unit/plugin/say_test.rb