I've run into a fairly strange issue recently when testing my Rails application. I have a route set up as follows in routes.rb:
controller :employees do match ':company/:department/:lastname' => :show, :via => :get end
So, doing a request as follows: get '/exampleinc/it/foo'
Routes correctly to: { :controller => "employees", :department => "it", :company => "exampleinc", :lastname => "foo", :action => "show" }
However, when using Faker to generate some basic test data, I have it generating information with spaces, periods, and other special characters that will undoubtedly be part of the real world for this application. But in testing, I've found that when spaces, periods, and/or other URL-encoded (or not) variables are present in the request, the router doesn't even route it to the controller - it just spits out a "No Route Matches" error instead.
So for example: get '/Example,+Inc./IT/Some+Last+Name'
Causes an ActionController::RoutingError: No route matches { :action => "show", :company => "Example+Inc.", :controller => "employees", :lastname => "Some+Last+Name", :department => "IT" }
What can I do differently in my routes to make this route correctly? Thanks for any help you can provide.