Rake error

HI all

If I have two functional tests that test the same controller, I get
fixture errors. Is this right?

here is one

require File.dirname(FILE) + ‘/…/test_helper’
require ‘summary_controller’

Re-raise errors caught by the controller.

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

class SummaryControllerTest < Test::Unit::TestCase
all_fixtures

and here is the other

require File.dirname(FILE) + ‘/…/test_helper’
require ‘summary_controller’

Re-raise errors caught by the controller.

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

class SummaryControllerTest < Test::Unit::TestCase
fixtures :users, :decisions, :roles

Here is the error it produces…

  1. Error:
    test_choose_chart(SummaryControllerTest):
    NoMethodError: You have a nil object when you didn’t expect it!
    You might have expected an instance of Array.
    The error occurred while evaluating nil.[]
    c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/fixture
    s.rb:498:in users' ./test/functional/summary_controller_test.rb:42:intest_choose_chart’
    c:/ruby/lib/ruby/gems/1.8/gems/mocha-0.5.5/lib/mocha/test_case_adapter.rb:19
    :in __send__' c:/ruby/lib/ruby/gems/1.8/gems/mocha-0.5.5/lib/mocha/test_case_adapter.rb:19 :inrun’

on this line:
admin = users(:admin)

Have any of you run into a similar problem before?

I haven’t looked into it in any depth, but I wonder if your problem
could be that your test classes have exactly the same name. So when
the second file is loaded, you will be modifying the first test class.

James.

James M. wrote:

I haven’t looked into it in any depth, but I wonder if your problem
could be that your test classes have exactly the same name. So when
the second file is loaded, you will be modifying the first test class.

James.
http://blog.floehopper.org
http://tumble.floehopper.org

That turned out to be the issue. Apprently you cannot do that in tests
apparently, have the same controller being tested. I dunno why but
deleting one fixed the problem.

Thanks!

I suspect you can have two test cases testing the same controller as
long as the class names of the two TestCases are different.

class SummaryControllerOneTest < Test::Unit::TestCase
class SummaryControllerAnotherTest < Test::Unit::TestCase


James.