Topic: Why is this nil?

require File.dirname(__FILE__) + '/../test_helper'
require 'user_controller'

class UserController; def rescue_action(e) raise e end; end

class UserControllerTest < ActionController::TestCase
  fixtures :users
  def setup
    @controller =
    @request =
    @response =
    @valid_user = users(:valid_user)

  def test_fails_for_some_reason
    assert_not_nil @valid_user

@valid_user is nil in test_fails_for_some_reason but if I do this:

user = users(:valid_user)
assert_not_nil user

it works...

how am I screwing this up?


Re: Why is this nil?

Are the fixtures run *after* setup?

Toby Hede
FiniteStateMachine - Software Development for Social Networks

Re: Why is this nil?

I was following an example in a book I bought.  I assumed that "setup" was one of those magical methods that rails called for me before the test fixture.  But I guessing that's not the case...