Skip to content

Commit

Permalink
Fix #73: :seen squeeze all non whitespace characters
Browse files Browse the repository at this point in the history
  • Loading branch information
benj committed Sep 12, 2020
1 parent 306b8f4 commit c069389
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rspec-html-matchers/nokogiri_text_helper.rb
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions spec/issues_spec.rb
Expand Up @@ -13,4 +13,15 @@
expect('<p>My paragraph.</p>').not_to have_tag('body')
end
end

it '#73' do # https://github.com/kucaahbe/rspec-html-matchers/issues/73
rendered = <<HTML
<p>
content with ignored
spaces
around
</p>
HTML
expect(rendered).to have_tag('p', :seen => 'content with ignored spaces around')
end
end

0 comments on commit c069389

Please sign in to comment.