Commit 5d783a7e4a2c6ceed45ce9573cba13ef03af5963
1 parent
92267854
Exists in
master
and in
20 other branches
rails4: check tag content
Showing
1 changed file
with
7 additions
and
1 deletions
Show diff stats
test/test_helper.rb
... | ... | @@ -138,12 +138,18 @@ class ActiveSupport::TestCase |
138 | 138 | def find_tag_in_string text, options |
139 | 139 | doc = Nokogiri::HTML.fragment text |
140 | 140 | tag = doc.css(options[:tag]).first |
141 | + content = tag.text.strip | |
142 | + | |
141 | 143 | attributes = {}; tag.attributes.each do |a, v| |
142 | 144 | a = a.to_sym |
143 | 145 | next unless options[:attributes].has_key? a |
144 | 146 | attributes[a] = v.value |
145 | 147 | end |
146 | - tag if (tag and attributes == options[:attributes]) | |
148 | + | |
149 | + ret = tag.present? | |
150 | + ret &&= options[:attributes].blank? || attributes == options[:attributes] | |
151 | + ret &&= options[:content].blank? || content == options[:content] | |
152 | + ret | |
147 | 153 | end |
148 | 154 | |
149 | 155 | def assert_tag_in_string(text, options) | ... | ... |