From 7ea5176ba7ae8c44248374a5edc3659e4f2aa00c Mon Sep 17 00:00:00 2001 From: Gabe Berke-Williams Date: Thu, 20 Mar 2014 13:07:56 -0400 Subject: [PATCH] Enable using just `t` (not `I18n.t`) in specs --- README.md | 2 ++ lib/suspenders/app_builder.rb | 4 ++++ lib/suspenders/generators/app_generator.rb | 1 + templates/i18n.rb | 3 +++ 4 files changed, 10 insertions(+) create mode 100644 templates/i18n.rb diff --git a/README.md b/README.md index 4ae1910da..8890f69e4 100644 --- a/README.md +++ b/README.md @@ -88,12 +88,14 @@ Suspenders also comes with: * [Fast-failing factories][fast] * A [low database connection pool limit][pool] * [Safe binstubs][binstub] +* [t() and l() in specs without prefixing with I18n][i18n] [bin]: http://robots.thoughtbot.com/bin-setup [compress]: http://robots.thoughtbot.com/content-compression-with-rack-deflater/ [fast]: http://robots.thoughtbot.com/testing-your-factories-first [pool]: https://devcenter.heroku.com/articles/concurrency-and-database-connections [binstub]: https://github.com/thoughtbot/suspenders/pull/282 +[i18n]: https://github.com/thoughtbot/suspenders/pull/304 Suspenders fixes several of Rails' [insecure defaults]: diff --git a/lib/suspenders/app_builder.rb b/lib/suspenders/app_builder.rb index b0fe4bfc5..20f4dfff0 100644 --- a/lib/suspenders/app_builder.rb +++ b/lib/suspenders/app_builder.rb @@ -172,6 +172,10 @@ def configure_travis template 'travis.yml.erb', '.travis.yml' end + def configure_i18n_in_specs + copy_file 'i18n.rb', 'spec/support/i18n.rb' + end + def use_spring_binstubs run 'bundle exec spring binstub --all' end diff --git a/lib/suspenders/generators/app_generator.rb b/lib/suspenders/generators/app_generator.rb index 5f7be301c..81e0015ab 100644 --- a/lib/suspenders/generators/app_generator.rb +++ b/lib/suspenders/generators/app_generator.rb @@ -82,6 +82,7 @@ def setup_test_environment build :enable_database_cleaner build :configure_spec_support_features build :configure_travis + build :configure_i18n_in_specs end def setup_production_environment diff --git a/templates/i18n.rb b/templates/i18n.rb new file mode 100644 index 000000000..3d4094d4b --- /dev/null +++ b/templates/i18n.rb @@ -0,0 +1,3 @@ +RSpec.configure do |config| + config.include AbstractController::Translation +end