01 Jun 2011, 23:06
Generic-user-small

James Strocel (1 post)

Hi There,

I was working my way through the book and I ran the tests for huddle3 as advised on page 55. Instead of getting this error:

1) Error: test_creation_of_status_report_with_data(StatusReportsControllerTest): ArgumentError: wrong number of arguments (1 for 0)     /test/functional/status_reports_controller_test.rb:58:in ✎to_s'     /test/functional/status_reports_controller_test.rb:58:in      ✎test_creation_of_status_report_with_data'

I get these errors:

1) Error:
test_index_should_display_project_timeline(ProjectsControllerTest):
ActionView::Template::Error: undefined method `users' for #<Project:0x102c59bc8>
    app/views/projects/show.html.erb:5:in `_app_views_projects_show_html_erb__1391822682_2176008960_0'
    app/controllers/projects_controller.rb:26:in `show'
    /test/functional/projects_controller_test.rb:73:in `test_index_should_display_project_timeline'

  2) Error:
test_project_timeline_index_should_be_sorted_correctly(ProjectsControllerTest):
ActionView::Template::Error: undefined method `users' for #<Project:0x10351df98>
    app/views/projects/show.html.erb:5:in `_app_views_projects_show_html_erb__1391822682_2176008960_0'
    app/controllers/projects_controller.rb:26:in `show'
    /test/functional/projects_controller_test.rb:63:in `test_project_timeline_index_should_be_sorted_correctly'

  3) Error:
test_should_get_edit(ProjectsControllerTest):
ActionView::Template::Error: undefined method `projects' for #<User:0x1031ae678>
    app/views/projects/edit.html.erb:12:in `_app_views_projects_edit_html_erb__1954596551_2173714420_0'
    app/views/projects/edit.html.erb:8:in `each'
    app/views/projects/edit.html.erb:8:in `_app_views_projects_edit_html_erb__1954596551_2173714420_0'
    /test/functional/projects_controller_test.rb:44:in `test_should_get_edit'

  4) Error:
test_should_show_project(ProjectsControllerTest):
ActionView::Template::Error: undefined method `users' for #<Project:0x102f0fdb8>
    app/views/projects/show.html.erb:5:in `_app_views_projects_show_html_erb__1391822682_2176008960_0'
    app/controllers/projects_controller.rb:26:in `show'
    /test/functional/projects_controller_test.rb:39:in `test_should_show_project'

  5) Error:
test_should_update_project(ProjectsControllerTest):
NoMethodError: undefined method `users=' for #<Project:0x102d56760>
    app/controllers/projects_controller.rb:69:in `update'
    /test/functional/projects_controller_test.rb:49:in `test_should_update_project'

  6) Error:
test_should_update_with_users(ProjectsControllerTest):
StandardError: No fixture with name 'quentin' found for table 'users'
    /test/functional/projects_controller_test.rb:90:in `test_should_update_with_users'

Am I doing something wrong here or did I use the wrong code sample?

Keep up the good work!

-James

03 Jun 2011, 21:40
Generic-user-small

Danny O Cuiv (7 posts)

Hi James,

My guess from the above is that you have downloaded the code from the PragProg site and used that in your work-through. However, this code is for the completed example. What you needed to have done is to get a starting setup as explained in Appendix A: Sample Application Setup. I say this because your first two errors above are undefined method errors for a method called users on a Project instance. This method is being called on line 5 of your show view for projects. When I was working through the example, there was no users association in the Project model at that stage and the first few lines of the show view were like this:

<p id="notice"><%= notice %></p>

<p>
  <b>Name:</b>
  <%= @project.name %>
</p>

However, in the version from the code download, there is indeed a call to project.users on line 5 of the show view:

<% @project.users.each do |user| %>

The users association isn’t added until the top of page 243, much further on from where you are now. Oddly enough, this association is actually missing from the code download version. It should really be there.

Regards,

Danny.

  You must be logged in to comment