# Rake error

**URL:** <https://www.ruby-forum.com/t/rake-error/120849>\
**Category:** Rails\
**Created:** [November 21, 2007, 4:40am UTC](https://www.ruby-forum.com/t/rake-error/120849 "2007-11-21T04:40:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tesmar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dbc845/32.png) [@tesmar](https://www.ruby-forum.com/u/tesmar)\
**Post date:** [November 21, 2007, 4:40am UTC](https://www.ruby-forum.com/t/rake-error/120849/1 "2007-11-21T04:40:21Z")

</div>

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:in`test\_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 :in`run’

on this line:  
admin = users(:admin)

Have any of you run into a similar problem before?

---

<div class="post-metadata">

**Author:** ![tesmar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dbc845/32.png) [@tesmar](https://www.ruby-forum.com/u/tesmar)\
**Post date:** [November 21, 2007, 6:59pm UTC](https://www.ruby-forum.com/t/rake-error/120849/2 "2007-11-21T18:59:23Z")

</div>

## 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 Mead](https://jamesmead.org/)**
>
> Ruby Developer, author of Mocha, and ex-Antarctic Hero.

> **[Floehopper](https://tumble.floehopper.org/)**
>
> thoughts on the bergy bits of life

---

<div class="post-metadata">

**Author:** ![tesmar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dbc845/32.png) [@tesmar](https://www.ruby-forum.com/u/tesmar)\
**Post date:** [November 21, 2007, 7:24pm UTC](https://www.ruby-forum.com/t/rake-error/120849/3 "2007-11-21T19:24:56Z")

</div>

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://blog.floehopper.org)  
> [http://tumble.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!

---

<div class="post-metadata">

**Author:** ![tesmar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dbc845/32.png) [@tesmar](https://www.ruby-forum.com/u/tesmar)\
**Post date:** [November 21, 2007, 11:27pm UTC](https://www.ruby-forum.com/t/rake-error/120849/4 "2007-11-21T23:27:47Z")

</div>

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.

> **[James Mead](https://jamesmead.org/)**
>
> Ruby Developer, author of Mocha, and ex-Antarctic Hero.

> **[Floehopper](https://tumble.floehopper.org/)**
>
> thoughts on the bergy bits of life
