From 5d783a7e4a2c6ceed45ce9573cba13ef03af5963 Mon Sep 17 00:00:00 2001 From: Braulio Bhavamitra Date: Thu, 9 Apr 2015 21:52:44 -0300 Subject: [PATCH] rails4: check tag content --- test/test_helper.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index 6eaa95d..3562a60 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -138,12 +138,18 @@ class ActiveSupport::TestCase def find_tag_in_string text, options doc = Nokogiri::HTML.fragment text tag = doc.css(options[:tag]).first + content = tag.text.strip + attributes = {}; tag.attributes.each do |a, v| a = a.to_sym next unless options[:attributes].has_key? a attributes[a] = v.value end - tag if (tag and attributes == options[:attributes]) + + ret = tag.present? + ret &&= options[:attributes].blank? || attributes == options[:attributes] + ret &&= options[:content].blank? || content == options[:content] + ret end def assert_tag_in_string(text, options) -- libgit2 0.21.2