How to access controller's instance variables in integration tests?

In my controller's action I set instance variables like:

    @last_action = xxx     @paid_with_card = xxx

Now, how do I access them in my integration tests? I tried Mike Clark's example(1):    assert_not_nil assigns(:paid_with_card)

But my test fails: ============start test output====== Started ...................F.. Finished in 17.906 seconds.

  1) Failure: test_select_and_buy_pack(AllPagesTest)     [./test/integration/all_pages_test.rb:27:in `test_select_and_buy_pack'      c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/integration.rb:453:in `run']: <nil> expected to not be nil.

22 tests, 63 assertions, 2 failures, 0 errors ============end test output======

What can I do to access these variables? What do I get wrong here? What am I missing? How do you actually read instance variables from the controller in the integration tests???

Thanks in advance! /Jesper Rønn-Jensen, www.justaddwater.dk

PS I have also tried these that don't seem to work either:     # controller.instance_variable_get("@paid_with_card")     # controller.assigns(:paid_with_card)     # controller.assigns[:paid_with_card]     # assigns[:paid_with_card]

(1) Mike Clark's example: http://clarkware.com/cgi/blosxom/2006/04/04

Jesper Rønn-Jensen wrote:

In my controller's action I set instance variables like:

    @last_action = xxx     @paid_with_card = xxx

Now, how do I access them in my integration tests? I tried Mike Clark's example(1):    assert_not_nil assigns(:paid_with_card)

But my test fails: ============start test output====== Started ...................F.. Finished in 17.906 seconds.

  1) Failure: test_select_and_buy_pack(AllPagesTest)     [./test/integration/all_pages_test.rb:27:in `test_select_and_buy_pack'      c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/ action_controller/integration.rb:453:in `run']: <nil> expected to not be nil.

22 tests, 63 assertions, 2 failures, 0 errors ============end test output======

What can I do to access these variables? What do I get wrong here? What am I missing? How do you actually read instance variables from the controller in the integration tests???

Thanks in advance! /Jesper Rønn-Jensen, www.justaddwater.dk

PS I have also tried these that don't seem to work either:     # controller.instance_variable_get("@paid_with_card")     # controller.assigns(:paid_with_card)     # controller.assigns[:paid_with_card]     # assigns[:paid_with_card]

(1) Mike Clark's example: http://clarkware.com/cgi/blosxom/2006/04/04

>

Try

controller.instance_variable_get(:@paid_with_card)

Hope this helps, Chris

Try controller.instance_variable_get(:@paid_with_card) Hope this helps, Chris

Thanks for your support Chris. I finally managed to get it working, and inspired by your tip I made an integration test to test off what works and whatnot. I have included the non-working examples as well for later reference.

Kind regards, Jesper Rønn-Jensen http://justaddwater.dk/

PS. Actually I got it working with the first example I posted:   assert_not_nil assigns(:paid_with_card) The catch was to put a

post_via_redirect :params assert_not_nil assigns(:paid_with_card)

instead of

post :params assert_redirected_to follow_redirect assert_not_nil assigns(:paid_with_card)

========file "/test/integration/test_of_assigns.rb" below============ require "#{File.dirname(__FILE__)}/../test_helper" # This test requires a root route pointed to a controller for the default action # controller#index responding to "/"