Sha256: 2c879d598f83912d6f9e31088ec738f7bad91c8441347fbf611065c47c0acad0

Contents?: true

Size: 1.06 KB

Versions: 9

Compression:

Stored size: 1.06 KB

Contents

require File.dirname(__FILE__) + '/test_helper.rb'

class TestTw < Test::Unit::TestCase

  def setup
    @client = Tw::Client.new
    @client.auth
  end

  def user?(str)
    return false unless str.kind_of? String
    str =~ /^[a-zA-Z0-9_]+$/
  end

  def response?(arr)
    return false unless arr.kind_of? Array
    arr.each do |i|
      return false if !(i[:id].class == Fixnum and
                        (user? i[:user] or (user? i[:user][:to] and user? i[:user][:from])) and
                        i[:text].kind_of? String and
                        i[:time].kind_of? Time)
    end
    return true
  end
  
  def test_mentions
    assert response? @client.mentions
  end

  def test_home_timeline
    assert response? @client.home_timeline
  end

  def test_search
    assert response? @client.search('ruby')
  end

  def test_user_timeline
    assert response? @client.user_timeline 'shokai'
  end

  def test_list_timeline
    assert response? @client.list_timeline('shokai', 'arr')
  end

  def test_direct_message
    assert response? @client.direct_messages
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
tw-0.2.6 test/test_tw.rb
tw-0.2.5 test/test_tw.rb
tw-0.2.4 test/test_tw.rb
tw-0.2.3 test/test_tw.rb
tw-0.2.2 test/test_tw.rb
tw-0.2.1 test/test_tw.rb
tw-0.2.0 test/test_tw.rb
tw-0.1.1 test/test_tw.rb
tw-0.1.0 test/test_tw.rb