From c069389ac53f228920d731ecea786fce96d143d9 Mon Sep 17 00:00:00 2001 From: benj Date: Sat, 12 Sep 2020 13:57:32 +0200 Subject: [PATCH] Fix #73: :seen squeeze all non whitespace characters --- lib/rspec-html-matchers/nokogiri_text_helper.rb | 2 +- spec/issues_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/rspec-html-matchers/nokogiri_text_helper.rb b/lib/rspec-html-matchers/nokogiri_text_helper.rb index cfb622b..27eccfe 100644 --- a/lib/rspec-html-matchers/nokogiri_text_helper.rb +++ b/lib/rspec-html-matchers/nokogiri_text_helper.rb @@ -15,7 +15,7 @@ def initialize text, squeeze_text = false def content node_set node_set.find_all do |node| actual_content = node.content.gsub(NON_BREAKING_SPACE, ' ') - actual_content = node.content.strip.squeeze(' ') if @squeeze_text + actual_content = node.content.gsub(/\s+/, ' ').strip if @squeeze_text actual_content == @text end diff --git a/spec/issues_spec.rb b/spec/issues_spec.rb index b94cd12..f55a7c9 100644 --- a/spec/issues_spec.rb +++ b/spec/issues_spec.rb @@ -13,4 +13,15 @@ expect('

My paragraph.

').not_to have_tag('body') end end + + it '#73' do # https://github.com/kucaahbe/rspec-html-matchers/issues/73 + rendered = < + content with ignored + spaces + around +

+HTML + expect(rendered).to have_tag('p', :seen => 'content with ignored spaces around') + end end