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.
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]
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.
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]
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.
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 "/"