testing .mobile mime format with capybara / rspec

Posted by Chris Beck on Stack Overflow See other posts from Stack Overflow or by Chris Beck
Published on 2012-09-05T03:43:07Z Indexed on 2012/09/05 21:38 UTC
Read the original article Hit count: 258

For detecting and responding to mobile user agents, I'm using

Mime::Type.register_alias "text/html", :mobile

and the approach I'm wondering what is the best approach to test with capybara. This article suggests setting up an iphone driver with Capybara.register_driver :iphone do |app|

http://blog.plataformatec.com.br/2011/03/configuring-user-agents-with-capybara-selenium-webdriver/

but I'd like a more flexible approach where the mime type is set via the url extension

localhost/index.mobile

and where I can do this

visit user_path( format: :mobile)

Rails understands the extension and sets the format in the params hash, but how do I get the url helper methods to add that to all urls as a file extension?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about url-routing