Created
February 22, 2009 15:33
-
-
Save nkryptic/68497 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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 = { '&' => '&', '>' => '>', '<' => '<', '"' => '"' } | |
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