Created
December 12, 2008 19:32
-
-
Save lmarburger/35242 to your computer and use it in GitHub Desktop.
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
require 'test_helper' | |
require 'flexmock/test_unit' | |
class BlogHelperTest < ActionView::TestCase | |
tests BlogHelper | |
context "getting tweet list" do | |
setup do | |
@twitter_user = 'test' | |
@tweets = get_tweets_mock | |
flexmock(Twitter).new_instances.should_receive(:tweets).once.and_return(@tweets) | |
end | |
should "render tweets" do | |
assert_dom_equal( | |
@tweets.inject('<ol class="twitter">') do |memo, tweet| | |
memo << %Q(<li><p>#{tweet.text}</p><span>less than a minute ago</span><a href="http://twitter.com/#{tweet.user.screen_name}/status/#{tweet.id}" class="permalink">Permalink</a></li>) | |
end << '</ol>', | |
tweets_list('test') | |
) | |
end | |
end | |
context "getting blog post list" do | |
setup do | |
@posts = get_posts_mock | |
flexmock(Blog).new_instances.should_receive(:posts).once.and_return(@posts) | |
end | |
should "render blog posts" do | |
assert_dom_equal( | |
@posts.inject('<ol class="entries">') do |memo, post| | |
memo << %Q(<li><h2>#{post.title.text}</h2><h3>Posted by Me #{time_ago_in_words(post.published.text)} ago</h3><p>#{post.content.text}</p></li>) | |
end << '</ol>', | |
blog_posts_list | |
) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment