nkryptic (owner)

Revisions

gist: 68497 Download_button fork
public
Public Clone URL: git://gist.github.com/68497.git
Ruby
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
## 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