/rails-minitest-fails-with-task

showcase minittest errors when creating a rake task which includes url_helpers

Primary LanguageRuby

README

a test environment to reproduce errors when creating rake-tasks which include url_helpers

given i want to make use of helpers and url_helper in rake task: /lib/tasks/foo.rake

findings

whenever you include

include Rails.application.routes.url_helpers
...

in rake task then ‘rake test’ will produce errors because of the included url_helpers

rake test (with rails 4.2.4)

1) Error:
ToolsControllerTest#test_should_get_edit:
RuntimeError: In order to use #url_for, you must include routing helpers explicitly. For instance, `include Rails.application.routes.url_helpers`.
   test/controllers/tools_controller_test.rb:33:in `block in <class:ToolsControllerTest>'

rake test (with rails 4.2.5)

1) Error:
ToolsControllerTest#test_should_get_edit:
ActionView::Template::Error: arguments passed to url_for can't be handled. Please require routes or provide your own implementation
   app/views/tools/edit.html.erb:5:in `_app_views_tools_edit_html_erb___1103415953847731251_37693160'
   test/controllers/tools_controller_test.rb:33:in `block in <class:ToolsControllerTest>'