# Functional test question

**URL:** <https://www.ruby-forum.com/t/functional-test-question/91378>\
**Category:** Rails\
**Created:** [April 7, 2007, 10:08pm UTC](https://www.ruby-forum.com/t/functional-test-question/91378 "2007-04-07T22:08:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ad7895/32.png) [@jeet](https://www.ruby-forum.com/u/jeet)\
**Post date:** [April 7, 2007, 10:08pm UTC](https://www.ruby-forum.com/t/functional-test-question/91378/1 "2007-04-07T22:08:27Z")

</div>

I have a view that passes two params hashes (:user and :school) to my  
controller action. In the functional test for the controller action,  
how do pass these two hashes?

I tried the following that did not work  
get(:create, [:user =\> {:firstname =\> ‘xxx’, :lastname =\>  
‘yyyy’}, :school =\> {:id =\> 1}] )

It seems to pick only the first array element.

Anybody run into this issue and knows how to do this?

-Navjeet

---

<div class="post-metadata">

**Author:** ![jeet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ad7895/32.png) [@jeet](https://www.ruby-forum.com/u/jeet)\
**Post date:** [April 7, 2007, 10:23pm UTC](https://www.ruby-forum.com/t/functional-test-question/91378/2 "2007-04-07T22:23:27Z")

</div>

njs wrote:

> I tried the following that did not work  
> get(:create, [:user =\> {:firstname =\> ‘xxx’, :lastname =\>  
> ‘yyyy’}, :school =\> {:id =\> 1}] )

You are thinking too hard. Rails typically requires less effort.

get :create, :user =\> {:firstname =\> ‘xxx’, :lastname =\> ‘yyyy’},  
:school =\> {:id =\> 1}

Now get inside def create, and add

p params

Run the test, and you will see how your parameters pass thru.

> Anybody run into this issue and knows how to do this?

Have you read /Agile Web D. with Rails/? It covers all this  
stuff.

–  
Phlip  
["Pigleg too?", week 1](http://flea.sourceforge.net/PiglegToo_1.html)

---

<div class="post-metadata">

**Author:** ![jeet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ad7895/32.png) [@jeet](https://www.ruby-forum.com/u/jeet)\
**Post date:** [April 7, 2007, 11:46pm UTC](https://www.ruby-forum.com/t/functional-test-question/91378/3 "2007-04-07T23:46:33Z")

</div>

Hi –

On 4/7/07, njs [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Anybody run into this issue and knows how to do this?

You don’t need to wrap your hashes in an array. In fact, you need not  
to 🙂

get(:create,  
:user =\> {:firstname =\> ‘xxx’, :lastname =\> ‘yyyy’},  
:school =\> {:id =\> 1})

:user and :school are themselves hash keys, and the hash to which they  
belong is implicit in your argument list, based on the Ruby rule that  
if the last thing in an argument list is a literal hash, you can leave  
off the curly braces.

David

–  
Upcoming Rails training by Ruby Power and Light:  
Four-day Intro to Intermediate  
May 8-11, 2007  
Edison, NJ  
[http://www.rubypal.com/events/05082007](http://www.rubypal.com/events/05082007)
