# Problem with functional tests

**URL:** <https://www.ruby-forum.com/t/problem-with-functional-tests/79147>\
**Category:** Rails\
**Created:** [December 12, 2006, 4:35pm UTC](https://www.ruby-forum.com/t/problem-with-functional-tests/79147 "2006-12-12T16:35:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [December 12, 2006, 4:35pm UTC](https://www.ruby-forum.com/t/problem-with-functional-tests/79147/1 "2006-12-12T16:35:12Z")

</div>

Hi everybody

I have some basic problems with my functional tests. In my controller, I  
have the method “index” and “list”.

def index  
list  
render :action =\> ‘list’  
end

def list  
@person\_pages, @persons = paginate :persons, :per\_page =\> 200  
end

Now I would like to test the controller. So I wrote the test-method like  
the following:

def setup  
@controller = CurrencyController.new  
@request = ActionController::TestRequest.new  
@response = ActionController::TestResponse.new  
end

def test\_index  
get :index  
assert\_response :success  
assert\_template ‘list’  
end

But it doesn’t work! Why? I receive only these error message:

> NoMethodError: You have a nil object when you didn’t expect it!  
> You might have expected an instance of Array.  
> The error occured while evaluating nil.-

---

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [December 12, 2006, 4:44pm UTC](https://www.ruby-forum.com/t/problem-with-functional-tests/79147/2 "2006-12-12T16:44:38Z")

</div>

We’ll need more information, as what you’ve posted looks fine. What line  
is  
the NoMethodError thrown from?

Jason

---

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [December 12, 2006, 5:11pm UTC](https://www.ruby-forum.com/t/problem-with-functional-tests/79147/3 "2006-12-12T17:11:10Z")

</div>

Jason R. wrote:

> We’ll need more information, as what you’ve posted looks fine. What line  
> is  
> the NoMethodError thrown from?
> 
> Jason

/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_record/transactions.rb:112:in  
`unlock\_mutex’

/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.4/lib/active\_record/fixtures.rb:534:in  
`teardown’

---

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [December 12, 2006, 5:39pm UTC](https://www.ruby-forum.com/t/problem-with-functional-tests/79147/4 "2006-12-12T17:39:42Z")

</div>

Jason R. wrote:

> Are you properly pulling in fixtures into your tests (fixtures  
> :persons)?
> 
> Is your data schema in working order (migrations, fixture YAML files,  
> etc)?
> 
> Jason

Yes, I pulling fixtures into my tests. About my data schema. I clone  
with rake the whole structure to the test environment.

---

<div class="post-metadata">

**Author:** ![flnative](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5daacb/32.png) [@flnative](https://www.ruby-forum.com/u/flnative)\
**Post date:** [December 12, 2006, 5:34pm UTC](https://www.ruby-forum.com/t/problem-with-functional-tests/79147/5 "2006-12-12T17:34:48Z")

</div>

Are you properly pulling in fixtures into your tests (fixtures  
:persons)?

Is your data schema in working order (migrations, fixture YAML files,  
etc)?

Jason
