From 37249f6a864d6f54cb66168fd2e51b409fb5bc63 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 18 Feb 2005 17:13:57 +0000 Subject: Fixed that assert_template_xpath_matches did not indicate when a path was not found #658 [Eric Hodel] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@665 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/action_controller/assertions/action_pack_assertions.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/assertions/action_pack_assertions.rb') diff --git a/actionpack/lib/action_controller/assertions/action_pack_assertions.rb b/actionpack/lib/action_controller/assertions/action_pack_assertions.rb index a8819550e6..c9a1aae174 100644 --- a/actionpack/lib/action_controller/assertions/action_pack_assertions.rb +++ b/actionpack/lib/action_controller/assertions/action_pack_assertions.rb @@ -217,7 +217,14 @@ module Test #:nodoc: response = acquire_assertion_target xml, matches = REXML::Document.new(response.body), [] xml.elements.each(expression) { |e| matches << e.text } - matches = matches.first if matches.length < 2 + if matches.empty? then + msg = build_message(message, " not found in document", + expression) + flunk(msg) + return + elsif matches.length < 2 then + matches = matches.first + end msg = build_message(message, " found , not ", expression, matches, expected) assert_block(msg) { matches == expected } -- cgit v1.2.3