Created
December 4, 2012 17:44
-
-
Save sirbrillig/4206758 to your computer and use it in GitHub Desktop.
RSpec have_normal_content matcher to normalize text.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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