# Functional tests don't detect that locals are not passed

**URL:** <https://www.ruby-forum.com/t/functional-tests-dont-detect-that-locals-are-not-passed/144657>\
**Category:** Rails\
**Created:** [July 31, 2008, 9:36pm UTC](https://www.ruby-forum.com/t/functional-tests-dont-detect-that-locals-are-not-passed/144657 "2008-07-31T21:36:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mats](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b4bc9f/32.png) [@Mats](https://www.ruby-forum.com/u/Mats)\
**Post date:** [July 31, 2008, 9:36pm UTC](https://www.ruby-forum.com/t/functional-tests-dont-detect-that-locals-are-not-passed/144657/1 "2008-07-31T21:36:45Z")

</div>

I have quite a strange problem: there was a bug in my code where I  
forgot to pass a local variable to a partial. This problem was not  
detected by my functional tests although it lead to a  
ActionView::TemplateError: undefined local variable or method  
in my development (and unfortunately production) environment.  
After digging deeper, I noticed that the functional test fails as  
expected when it is executed without the other tests (using the -n  
option). But when running all tests of the whole controller, the test  
passes. I suspect the test-environment to somehow cache the partial  
(it is also called by other tests) and thus played around with the  
config.action\_controller.perform\_caching and  
config.action\_view.cache\_template\_extensions parameters, but without  
success.  
Does anybody have an idea where the problem comes from and how I can  
fix it? When I can’t trust my tests anymore, I am really stuck…

Thanks,  
Mats

---

<div class="post-metadata">

**Author:** ![Mats](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b4bc9f/32.png) [@Mats](https://www.ruby-forum.com/u/Mats)\
**Post date:** [July 31, 2008, 9:42pm UTC](https://www.ruby-forum.com/t/functional-tests-dont-detect-that-locals-are-not-passed/144657/2 "2008-07-31T21:42:01Z")

</div>

On Jul 31, 8:22 pm, Mats [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I have quite a strange problem: there was a bug in my code where I  
> forgot to pass a local variable to a partial. This problem was not  
> detected by my functional tests although it lead to a  
> ActionView::TemplateError: undefined local variable or method  
> in my development (and unfortunately production) environment.

> After digging deeper, I noticed that the functional test fails as  
> expected when it is executed without the other tests (using the -n  
> option). But when running all tests of the whole controller, the test  
> passes. I suspect the test-environment to somehow cache the partial  
> (it is also called by other tests) and thus played around with the  
> config.action\_controller.perform\_caching and  
> config.action\_view.cache\_template\_extensions parameters, but without  
> success.

This sounds familiar, there have been the odd option touching on these  
recently. What you are seeing is an artefact of how :locals is  
implemented, and it’s not something that can be turned on or off (and  
it’s not specific to the test environment).  
There are some threads that have touched on it:  
[http://groups.google.com/group/rubyonrails-core/browse\_thread/thread/fab600c00f4d076/d186056818da1aa5?lnk=gst&q=locals#d186056818da1aa5](http://groups.google.com/group/rubyonrails-core/browse_thread/thread/fab600c00f4d076/d186056818da1aa5?lnk=gst&q=locals#d186056818da1aa5)  
[http://groups.google.com/group/rubyonrails-core/browse\_thread/thread/1f61a859c16ae533/2dad09e1bf7d754d?lnk=gst&q=locals+defined#2dad09e1bf7d754d](http://groups.google.com/group/rubyonrails-core/browse_thread/thread/1f61a859c16ae533/2dad09e1bf7d754d?lnk=gst&q=locals+defined#2dad09e1bf7d754d)

Fred
