Skip to content

Instantly share code, notes, and snippets.

@sirbrillig
Created December 4, 2012 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sirbrillig/4206758 to your computer and use it in GitHub Desktop.
Save sirbrillig/4206758 to your computer and use it in GitHub Desktop.
RSpec have_normal_content matcher to normalize text.
RSpec::Matchers.define :have_normal_content do |expected|
match do |actual|
actual.text.squish =~ Regexp.new(expected)
end
failure_message_for_should do |actual|
"expected content '#{expected}' in normalized text '#{actual.text.squish}'"
end
failure_message_for_should_not do |actual|
"expected not to find content '#{expected}' in normalized text '#{actual.text.squish}'"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment