Created
April 7, 2010 02:20
-
-
Save rbarazi/358409 to your computer and use it in GitHub Desktop.
[Beginning Rails 3] Listing 10-12. Updated test case for the index action in test/functional/articles_controller_test.rb
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' | |
class ArticlesControllerTest < ActionController::TestCase | |
setup do | |
@article = articles(:welcome_to_rails) | |
end | |
test "should get index" do | |
get :index | |
assert_response :success | |
assert_template 'index' | |
assert_not_nil assigns(:articles) | |
end | |
test "should get new" do | |
get :new | |
assert_response :success | |
end | |
test "should create article" do | |
assert_difference('Article.count') do | |
post :create, :article => @article.attributes | |
end | |
assert_redirected_to article_path(assigns(:article)) | |
end | |
test "should show article" do | |
get :show, :id => @article.to_param | |
assert_response :success | |
end | |
test "should get edit" do | |
get :edit, :id => @article.to_param | |
assert_response :success | |
end | |
test "should update article" do | |
put :update, :id => @article.to_param, :article => @article.attributes | |
assert_redirected_to article_path(assigns(:article)) | |
end | |
test "should destroy article" do | |
assert_difference('Article.count', -1) do | |
delete :destroy, :id => @article.to_param | |
end | |
assert_redirected_to articles_path | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment