dave99s_controller_test.rb

来自「ruby on rails web敏捷开发之路第二版 源代码」· RB 代码 · 共 63 行

RB
63
字号
#---# Excerpted from "Agile Web Development with Rails, 2nd Ed."# We make no guarantees that this code is fit for any purpose. # Visit http://www.pragmaticprogrammer.com/titles/rails2 for more book information.#---require File.dirname(__FILE__) + '/../test_helper'require 'dave99s_controller'# Re-raise errors caught by the controller.class Dave99sController; def rescue_action(e) raise e end; endclass Dave99sControllerTest < Test::Unit::TestCase  fixtures :dave99s  def setup    @controller = Dave99sController.new    @request    = ActionController::TestRequest.new    @response   = ActionController::TestResponse.new  end  def test_should_get_index    get :index    assert_response :success    assert assigns(:dave99s)  end  def test_should_get_new    get :new    assert_response :success  end    def test_should_create_dave99    old_count = Dave99.count    post :create, :dave99 => { }    assert_equal old_count+1, Dave99.count        assert_redirected_to dave99_path(assigns(:dave99))  end  def test_should_show_dave99    get :show, :id => 1    assert_response :success  end  def test_should_get_edit    get :edit, :id => 1    assert_response :success  end    def test_should_update_dave99    put :update, :id => 1, :dave99 => { }    assert_redirected_to dave99_path(assigns(:dave99))  end    def test_should_destroy_dave99    old_count = Dave99.count    delete :destroy, :id => 1    assert_equal old_count-1, Dave99.count        assert_redirected_to dave99s_path  endend

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?