Rails 2.0: selenium-on-rails routes.rb fix

When I updated a few projects to Rails 2.0 last year, selenium-on-rails stopped working … some issue with routing and the lame way selenium-on-rails adds its routes. I didn’t spend the time to figure out exactly what the routing problem was, but did manage to hack a quick fix into routes.rb. This feels like the Wrong Way for an ultimate fix but it at least solves the immediate problem. Shove these rules into your routes.rb and the /selenium path should start resolving again…

ActionController::Routing::Routes.draw do |map|

# other rules
# ...
# HACK for selenium-on-rails in rails 2.0
if RAILS_ENV == 'test'

map.connect 'selenium/setup', :controller => 'selenium', :action => 'setup'
map.connect 'selenium/tests/*testname', :controller => 'selenium', :action => 'test_file'
map.connect 'selenium/postResults', :controller => 'selenium', :action => 'record'
map.connect 'selenium/postResults/:logFile', :controller => 'selenium', :action => 'record', :requirements => { :logFile => /.*/ }
map.connect 'selenium/*filename', :controller => 'selenium', :action => 'support_file'



Leave a Reply

Your email address will not be published. Required fields are marked *