Skip to content
This repository has been archived by the owner on Feb 7, 2018. It is now read-only.

Commit

Permalink
Added Twitter client tests
Browse files Browse the repository at this point in the history
  • Loading branch information
billinghamj committed Oct 28, 2014
1 parent dd2aa1a commit e3af0bb
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/test_twitter_client.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
require 'minitest/autorun'

class TestTwitterClient < Minitest::Test
def setup
@tw = MiniTest::Mock.new
@client = TwitterClient.new client: @tw
end

def test_search
tweets = [
Twitter::Tweet.new(id: '', text: 'testing this program'),
Twitter::Tweet.new(id: '', text: 'testing is important'),
Twitter::Tweet.new(id: '', text: 'testing is fun'),
Twitter::Tweet.new(id: '', text: 'testing is foo bar')
]

@tw.expect :search, tweets, ['testing', result_type: 'recent']

ws = @client.search 'testing'

assert_equal 0, ws.count
assert_empty ws.top_words
assert_empty ws.top_characters
assert_empty ws.top_vowels
assert_empty ws.top_consonants
assert_empty ws.top_5_words
assert_empty ws.top_5_characters
assert_empty ws.top_5_vowels
assert_empty ws.top_5_consonants

assert_equal true, ws.run
assert_equal 13, ws.count
assert_equal nil, ws.next_word
assert_equal 13, ws.count
assert_equal nil, ws.next_word
assert_equal 13, ws.count

assert_equal 'testing', ws.top_words[0]
assert_equal 'is', ws.top_words[1]
end
end

0 comments on commit e3af0bb

Please sign in to comment.