Skip to content

Instantly share code, notes, and snippets.

@tcdowney
Created October 10, 2014 02:39
Show Gist options
  • Save tcdowney/75263847ff43a11e038a to your computer and use it in GitHub Desktop.
Save tcdowney/75263847ff43a11e038a to your computer and use it in GitHub Desktop.
Missing Translations RSpec Matcher
# 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