Upgrading to rails 2.3.11 – A selenium and mongrel odyssey

In the last weeks, as a low priority task, I ported our rails app from 2.3.4 to 2.3.11.
The process went well, I updated all gems, fixed all warnings and all our cucumber, spec, unit, function, integration tests… easy stuffs.
BUT we have also some selenium tests that cover ajax interactions and some critical scenario for our app, so I started to check if everything was fine there also and that was the start of my odyssey.

To make a long story short here are the steps I followed to find the problem:

running the tests I was receiving:

1) Error:
Webrat::TimeoutError: Timeout exceeded (after 5 sec)
webrat (0.7.3) lib/webrat/selenium/selenium_session.rb:189:in `wait_for'
webrat (0.7.3) lib/webrat/selenium.rb:62:in `wait_for'
/test/selenium/../selenium_test_base.rb:117:in `assert_contain_waiting'
/test/selenium/../selenium_test_base.rb:81:in `log_in'
/test/selenium/buoni_sconto_monouso_selenium_test.rb:29:in `test_already_used_coupon_inserted_before_login'

basically it cannot verify the user is correctly logged in.
I thought it was a cookie/session problem because I saw it was able to find the given user so I put a “debugger” to be able to use the firefox in the middle of the test and check the response headers. No session cookie was present after log in.

Using script/server everything was fine… so what’s the problem, it should be in the way webrat starts mongrel so I looked in the webrat source to find in which way it starts mongrel.
I started mongrel directly from the terminal and as soon as it was up & running visiting the homepage I got these errors in the console:

Fri Jun 16 13:21:12 +0200 2011: Error calling Dispatcher.dispatch #
/Users/silk/.rvm/gems/ruby-1.8.7-p302@epistore.2.3.10/gems/mongrel-1.1.5/bin/../lib/mongrel/cgi.rb:108:in `send_cookies'

Bingo! from here it was easy to ask google for a solution “mongrel_server rails 2.3.11 cookies” and it pointed me to this post that have the solution:


Now it’s time to move to rails 3.0.9!!!