전통적인 RESTful 방식으로 직접 액세스 할 수없는 컨트롤러가 있지만 특정 URL을 통해서만 액세스 할 수 있습니다.직접 액세스 할 수없는 RSpec 컨트롤러 동작 테스트
일반적으로 get 및 post를 내 컨트롤러 사양에서 사용하여 컨트롤러 작업을 호출하는 데 익숙합니다. 특정 URL을 방문하여 컨트롤러를 사용할 수있는 방법이 있습니까?
이 편집 : 여기
Larzworld::Application.routes.draw do
match '/auth/:provider/callback' => 'authentications#create'
devise_for :users, :controllers => {:registrations => "registrations"}
root :to => 'pages#home'
end
내 사양입니다 : 여기
내 경로 여기
require 'spec_helper'
describe AuthenticationsController do
before(:each) do
request.env["omniauth.auth"] = {"provider" => "twitter", "uid" => "12345678"}
end
describe 'POST create' do
it "should find the Authentication using the uid and provider from omniauth" do
Authentication.should_receive(:find_by_provider_and_uid)
post 'auth/twitter/callback'
end
end
end
에러가 나는 받게된다
Failures:
1) AuthenticationsController POST create should find the Authentication using the uid and provider from omniauth
Failure/Error: post 'auth/twitter/callback'
No route matches {:action=>"auth/twitter/callback", :controller=>"authentications"}
# ./spec/controllers/authentications_controller_spec.rb:13
Finished in 0.04878 seconds
1 example, 1 failure
좋아, 그건 내가 생각했던 것인데, 그런 다음 내가 편집 한 게시물을보고 내 경로, 테스트 및 오류를 게시합니다. 왜 올바른 동작으로 매핑하지 않는지 이해할 수 없습니다. – TheDelChop
내 편집을 참조하십시오. 여기 라우팅 테스트가 정말로 필요합니다. – zetetic