views:

38

answers:

1

i am trying to create a simple login test, but cannot get past the follow_redirect. it says: TypeError: can't convert Symbol into String when it meets the 'follow_redirect'. Does it have anything to do with the fact that we are using https for the login process? i simply want to assert that the user is able to log in, and gets redirected to some other controller based on the type of user, but cannot get past the first redirect.

In response to the comment asking for error, here is the relevant portion:

The code is:

19   def test_login
20     params = {:email => 'normaluser.com', :password => 'password'}
21     post :login, params
22     puts "#{@response.inspect}"
23     assert_response :redirect
24     #assert_redirected_to '/user/login?email=normaluser.com&password=password'
25     follow_redirect
26     assert_response :success

The error i get is :

TypeError: can't convert Symbol into String
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/test_process.rb:413:in `delete'
/usr/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/test_process.rb:413:in `follow_redirect_without_deprecation'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/deprecation.rb:94:in `send'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/deprecation.rb:94:in `follow_redirect'
user_controller_test.rb:25:in `test_login'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/testing/setup_and_teardown.rb:33:in `__send__'
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/active_support/testing/setup_and_teardown.rb:33:in `run'
A: 

I'm not in favour of testing use interaction like this. It's too artificial. For testing login and other user interaction I use and highly recommend using Cucumber. This allows you to actually fill out the login form and "see" what your apps response is. That way you are not only testing your controllers, but your entire app stack. The benefit of that is that when you introduce a bug anywhere in your application, you'll notice it in your cucumber tests.

My recommendation is: use cucumber for your entire stack and rspec to test your models thoroughly.

Ariejan
you may be right, and i will explore cucumber testing, but i currently want to find out why i am getting error messages in such a simple 4 lines. basically i was not expecting a redirect to self, but i get it, and then when i try to follow the redirect, i get an error, so not sure what i need to do to make it work. does https have anything to do with it, or follow_redirect no longer works in rails 2.1.2?