0
私は問題に遭遇し、this answerが私の問題を解決すると信じていましたが、それを動作させることはできません。ここでこれらのテストが機能しないのはなぜですか?
は私のコードです:
setup do
# where the hell do I put this
def main_app
Rails.application.class.routes.url_helpers
end
@routes = Engine.routes
end
test "should get index" do
get :index
assert_response :success
end
[email protected]:~/sizzle-chisel$ rake test
Started with run options --seed 60111
ERROR["test_should_get_index", Blog::Admin::ArticlesControllerTest, 0.3109516409999742]
test_should_get_index#Blog::Admin::ArticlesControllerTest (0.31s)
ActionView::Template::Error: ActionView::Template::Error: undefined method `root_path' for #<ActionDispatch::Routing::
RoutesProxy:0x00000006eda278>
Blog::Engine.routes.draw do
root "articles#index"
resources :articles
namespace :admin do
resources :articles
root to: 'articles#index'
end
end
私はのroot_pathを得続ける私のレイアウト内、このコードがありますので、未定義です:
<%= link_to "some link", main_app.root_path %>
私のコードベースはRailsエンジンなので... rake testを実行すると、main_appにroot_pathが定義されていません。
これは私の質問に答えません...私が投稿したリンクを読んでください。私はあなたが私の問題を理解しているとは思わない。 –