Default scaffold makes a test.rb with errors

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

On Apr 25, 6:41 am, “[email protected][email protected] wrote:

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.

Normally contacts is a method that is magicked into existance because
you have a contacts.yml fixture file. If you didn’t (perhaps it ended
up as contact.yml or something, which might happen if you gave a
generator a plural when it expected a singular ( or vice-versa )) or
if your test_helper.rb didn’t say fixtures :all then you might get
that error.

Fred

The application works fine in development mode, so I can’t really see
anything being wrong but I’ll double check. I just keep getting the
error 500 screen every time I deploy and these are the only errors I
can find.