3
Omniauth를 통해 Facebook 인증 콜백을 설정하려고 할 때 이상한 문제가 있습니다. (오류를 표시하는 데 필요한 코드 만에 간체) 내 컨트롤러에서 나는이 :이 나에게 해시를 보여주는, 생산 모드에서 작동omniauth 콜백 테스트에 rspec을 사용할 때 env 설정
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
raise env.inspect
# auth_hash = env["omniauth.auth"]
end
end
. 그러나 테스트 모드에서 env는 nil로 설정됩니다.
나는 내 spec_helper.rb 파일
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:facebook, {"credentials" => {
"token" => "foo-token"
}
})
에서 설정 한 다음 한 내 사양은 다음과 같습니다
require 'spec_helper'
describe Users::OmniauthCallbacksController do
describe "Facebook" do
before(:each) do
request.env["devise.mapping"] = Devise.mappings[:user]
request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:facebook]
end
it "should be a redirect" do
get :facebook
response.should redirect_to(root_path)
end
end
end
사람이 내가 ENV를하지 않은하기 위해 무엇을해야하는지에 가르치 려 수 테스트를 실행할 때 제로가되지 않습니까?