このメソッドの単体テストを行いたいのですが、コードは次のとおりです。
def self.find_for_facebook_oauth(access_token, sign_in_resource=nil)
data = access_token.extra.raw_info
if !Authentication.where(:uid => access_token['uid']).empty?
authentication = Authentication.find_by_uid(access_token['uid'])
if !authentication.user.nil?
user = authentication.user
return user
else
# in case for some reason the authentication has no user
raise "Something went wrong"
end
else
user = User.new
user.authentications.build(:provider => access_token['provider'], :uid => access_token['uid'], :token => access_token['credentials']['token'])
user.save(:validate=>false)
return user
end
return false
end
どうやってするの?ありがとうございました :)