Итак, я работаю над простым приложением Ruby on Rails. Фактически он основан на официальном учебнике, который вы можете найти по адресу http://guides.rubyonrails.org/getting_started.html. Я расширяю тестирование за рамки учебника. Используемая среда тестирования SimpleCov.Маршрут не найден при использовании POST с RoR
3) Error:
CommentsControllerTest#test_Rcomment_-_Create_(S):
ActionController::UrlGenerationError: No route matches {:action=>"/articles/201799169/:create", :comment=>{:alias=>"Somebody", :text=>"Some plain text"}, :controller=>"comments"}
test/controllers/comments_controller_test.rb:13:in `block (2 levels) in <class:CommentsControllerTest>'
test/controllers/comments_controller_test.rb:12:in `block in <class:CommentsControllerTest>'
Prefix Verb URI Pattern Controller#Action
welcome_index GET /welcome/index(.:format) welcome#index
root GET / welcome#index
article_comments GET /articles/:article_id/comments(.:format) comments#index
POST /articles/:article_id/comments(.:format) comments#create
new_article_comment GET /articles/:article_id/comments/new(.:format) comments#new
edit_article_comment GET /articles/:article_id/comments/:id/edit(.:format) comments#edit
article_comment GET /articles/:article_id/comments/:id(.:format) comments#show
PATCH /articles/:article_id/comments/:id(.:format) comments#update
PUT /articles/:article_id/comments/:id(.:format) comments#update
DELETE /articles/:article_id/comments/:id(.:format) comments#destroy
articles GET /articles(.:format) articles#index
POST /articles(.:format) articles#create
new_article GET /articles/new(.:format) articles#new
edit_article GET /articles/:id/edit(.:format) articles#edit
article GET /articles/:id(.:format) articles#show
PATCH /articles/:id(.:format) articles#update
PUT /articles/:id(.:format) articles#update
DELETE /articles/:id(.:format) articles#destroy
test "Rcomment - Create (S)" do
article = articles(:valid)
article.save
assert_difference('Comment.count') do
post '/articles/' + article.id.to_s + '/:create', comment: { alias: 'Somebody', text: 'Some plain text' }
end
assert_response :redirect
assert_redirected_to article_path(assigns(:article))
end
Paste вам контроллеры код –
Вы только POST против статей/{ArticleID}/комментарии, так же, как линия 4 ваших маршрутов говорит. Какая черта «/: create» там? – railsdog