Sha256: ddf79ab2c3ecd7244d5dae43df14b7964e55971c8d9900e68a76f60ea428a1a1

Contents?: true

Size: 1.12 KB

Versions: 3

Compression:

Stored size: 1.12 KB

Contents

require 'test/unit'
require 'rubygems'
require 'mocha'
require 'delegate'
require 'ruby-debug'
require 'tempfile'
require File.dirname(__FILE__) + "/../lib/roflbot"

class FakeClient < Mocha::Mock
  attr_reader :on_im_block
  def on_im(&block)
    @on_im_block = block
  end
end

class Test::Unit::TestCase
  def setup
    @client = FakeClient.new
    @buddy = stub("Buddy")
    Net::TOC.stubs(:new).returns(@client)

    @oauth = stub("OAuth", :authorize_from_access => [])
    @twitter = stub("Twitter", :mentions => [])
    Twitter::OAuth.stubs(:new).returns(@oauth)
    Twitter::Base.stubs(:new).returns(@twitter)
  end

  def receive_im(message, auto = false)
    @client.on_im_block.call(message, @buddy, auto)
  end

  def fake_tweet(message, id)
    Hashie::Mash.new("user" => { "screen_name" => "dudeguy" }, "text" => "@roflbot #{message}", "id" => id)
  end

  def fixture_filename(name)
    File.dirname(__FILE__) + "/fixtures/#{name}"
  end

  def create_config(name)
    tmp = Tempfile.open("roflbot_config")
    file = File.open(fixture_filename(name), "r")
    tmp.write(file.read)
    file.close
    tmp.close
    tmp.path
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
roflbot-0.0.5 test/helper.rb
roflbot-0.0.4 test/helper.rb
roflbot-0.0.3 test/helper.rb