0
我寫發動機:的Rails 4.0引擎和嵌套路由測試使用RSpec 3
module MercatorMpay24
class Admin::PaymentsController < ::Admin::AdminSiteController
def check_confirmation
@payment = Payment.find(params[:id])
end
end
end
和定義的路由:
MercatorMpay24::Engine.routes.draw do
namespace :admin do
get 'payments/:id/check_confirmation' => 'payments#check_confirmation',
:as => 'check_confirmation'
end
end
工作正常並且可以調用,響應,.. 。
現在我想單元測試:
require 'spec_helper'
describe MercatorMpay24::Admin::PaymentsController, :type => :controller do
describe "GET #check_confirmation" do
it "finds the payment" do
@payment = create(:payment)
get :check_confirmation, id: @payment.id
expect(assigns(:payment)).to eql @payment
end
end
end
但給我一個錯誤:
No route matches {:action=>"check_confirmation",
:controller=>"mercator_mpay24/admin/payments", :id=>"1"}
而rake routes | grep check_confirmation
給我:
admin_check_confirmation GET /admin/payments/:id/check_confirmation(.:format)
mercator_mpay24/admin/payments#check_confirmation
我想,我在這裏做一些錯誤的命名空間,但我不知道,是什麼.. ..