我正在使用forem rails引擎,我无法编写rspec 请求规范,因为我尝试使用的路由无法找到(根据rspec)。我想使用请求规范发出POST
请求来创建对主题的回复。
请求规范中的以下内容不起作用:
post "/forums/topics/#{topic.to_param}/posts", :post => { 'text' => 'reply' }
失败了
No route matches [POST] "/forums/topics/first-topic/posts"
以下是事物的外观:从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"}
来自请求规范中的pry会话 - 显示路径由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"
如何编写我的请求规范以创建对主题的回复?