मैं फेसबुक के माध्यम से अपना लॉगिन परीक्षण करना चाहता हूं। मैं शुद्ध omniauth का उपयोग कर, डब्ल्यू/ओ Devise। मैं विकि पृष्ठ की जाँच करें और निम्न करें:omniauth mock facebook प्रतिक्रिया
अनुरोध चश्मा के लिए सहायक
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.[]
मेरी त्रुटि कहां है?
अगर मैं अपने नकली और मेजबान के साथ हिस्सा बाहर टिप्पणी व्यवहार फ्लॉप परिवर्तन की तुलना में (केवल enable_test_mode = छोड़ दिया सही)। ऐसा लगता है जैसे omniauth बस मेरे नकली नहीं देखा: | –
आपके सत्र नियंत्रक और उपयोगकर्ता मॉडल कैसा दिखता है? – azolotov