Ruby on rails 3 rspec中无法识别命名路径

Ruby on rails 3 rspec中无法识别命名路径,ruby-on-rails-3,rspec,Ruby On Rails 3,Rspec,我使用的是Rails 3.1.0和Rspec 2.12.2。我想通过jQuery发布一个操作: /path/api/save-reply 我有以下规格: describe 'test adding new mb post' do it 'shall add a new mb post' do post :save_reply, mb_detail: 'here is my detail', timestamp_id: 123, parent_id: 50, depth: 0 e

我使用的是Rails 3.1.0和Rspec 2.12.2。我想通过jQuery发布一个操作:

/path/api/save-reply
我有以下规格:

describe 'test adding new mb post' do
  it 'shall add a new mb post' do
    post :save_reply, mb_detail: 'here is my detail', timestamp_id: 123, parent_id: 50, depth: 0
  end
end
使用以下命名路由:

routes.rb

post '/api/save-reply' => 'api_mb#save_mb_reply', :as => :save_reply, :defaults => { :format => 'json' }
并获取以下错误:

1) ApiMbController test adding new mb post shall add a new mb post
   Failure/Error: post :save_reply, mb_detail: 'here is my detail', timestamp_id: 123, parent_id: 50, depth: 0
   AbstractController::ActionNotFound:
     The action 'save_reply' could not be found for ApiMbController
   # ./spec/controllers/api_mb_controller_spec.rb:16:in `block (3 levels) in <top (required)>'

thx预先

控制器规范不使用路由来确定调用什么-它们只调用您指定的方法

thx-这看起来是正确的。我使用控制器而不是请求规范的唯一原因是处理cookie。有没有更好的方法来处理这个问题?我认为你仍然可以在请求规范中规范cookie内容。
Mon Jan 07$ bundle exec rake routes | grep save_reply
                      save_reply POST   /arc/v1/api/save-reply(.:format)                                                 {:format=>"json", :controller=>"api_mb", :action=>"save_mb_reply"}
Mon Jan 07$