|
Revision 9133, 1.2 kB
(checked in by bitsweat, 3 months ago)
|
Generated tests rely on test dir in load path rather than File.dirname shenanigans. ruby -Itest test/unit/foo_test.rb to run a test by hand (that's a capital I as in Island).
|
| Line | |
|---|
| 1 |
require 'test_helper' |
|---|
| 2 |
|
|---|
| 3 |
class <%= controller_class_name %>ControllerTest < ActionController::TestCase |
|---|
| 4 |
def test_should_get_index |
|---|
| 5 |
get :index |
|---|
| 6 |
assert_response :success |
|---|
| 7 |
assert_not_nil assigns(:<%= table_name %>) |
|---|
| 8 |
end |
|---|
| 9 |
|
|---|
| 10 |
def test_should_get_new |
|---|
| 11 |
get :new |
|---|
| 12 |
assert_response :success |
|---|
| 13 |
end |
|---|
| 14 |
|
|---|
| 15 |
def test_should_create_<%= file_name %> |
|---|
| 16 |
assert_difference('<%= class_name %>.count') do |
|---|
| 17 |
post :create, :<%= file_name %> => { } |
|---|
| 18 |
end |
|---|
| 19 |
|
|---|
| 20 |
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>)) |
|---|
| 21 |
end |
|---|
| 22 |
|
|---|
| 23 |
def test_should_show_<%= file_name %> |
|---|
| 24 |
get :show, :id => <%= table_name %>(:one).id |
|---|
| 25 |
assert_response :success |
|---|
| 26 |
end |
|---|
| 27 |
|
|---|
| 28 |
def test_should_get_edit |
|---|
| 29 |
get :edit, :id => <%= table_name %>(:one).id |
|---|
| 30 |
assert_response :success |
|---|
| 31 |
end |
|---|
| 32 |
|
|---|
| 33 |
def test_should_update_<%= file_name %> |
|---|
| 34 |
put :update, :id => <%= table_name %>(:one).id, :<%= file_name %> => { } |
|---|
| 35 |
assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>)) |
|---|
| 36 |
end |
|---|
| 37 |
|
|---|
| 38 |
def test_should_destroy_<%= file_name %> |
|---|
| 39 |
assert_difference('<%= class_name %>.count', -1) do |
|---|
| 40 |
delete :destroy, :id => <%= table_name %>(:one).id |
|---|
| 41 |
end |
|---|
| 42 |
|
|---|
| 43 |
assert_redirected_to <%= table_name %>_path |
|---|
| 44 |
end |
|---|
| 45 |
end |
|---|