에 대한 통합 테스트에서 나는에 Omniauth 테스트 모드가:</p> <p><strong>spec_helper (내가 바로 <code>end</code> 전에 파일의 맨 아래에 넣어) :</strong> OmniAuth
#Turn on "test mode" for OmniAuth
OmniAuth.config.test_mode = true
이 내 테스트입니다 :
사양/요청/authorization_pages_spec.rb :
나는 내 테스트를 실행할 때describe "signin" do
before { visit signin_path }
.
.
.
describe "with OmniAuth" do
before do
OmniAuth.config.add_mock :facebook, uid: "fb-12345", info: { name: "Bob Smith" }
visit root_path
end
describe "Facebook provider" do
before do
request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:facebook]
click_link "Sign in with Facebook"
end
it { should have_selector('title', text: user.name) }
it { should have_link('Users', href: users_path) }
it { should have_link('Profile', href: user_path(user)) }
it { should have_link('Settings', href: edit_user_path(user)) }
it { should have_link('Sign out', href: signout_path) }
it { should_not have_link('Sign in', href: signin_path) }
end
난이 얻을 :
실패 :
1) Authentication signin with OmniAuth Facebook provider
Failure/Error: request.env["omniauth.auth"] = OmniAuth.config.mock_auth[:facebook]
NoMethodError:
undefined method `env' for nil:NilClass
# ./spec/requests/authentication_pages_spec.rb:57:in `block (5 levels) in <top (required)>'
(등).
누락되었거나 잘못된 것입니까?
이것을 알아 냈습니까? 나는 같은 문제가있다. ... – Brandon
@Brandon 잠을 2 주 후에, 나는 포기했다. 그리고 새로운 규칙을 채택했습니다 : 보석을 시험하지 마십시오. 그렇지 않으면 시험을 싫어하게 될 것입니다. – alexchenco