Using Webrat's save_and_open_page on Linux
Mmmm, this year has flown and I have done hardly any blogging, despite my intention to blog at least once a week. Oh, well. My excuse is working extra hard to cover a family holiday and the upcoming trip to Scottland on Rails.
The best way to get going on something is to just do it so here is a quick post on how to view the page you're working on in Webrat with it's save page feature when on Linux (It is currently only works on Windows and Mac)
A quick monkey patch in your test helper or Cucumber env file:
module Webrat::SaveAndOpenPage
alias_method :old_open_in_browser, :open_in_browser
def open_in_browser(path)
if ruby_platform =~ /linux/i
`firefox #{path}`
else
old_open_in_browser path
end
end
end
This is not perfect because it is specific to using Firefox, but I know most of you use Firefox anyway, and at least it will continue to work for those using Windows or Mac
Now let's hope I can get my work load under control and post more frequently.
Comments
Have your say