Skip to content

Instantly share code, notes, and snippets.

@james
Created March 14, 2022 09:09
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 james/1349db428b4a25892ddddb82ddd380e8 to your computer and use it in GitHub Desktop.
Save james/1349db428b4a25892ddddb82ddd380e8 to your computer and use it in GitHub Desktop.
desc "Will replace i18n references in specs with actual text from default locale"
task undo_i18n_in_specs: :environment do
Dir[Rails.root.join("spec/features/**/*.rb")].collect do |file_name|
file_text = File.read(file_name)
file_text.scan(/\Wt\("([\w\.]+)"\)/).each do |match|
file_text.gsub!("t(\"#{match.first}\")", "\"#{I18n.t(match.first)}\"")
end
File.open(file_name, "w") { |file| file.puts file_text }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment