Forum: Ruby on Rails Help needed using assigns() functionality in functional test

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Keith L. (Guest)
on 2006-01-20 22:39
Accidentally posted this to the engines group first...dang computers :-)



I'm trying to create a functional test where the controller action (for
now, anyway) breaks apart a string and populates intermediate variables
with the results. I want to check the intermediate vars in my test, so I
tried the following

(in the controller)

def string_action
  # do some processing, etc.
  @string_segment = "howdy"
end

(in the unit test)
def test_the_string_doohicky
  post :string_action, ... some params here, etc.
  assert_equal "howdy", assigns["string_segment"]
end

The assigns[] always comes up nil, so I must be missing something here.
Any pointers?

TIA,
Keith

Reply with quote
Joerg D. (Guest)
on 2006-01-20 23:47
Try assings(:string_segment) rather.


> (in the unit test)
> def test_the_string_doohicky
>   post :string_action, ... some params here, etc.
>   assert_equal "howdy", assigns["string_segment"]
> end
>
> The assigns[] always comes up nil, so I must be missing something here.
> Any pointers?
Keith L. (Guest)
on 2006-01-21 00:01
Joerg D. wrote:
> Try assings(:string_segment) rather.
>
>
>> (in the unit test)
>> def test_the_string_doohicky
>>   post :string_action, ... some params here, etc.
>>   assert_equal "howdy", assigns["string_segment"]
>> end
>>
>> The assigns[] always comes up nil, so I must be missing something here.
>> Any pointers?

Ok, so I tried that and it worked. Just for fun, I went back to the
other method, and this time IT worked. I keep forgetting that old
saying,

       "Never code Ruby while drinking tequila".

:-)

(Actually, have changed a number of things in code since posting, so
maybe I accidentally fixed something in the process...)

Thanks for the help.
Keith
This topic is locked and can not be replied to.