У меня возникла проблема и нашла 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, на main_app не указан root_path.
это не отвечает на мой вопрос ... прочитайте ссылку, которую я разместил. Я не думаю, что вы понимаете мою проблему. –