Created
October 10, 2014 02:39
-
-
Save tcdowney/75263847ff43a11e038a to your computer and use it in GitHub Desktop.
Missing Translations RSpec Matcher
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
# spec/support/missing_translations.rb | |
require 'rspec/expectations' | |
RSpec::Matchers.define :have_missing_translations do | |
match do |actual| | |
missing_i18n_js = /\[missing ".*" translation\]/ | |
missing_i18n_ruby = /class="translation_missing"/ | |
!!(actual.body.match(missing_i18n_ruby) || actual.body.match(missing_i18n_js)) | |
end | |
failure_message_for_should do |actual| | |
'expected page to have missing translations' | |
end | |
failure_message_for_should_not do |actual| | |
'expected page to not have missing translations' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment