Skip to content

Instantly share code, notes, and snippets.

@jferris
Created August 5, 2009 21:37
Show Gist options
  • Save jferris/162988 to your computer and use it in GitHub Desktop.
Save jferris/162988 to your computer and use it in GitHub Desktop.
describe PostsController do
it "should show a published post on GET show" do
post = stub('a post', :to_param => '1')
post.expects(:published? => true)
Post.expects(:find).with(post.to_param).returns(post)
get :show, :id => post.to_param
should render_template(:show)
should assign_to(:post).with(post)
end
end
describe "/posts/show" do
it "should a post" do
assigns[:post] = stub('a post', :published? => true, :title => 'a title')
render '/posts/show'
template.should have_tag('h1', assigns[:post].title)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment