This repository has been archived by the owner on Feb 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd2aa1a
commit e3af0bb
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |