Lines 24, 29, 34, (39 and 40) show errors I received when I used –
trace when I db:migrate all saying:
test_should_show_contact(ContactsControllerTest):
NoMethodError: undefined method `contacts’
Is the default file wrong. I can’t see rails making a mistake in
scaffold.
require ‘test_helper’
class ContactsControllerTest < ActionController::TestCase
test “should get index” do
get :index
assert_response :success
assert_not_nil assigns(:contacts)
end
test “should get new” do
get :new
assert_response :success
end
test “should create contact” do
assert_difference(‘Contact.count’) do
post :create, :contact => { }
end
assert_redirected_to contact_path(assigns(:contact))
end
test “should show contact” do
get :show, :id => contacts(:one).to_param
<-----24
assert_response :success
end
test “should get edit” do
get :edit, :id => contacts(:one).to_param
<-----29
assert_response :success
end
test “should update contact” do
put :update, :id => contacts(:one).to_param, :contact =>
{ } <-----34
assert_redirected_to contact_path(assigns(:contact))
end
test “should destroy contact” do
assert_difference(‘Contact.count’, -1)
do <-----39
delete :destroy, :id => contacts
(:one).to_param <-----40
end
assert_redirected_to contacts_path
end
end