unit testing - Rails test - error with routing -
i have strange problem.
when run rake test, following wrror:
1) error: streamscontrollertest#test_should_get_index: runtimeerror: in order use #url_for, must include routing helpers explicitly. instance, `include rails.application.routes.url_helpers test/controllers/streams_controller_test.rb:5:in `block in <class:streamscontrollertest>' i added following code /test/test_helper.rb:
include rails.application.routes.url_helpers default_url_options[:host] = configurable[:server_host_name] default_url_options[:protocol] = configurable[:server_protocol] but still same error.
inside test class, sure, added debugging message:
require 'test_helper' class streamscontrollertest < actioncontroller::testcase test "should index" puts ">>>> #{streams_url} <<<<" :index assert_response :success end end and expected url:
>>>> http://testing-end.com/streams <<<< btw, if change get :index get :index2 (which not exist) error:
1) error: streamscontrollertest#test_non_existing_action: actioncontroller::urlgenerationerror: no route matches {:action=>"index2", :controller=>"streams"} test/controllers/streams_controller_test.rb:11:in `block in <class:streamscontrollertest>' (which looks reasonable me)
some idea going on here??
================= update ==================
in integration test file able access pages using routes, example:
require 'test_helper' class cacheflowstest < actiondispatch::integrationtest test "should index" root_url assert_response :success end but - when execution reaches route inside browsed code breaks:
1) error: cacheflowstest#test_should_get_index: actionview::template::error: arguments passed url_for can't handled. please require routes or provide own implementation app/views/streams/index.html.erb:51:in `block in _app_views_streams_index_html_erb__1226577901840473982_74088540' app/views/streams/index.html.erb:38:in `_app_views_streams_index_html_erb__1226577901840473982_74088540' test/integration/cache_flows_test.rb:5:in `block in <class:cacheflowstest>' i hope information understanding going on.
Comments
Post a Comment