gpt4 book ai didi

ruby-on-rails - omn​​iauth 模拟 facebook 回复

转载 作者:行者123 更新时间:2023-11-30 05:19:54 27 4
gpt4 key购买 nike

我想通过 Facebook 测试我的登录。我使用纯 omniauth,w/o Devise。我查看维基页面并执行以下操作:

请求规范的助手

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.[]

我的错误在哪里?

最佳答案

我的问题出在模拟中,它的结构有误。

OmniAuth.config.mock_auth[:facebook] = {
'user_info' => {
'name' => 'Mario Brothers',
'image' => '',
'email' => 'dpsk@email.ru' },
'uid' => '123545',
'provider' => 'facebook',
'credentials' => {'token' => 'token'}
}

关于ruby-on-rails - omn​​iauth 模拟 facebook 回复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7190677/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com