0
@@ -168,6 +168,8 @@ module Merb::Test::Rspec::ViewMatchers
0
+ attr_accessor :outer_has_tag, :inner_has_tag
0
# tag<~to_s>:: The tag to look for.
0
# attributes<Hash>:: Attributes for the tag (see below).
0
@@ -197,8 +199,13 @@ module Merb::Test::Rspec::ViewMatchers
0
!@document.search(selector).select do |ele|
0
+ rescue Spec::Expectations::ExpectationNotMetError
0
+ @error_message = "#{tag_for_error}:\n" + $!.message
0
!@document.search(selector).empty?
0
@@ -208,12 +215,10 @@ module Merb::Test::Rspec::ViewMatchers
0
# String:: The complete selector for element queries.
0
- @selector = "//#{@tag}#{id_selector}#{class_selector}"
0
- @selector << @attributes.map{|a, v| "[@#{a}=\"#{v}\"]"}.join
0
+ @selector = @outer_has_tag ? @outer_has_tag.selector : ''
0
- @selector << @inner_has_tag.selector unless @inner_has_tag.nil?
0
+ @selector << "//#{@tag}#{id_selector}#{class_selector}"
0
+ @selector << @attributes.map{|a, v| "[@#{a}=\"#{v}\"]"}.join
0
@@ -231,45 +236,38 @@ module Merb::Test::Rspec::ViewMatchers
0
# String:: The failure message.
0
-
"expected following output to contain a #{tag_for_error} tag:\n#{@document}"
0
+
@error_message || "expected following output to contain a #{tag_for_error} tag:\n#{@document}"
0
# String:: The failure message to be displayed in negative matches.
0
def negative_failure_message
0
-
"expected following output to omit a #{tag_for_error} tag:\n#{@document}"
0
+
@error_message || "expected following output to omit a #{tag_for_error} tag:\n#{@document}"
0
# String:: The tag used in failure messages.
0
- "#{inner_failure_message}<#{@tag}#{id_for_error}#{class_for_error}#{attributes_for_error}>"
0
- # The failure message to be displayed in negative matches within the
0
- def inner_failure_message
0
- "#{@inner_has_tag.tag_for_error} tag within a " unless @inner_has_tag.nil?
0
+ result = "#{@tag}#{id_for_error}#{class_for_error}#{attributes_for_error}"
0
+ inner_has_tag ? result << " > #{inner_has_tag.tag_for_error}" : result
0
# String:: ID for the error tag.
0
- "
id=\"#{@id}\"" unless @id.nil?
0
+ "
##{@id}" unless @id.nil?
0
# String:: Class for the error tag.
0
- "
class=\"#{@class}\"" unless @class.nil?
0
+ "
.#{@class}" unless @class.nil?
0
# String:: Class for the error tag.
0
def attributes_for_error
0
- @attributes.map{|a,v| "
#{a}=\"#{v}\""}.join
0
+ @attributes.map{|a,v| "
[#{a}=\"#{v}\"]"}.join
0
# Search for a child tag within a have_tag block.
0
@@ -279,6 +277,7 @@ module Merb::Test::Rspec::ViewMatchers
0
# attributes<Hash>:: Attributes for the tag (see below).
0
def with_tag(name, attrs={})
0
@inner_has_tag = HasTag.new(name, attrs)
0
+ @inner_has_tag.outer_has_tag = self