Skip to content

Instantly share code, notes, and snippets.

@nkryptic
Created February 22, 2009 15:33
Show Gist options
  • Save nkryptic/68497 to your computer and use it in GitHub Desktop.
Save nkryptic/68497 to your computer and use it in GitHub Desktop.
## in my env.rb (only part of it)
require 'webrat'
Webrat.configure do |config|
config.mode = :rails
config.open_error_files = false
end
class Webrat::Session
alias_method :old_formatted_error, :formatted_error
def formatted_error
def unescape( text )
html = { '&amp;' => '&', '&gt;' => '>', '&lt;' => '<', '&quot;' => '"' }
text.to_s.gsub(/(?:#{html.keys.join('|')})/) { |special| html[special] }
end
doc = Nokogiri::HTML( old_formatted_error )
content = []
doc.xpath('//body/p|//body/pre').each do |para|
value = unescape( para.inner_html.gsub( /<\/?[^>]+>/, '') )
content << value unless value =~ /^\s*(?:\{|RAILS_ROOT:|Parameters:|Show session dump|Headers:)/
end
content.join("\n");
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment