我创建了简单的引擎。一切正常,但是当我尝试为引擎控制器编写功能测试时,出现如下错误:
3) Error:
test_should_get_new(Supportilla::SessionsControllerTest):
ActionView::Template::Error: No route matches {}
我的测试文件 test/functional/supportilla/sessions_controller_test.rb:
require 'test_helper'
module Supportilla
class SessionsControllerTest < ActionController::TestCase
test "should get new" do
get "new", use_route: "supportilla"
assert_response :success
end
test "should get create" do
post :create, { session: { username: "test", password: "123"},
use_route: :supportilla }
assert_response :success
end
...
end
end
并且引擎安装在 test/dummy/config/routes.rb 中:
mount Supportilla::Engine => "/supportilla"
耙路线:
Routes for Supportilla::Engine:
signin GET /signin(.:format) supportilla/sessions#new
signout GET /signout(.:format) supportilla/sessions#destroy
POST /signin(.:format) supportilla/sessions#create
...
我很困惑,希望得到你的帮助。