Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable using just t (not I18n.t) in specs #304

Merged
merged 1 commit into from
Mar 20, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]:

Expand Down
4 changes: 4 additions & 0 deletions lib/suspenders/app_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/suspenders/generators/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions templates/i18n.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RSpec.configure do |config|
config.include AbstractController::Translation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be rather ActionView::Helpers::TranslationHelper? I'm not sure on the differences between the two

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me neither. I've used this on 2 projects so far and I haven't run into any problems. The TranslationHelper might be the wrapper that allows you to do t(".hello") (note the leading dot), which we wouldn't use in specs.

end