I''m using the functional test for a method like this: def test_create post :create, :phase => ''copynew'', :id => 1 assert_response :success assert_template ''create'' assert_tag :content => ''New Item'' assert_not_nil @item end This posts a request to the create method in the controller. Is there any way to look at the variables and objects that were created in the controller by this post? It looks like you are only able to examine the resulting html output. Is that more of a unit test thing rather than a functional test thing? And finally, if it is a unit test thing, how do I pass a set of params to a controller method call from a unit test? -- Posted with http://DevLists.com. Sign up and save your mailbox.
On May 16, 2006, at 12:49 PM, Richard Williams wrote:> > I''m using the functional test for a method like this: > > def test_create > > post :create, :phase => ''copynew'', :id => 1 > assert_response :success > assert_template ''create'' > assert_tag :content => ''New Item'' > > assert_not_nil @item > end > > This posts a request to the create method in the controller. Is there > any way to look at the variables and objects that were created in the > controller by this post? It looks like you are only able to > examine the > resulting html output.I''m just starting out myself, but I think this is covered in the AgileWDR book on pages 162 and 164. Take a look at the #assigns method call. Ex. assert_equal assigns(:some_var), <what the value should be>> Is that more of a unit test thing rather than a functional test thing?You can examine variables in either kind of test. It''s not limited to one or the other.> And finally, if it is a unit test thing, how do I pass a set of params > to a controller method call from a unit test?I''ve never done this but I assume it works the same way as the opposite (func test to unit test param passing). Maybe someone else can chime in here. cr
>> And finally, if it is a unit test thing, how do I pass a set of params >> to a controller method call from a unit test? > > I''ve never done this but I assume it works the same way as the > opposite (func test to unit test param passing). Maybe someone else > can chime in here. > > crIn unit test you never call the controller. Unit test are used to test the model only. For controller testing, use functionnall test instead. HTH -- Posted via http://www.ruby-forum.com/.
Reasonably Related Threads
- second assert_tag failling in rails integration test
- test_create gets 200 instead of :success
- Functional Tests misbehaving with Globalize
- [PATCH server] fixed functional tests after recent controller refactoring and managed node controller fixes.
- some help with functional testing of nested routes