我正在使用forem rails 引擎,但无法编写 rspec请求规范,因为找不到我尝试使用的路线(根据 rspec)。我想使用请求规范来POST
请求创建对主题的回复。
请求规范中的以下内容不起作用:
post "/forums/topics/#{topic.to_param}/posts", :post => { 'text' => 'reply' }
它失败了
No route matches [POST] "/forums/topics/first-topic/posts"
事情是这样的: rake routes from spec/dummy
:
Routes for Forem::Engine:
POST /topics/:topic_id/posts(.:format) forem/posts#create
从网站创建帖子的日志
Started POST "/forums/topics/welcome-to-forem/posts" for 127.0.0.1 at 2013-08-19 22:23:47 +0800
Processing by Forem::PostsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"vnzhdaRDTye1wM5eQEIAW8W/urG/18PJ02oPqcX3pK8=", "post"=>{"text"=>"asdf", "reply_to_id"=>"1"}, "commit"=>"Post Reply", "topic_id"=>"welcome-to-forem"}
来自请求规范中的撬动会话 - 显示路径被主机应用程序识别forem
但不是主机应用程序。
> forem.recognize_path "/topics/#{topic.to_param}/posts", :method => :post
=> {:action=>"create", :controller=>"forem/posts", :topic_id=>"first-topic"}
> Rails.application.routes.recognize_path "/topics/#{topic.to_param}/posts", :method => :post
ActionController::RoutingError: No route matches "/topics/first-topic/posts"
如何编写请求规范以创建对主题的回复?