From d96899be8cdb4b8b2d9b65f52db432e745e7e84c Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Mon, 23 Feb 2009 11:19:09 -0500 Subject: [PATCH] Remove extra whitespace from contain failure message --- lib/webrat/core/matchers/have_content.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/webrat/core/matchers/have_content.rb b/lib/webrat/core/matchers/have_content.rb index 8c1e3ff..7fc7481 100644 --- a/lib/webrat/core/matchers/have_content.rb +++ b/lib/webrat/core/matchers/have_content.rb @@ -26,15 +26,19 @@ module Webrat # ==== Returns # String:: The failure message. def failure_message - "expected the following element's content to #{content_message}:\n#{@element}" + "expected the following element's content to #{content_message}:\n#{squeeze_space(@element)}" end # ==== Returns # String:: The failure message to be displayed in negative matches. def negative_failure_message - "expected the following element's content to not #{content_message}:\n#{@element}" + "expected the following element's content to not #{content_message}:\n#{squeeze_space(@element)}" end - + + def squeeze_space(inner_text) + inner_text.gsub(/^\s*$/, "").squeeze("\n") + end + def content_message case @content when String