Voglio testare il mio login tramite facebook. Sto usando puro omniauth, senza Devise. Posso controllare la pagina wiki e facciamo seguire:omniauth mock risposta facebook
aiuto per la richiesta di specifiche
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'
}
})
mia spec
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
Ma in spec nulla ritorna al posto di il mio finto ho ricevuto un errore:
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.[]
Dov'è il mio errore?
se io commento parte con la mia finta e ospite (lasciato solo enable_test_mode = true) di cambiare il comportamento di poco. sembra che omniauth non abbia visto il mio mock: | –
Che aspetto hanno il controller di sessione e il modello utente? – azolotov