페이스 북을 통해 로그인을 테스트하고 싶습니다. 순수한 omniauth를 사용하여 Im, Devise. 나는 위키 페이지를 확인하고 다음을 수행하십시오 스펙 아무것도의 요구 사양에 대한omniauth mock facebook response
도우미
module IntegrationSpecHelper
def login_with_oauth(service = :facebook)
visit "/auth/#{service}"
end
end
spec_helper.rb
RSpec.configure do |config|
config.include IntegrationSpecHelper, :type => :request
end
Capybara.default_host = 'http://example.org'
OmniAuth.config.test_mode = true
OmniAuth.config.add_mock(:facebook, {
:provider => 'facebook',
:uid => '12345',
:user_info => {
:name => 'dpsk'
}
})
내 사양
require 'spec_helper'
describe 'facebook' do
it "should login with facebook", :js => true do
login_with_oauth
visit '/'
page.should have_content("dpsk")
end
end
#OmniAuth routes
match "/auth/:provider/callback" => "sessions#create"
match "/signout" => "sessions#destroy", :as => :signout
match "/signin" => "sessions#signin", :as => :signin
match "/auth/failure" => "sessions#failure", :as => :auth_failure
그러나이 대신 반환 내 모의 나는 오류있어 :
Failure/Error: visit "/auth/facebook"
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
내 실수는 어디에 있습니까?
것은 내가 내 모의와 호스트 부분을 주석 경우 행동 didnt 한 변화보다 (사실 만 enable_test_mode = 왼쪽). 옴니 아워처럼 내 모의도를 보지 못했던 것 같습니다 : | –
세션 컨트롤러 및 사용자 모델은 어떻게 생겼습니까? – azolotov