Capybara::SaveAndOpenPage

Public Instance Methods

open_in_browser(path) click to toggle source
# File lib/capybara/save_and_open_page.rb, line 20
def open_in_browser(path) # :nodoc
  require "launchy"
  Launchy::Browser.run(path)
rescue LoadError
  warn "Sorry, you need to install launchy to open pages: `gem install launchy`"
end
save_and_open_page(html) click to toggle source
# File lib/capybara/save_and_open_page.rb, line 5
def save_and_open_page(html)
  name = File.join(*[Capybara.save_and_open_page_path, "capybara-#{Time.new.strftime("%Y%m%d%H%M%S")}.html"].compact)

  unless Capybara.save_and_open_page_path.nil? || File.directory?(Capybara.save_and_open_page_path )
    FileUtils.mkdir_p(Capybara.save_and_open_page_path)
  end
  FileUtils.touch(name) unless File.exist?(name)

  tempfile = File.new(name,'w')
  tempfile.write(rewrite_css_and_image_references(html))
  tempfile.close

  open_in_browser(tempfile.path)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.