2
我正在爲Facebook集成編寫測試。當我運行rspec的,我得到以下錯誤使用水豚/ Rspec爲Facebook測試OAuth
Failure/Error: before { click_link "Sign in with Facebook" }
NoMethodError:
undefined method `provider' for #<Hash:0x007fbe98511798>
# ./app/models/user.rb:55:in `from_omniauth'
我的OAuth模擬包含
OmniAuth.config.test_mode = true
OmniAuth.config.mock_auth[:facebook] = {
'uid' => "999999",
'provider' => "facebook",
'extra' => {
'user_hash' => {
'email' => '[email protected]',
'first_name' => 'First',
'last_name' => 'Last',
'gender' => 'Male'
}
},
'credentials' => {
'token' => "token1234qwert"
}
}
它顯然打破了確切地點是
def self.from_omniauth(auth)
where("fb_provider = ? and fb_uid = ?", auth.provider, auth.uid.to_s).first_or_initialize.tap do |user|
但是當我做了puts auth.to_yaml
作爲第一行from_omniauth(auth)
它顯示provider: facebook
以及我在模擬驗證中包含的所有其他內容。我迷失在這一點上。任何建議或幫助,將不勝感激。謝謝。