vh84 (3) [Avatar] Offline
I am following the book and has made fixtures changes according to listings 5.38, 5.39, 5.40 and changes according to 5.42, 5.43 and 5.44.

When I run rake, I got a lot of error messages, mostly complaining about fixture 'one', like:
No fixture with name 'one' found for table 'tasks'

Looking at tasks_controller_test.rb, I see a lot of reference to fixture 'one', like

def test_should_show_task
get :show, :id => tasks(:one).id
assert_response :success

My questions are:
1) Does anyone else have this problem?
2) Are listings 5.38-5.44 correct? Or did Peter skip something important?
3) If listings 5.38-5.44 are correct, what should I try to look for?
4) How does login_as :ludwig map to fixture 'one'?

benben (1) [Avatar] Offline
Re: Iteration 5 Test failed - listings 5.38 - 5.44

i've got exactly the same errors and questions!

peter please help! smilie
najitaka (1) [Avatar] Offline
Re: Iteration 5 Test failed - listings 5.38 - 5.44
If you are working through the examples with Rails 2.3.3 and are having problems with tests try the following.

For users.yml do you fixtures like this:
login: ludwig
email: lvb@pomodo.com
first_name: Ludwig
last_name: van Beethoven
salt: 20b3c17b8f085f29a91def32258eb121b88371e4
crypted_password: 5fff39a8fdc9f6f9b5fe883b0b019c23b5d6ae39 # foooo
created_at: <%= 5.days.ago.to_s :db %>

For tasks, locations, and projects use this format:
user: ludwig
project: ludwig_project_one
location: ludwig_home
name: Finish eighth symphony
notes: Done. Yay!
next_action: false
completed: true

As you can see there are no need for IDs just use the titles for the relationships.
Use the fixture titles in place of the :one in the tests as well to get around that issue.

Also if you use ActionController::TestCase as the base of your test controllers, there is no need for the fixture statement as long as you have fixture :all in your test_helper.rb file. Therefore the top of the functional test will look like this:

require 'test_helper'
require 'tasks_controller'

# Re-raise errors caught by the controller.
class TasksController; def rescue_action(e) raise e end; end

class TasksControllerTest < ActionController::TestCase
def setup
login_as :ludwig

ActionController::TestCase handles @controller, @request, and @response for you. Be sure to call super first in the setup method however.

These changes got the tests to pass for me.