# File lib/mspec/matchers/equal_element.rb, line 9
 9:   def matches?(actual)
10:     @actual = actual
11:     
12:     matched = true
13:     
14:     if @options[:not_closed]
15:       matched &&= actual =~ /^#{Regexp.quote("<" + @element)}.*#{Regexp.quote(">" + (@content || ''))}$/
16:     else
17:       matched &&= actual =~ /^#{Regexp.quote("<" + @element)}/
18:       matched &&= actual =~ /#{Regexp.quote("</" + @element + ">")}$/
19:       matched &&= actual =~ /#{Regexp.quote(">" + @content + "</")}/ if @content      
20:     end
21:     
22:     if @attributes
23:       if @attributes.empty?
24:         matched &&= actual.scan(/\w+\=\"(.*)\"/).size == 0
25:       else
26:         @attributes.each do |key, value|
27:           if value == true
28:             matched &&= (actual.scan(/#{Regexp.quote(key)}(\s|>)/).size == 1)
29:           else
30:             matched &&= (actual.scan(%Q{ #{key}="#{value}"}).size == 1)
31:           end
32:         end        
33:       end
34:     end
35:     
36:     !!matched
37:   end