test/test_tweetskim.rb in tweetskim-0.0.2 vs test/test_tweetskim.rb in tweetskim-0.1.0

- old
+ new

@@ -1,31 +1,92 @@ require File.dirname(__FILE__) + '/test_helper.rb' class TestTweetskim < Test::Unit::TestCase def setup - @t = Tweetskim::TwitterAdapter.new + @f = Tweetskim::Formatter.new end - - def test_something - assert_equal 4, @t.trial - end - def test_twitter_integration_get_mentions - assert_equal 10, @t.mentions[0...10].count + def t(text) + status = Twitter::Status.new + status.stubs(:text).returns text + user = Twitter::User.new + user.stubs(:name).returns "Mock User" + status.stubs(:user).returns user + return status end + + def test_column_creation + tweets = [t("Ut enimad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."), t("Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. "), t("Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")] + + expected = <<FORMATTED +--Mock User-- Excepteur sint occaecat +cupidatat non proident, sunt in culpa +qui officia deserunt mollit anim id +est laborum. - def test_twitter_integration_get_timeline - assert_equal 10, @t.timeline[0...10].count + +--Mock User-- Duis aute irure dolor in +reprehenderit in voluptate velit esse +cillum dolore eu fugiat nulla pariatur. + + +--Mock User-- Ut enimad minim veniam, +quis nostrud exercitation ullamco +laboris nisi ut aliquip ex ea commodo +consequat. +FORMATTED + + actual = @f.column(tweets, {:width => 40}) + + assert_equal expected, actual end - - def test_column_creation - tweet_str = ["Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ", "Ut enimad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ", "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."] + def test_whitespace_padding -# tweets = tweet_str.map { |str| Twitter::Status.new :text => str } + col = <<COL +aaaaaa +aaaaa +aaaa +aaa +aa +a + +COL - puts @t.tweet_column( @t.timeline, 40) + expected = <<COL +aaaaaa +aaaaa +aaaa +aaa +aa +a + +COL + + assert_equal expected, @f.pad(col, 6) + end + + + def test_column_pasting + first_col = <<COL +aaa +aaa +aaa +COL + second_col = <<COL +bbb +bbb +bbb +COL + + expected = <<COL +aaa\tbbb +aaa\tbbb +aaa\tbbb +COL + + assert_equal expected, @f.pasted_columns([first_col, second_col]) end end