# Problem with Test Fixtures

**URL:** <https://www.ruby-forum.com/t/problem-with-test-fixtures/92183>\
**Category:** Rails\
**Created:** [April 16, 2007, 10:59pm UTC](https://www.ruby-forum.com/t/problem-with-test-fixtures/92183 "2007-04-16T22:59:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robin\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c2a13f/32.png) [@Robin\_F](https://www.ruby-forum.com/u/Robin_F)\
**Post date:** [April 16, 2007, 10:59pm UTC](https://www.ruby-forum.com/t/problem-with-test-fixtures/92183/1 "2007-04-16T22:59:42Z")

</div>

Hi All,

I’m currently working on an Admin Controller that displays a list of  
topics and questions. Users are required to login to add topics/  
questions. The login functionality works fine in practice - all  
actions except ‘signin’ are wrapped in a before filter that redirects  
in the absence of session[:user].

My problem is that all my tests are producing errors as the test suite  
will not recognise the fixtures for the AdminUser model as follows:

“No fixture with name ‘robin’ found for table ‘admin\_users’”

I’ve set out below 2 sample tests from the admin\_controller\_test (note  
the methods at the bottom - covering the bases using strings and  
symbols), fixtures and ‘tail’ from the test.log. I have tried to pass  
the session directly as a parameter to an individual test and still  
receive the same error.

Any help would be greatly appreciated.

Robin

* * *

def test\_should\_show\_new  
get\_with\_user :new  
assert\_response :success  
assert\_template ‘new’  
assert\_not\_nil assigns(:topic)  
end

def test\_should\_add\_topic  
post\_with\_user :new, :topic =\> {:name =\> ‘test  
topic’, :description =\> ‘test description’}  
assert ! assigns(:topic).new\_record?  
assert\_redirected\_to :action =\> ‘index’  
assert\_not\_nil flash[:notice]  
end

protected  
def get\_with\_user(action, parameters = nil, session = nil, flash =  
nil)  
get action, nil, {‘user’ =\> admin\_users(:robin).id}  
end

def post\_with\_user(action, parameters = nil, session = nil, flash =  
nil)  
post action, nil, :user =\> admin\_users(‘robin’).id  
end

* * *

one:  
id: 1  
username: robin  
password\_salt: 1YP9AH4N  
password\_hash:  
4deec5b9b2fb00544b018ee17e27e6fb9ed338d7a1402d16b72b715e75ea2ef4  
#secret

two:  
id: 2  
username: jaye  
password\_salt: CB620C9W  
password\_hash:  
1ff5c3462acdb8aa47fc07a2fd4a8103ac43d8754fb263b350bfb79e8b413c33  
#bunny

* * *

robin-fishers-computer:~/elearning robinfisher$ rake test:functionals  
tail -f log/test.log  
(in /Users/robinfisher/elearning)  
rake aborted!  
/Users/robinfisher/elearning/log/test.log:1: Invalid char `\033’ in  
expression  
/Users/robinfisher/elearning/log/test.log:1: parse error, unexpected  
‘;’, expecting ‘]’  
SQL (0.000167) SET SQL\_AUTO\_IS\_NULL=0  
^  
/Users/robinfisher/elearning/log/test.log:1: parse error, unexpected  
tIDENTIFIER, expecting $  
SQL (0.000167) SET SQL\_AUTO\_IS\_NULL=0  
^

(See full trace by running task with --trace)

---

<div class="post-metadata">

**Author:** ![Robin\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c2a13f/32.png) [@Robin\_F](https://www.ruby-forum.com/u/Robin_F)\
**Post date:** [April 16, 2007, 11:18pm UTC](https://www.ruby-forum.com/t/problem-with-test-fixtures/92183/2 "2007-04-16T23:18:47Z")

</div>

one:  
id: 1  
username: robin  
password\_salt: 1YP9AH4N  
password\_hash:  
4deec5b9b2fb00544b018ee17e27e6fb9ed338d7a1402d16b72b715e75ea2ef4  
#secret

Should be

robin:  
id: 1  
username: robin  
password\_salt: 1YP9AH4N  
password\_hash:  
4deec5b9b2fb00544b018ee17e27e6fb9ed338d7a1402d16b72b715e75ea2ef4  
#secret

When you do admin\_users(:robin) you need to pass the NAME of the  
fixture  
entry… Your first fixture entry is ‘one’ and not ‘robin’.

Does that make sense?

---

<div class="post-metadata">

**Author:** ![Robin\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/c2a13f/32.png) [@Robin\_F](https://www.ruby-forum.com/u/Robin_F)\
**Post date:** [April 16, 2007, 11:45pm UTC](https://www.ruby-forum.com/t/problem-with-test-fixtures/92183/3 "2007-04-16T23:45:49Z")

</div>

On Apr 16, 10:17 pm, “Brian H.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> When you do admin\_users(:robin) you need to pass the NAME of the fixture  
> entry… Your first fixture entry is ‘one’ and not ‘robin’.
> 
> Does that make sense?

Makes perfect sense!

Thanks for the quick response, I’m now showing a healthy 0 failures, 0  
errors.

Robin
