test/test_tw.rb in tw-0.0.3 vs test/test_tw.rb in tw-0.1.0

- old
+ new

@@ -5,15 +5,20 @@ 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 - i[:user] =~ /^[a-zA-Z0-9_]+$/ 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 @@ -34,7 +39,11 @@ 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