# NoMethodError on functional test -

**URL:** <https://www.ruby-forum.com/t/nomethoderror-on-functional-test/196719>\
**Category:** Rails\
**Created:** [June 23, 2008, 11:49am UTC](https://www.ruby-forum.com/t/nomethoderror-on-functional-test/196719 "2008-06-23T11:49:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eddy\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@eddy\_b](https://www.ruby-forum.com/u/eddy_b)\
**Post date:** [June 23, 2008, 11:49am UTC](https://www.ruby-forum.com/t/nomethoderror-on-functional-test/196719/1 "2008-06-23T11:49:13Z")

</div>

Hi,

I’ve got a small problem with my funcional tests. I want to test the  
function, that anybody who wants to the admin - controller redirect to  
the authentication - controller. So I write this small test:

def test\_index  
get :index  
assert\_response :redirect  
end

But every time I get these error message:

ruby test/functional/admin\_controller\_test.rb

Loaded suite test/functional/admin\_controller\_test  
Started  
E.  
Finished in 0.313 seconds.

1. Error:  
test\_index(AdminControllerTest):  
NoMethodError: You have a nil object when you didn’t expect it!  
You might have expected an instance of ActiveRecord::Base.  
The error occurred while evaluating nil.[]  
…  
2 tests, 0 assertions, 0 failures, 1 errors

Has anybody an idea to solve this problem?

Regards Eddy

---

<div class="post-metadata">

**Author:** ![eddy\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@eddy\_b](https://www.ruby-forum.com/u/eddy_b)\
**Post date:** [June 23, 2008, 11:54am UTC](https://www.ruby-forum.com/t/nomethoderror-on-functional-test/196719/2 "2008-06-23T11:54:12Z")

</div>

On 23 Jun 2008, at 10:49, Eddy B. wrote:

> 1. Error:  
> test\_index(AdminControllerTest):  
> NoMethodError: You have a nil object when you didn’t expect it!  
> You might have expected an instance of ActiveRecord::Base.  
> The error occurred while evaluating nil.[]

The error message will tell you where the error occurred. Find that  
line and work out what is nil and why.

Fred

---

<div class="post-metadata">

**Author:** ![eddy\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@eddy\_b](https://www.ruby-forum.com/u/eddy_b)\
**Post date:** [June 23, 2008, 1:21pm UTC](https://www.ruby-forum.com/t/nomethoderror-on-functional-test/196719/3 "2008-06-23T13:21:25Z")

</div>

Frederick C. wrote:

> On 23 Jun 2008, at 10:49, Eddy B. wrote:
> 
> > 1. Error:  
> > test\_index(AdminControllerTest):  
> > NoMethodError: You have a nil object when you didn’t expect it!  
> > You might have expected an instance of ActiveRecord::Base.  
> > The error occurred while evaluating nil.[]
> 
> The error message will tell you where the error occurred. Find that  
> line and work out what is nil and why.
> 
> Fred

He said, that this line ‘get :index’ is nil, but this doesn’t make  
sense. He gave these answer to all my methods.

Eddy

---

<div class="post-metadata">

**Author:** ![eddy\_b](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/c68b51/32.png) [@eddy\_b](https://www.ruby-forum.com/u/eddy_b)\
**Post date:** [June 23, 2008, 1:26pm UTC](https://www.ruby-forum.com/t/nomethoderror-on-functional-test/196719/4 "2008-06-23T13:26:51Z")

</div>

Eddy B. wrote:

> Frederick C. wrote:
> 
> > On 23 Jun 2008, at 10:49, Eddy B. wrote:
> > 
> > > 1. Error:  
> > > test\_index(AdminControllerTest):  
> > > NoMethodError: You have a nil object when you didn’t expect it!  
> > > You might have expected an instance of ActiveRecord::Base.  
> > > The error occurred while evaluating nil.[]
> > 
> > The error message will tell you where the error occurred. Find that  
> > line and work out what is nil and why.
> > 
> > Fred
> 
> He said, that this line ‘get :index’ is nil, but this doesn’t make  
> sense. He gave these answer to all my methods.
> 
> Eddy

Fred you are right. He has some problems with the integration of  
Globalite and so I get the NoMethodError. Thanks!

Eddy
