Skip to content
Browse files

spec test

  • Loading branch information...
1 parent eabe40b commit dfd4b756ce97a5920a07475251042db4adc66eb3 @judearasu committed
Showing with 44 additions and 3 deletions.
  1. +3 −0 example/config.ru
  2. +18 −3 lib/omniauth/strategies/miso.rb
  3. +23 −0 spec/omniauth/strategies/miso_spec.rb
View
3 example/config.ru
@@ -24,6 +24,9 @@ class App < Sinatra::Base
get '/auth/miso/callback' do
puts "THE RESULT HASH: #{request.env['omniauth.auth']}"
+ <<-HTML
+ #{:nickname}
+ HTML
end
get '/auth/failure' do
View
21 lib/omniauth/strategies/miso.rb
@@ -5,16 +5,31 @@ module OmniAuth
module Strategies
class Miso < OmniAuth::Strategies::OAuth
option :name, "miso"
- option :client_options,{:site=>'https://gomiso.com/',
- :authorize_url => '/oauth/authorize',
+ option :client_options,{:site=>'http://gomiso.com',
+ :authorize_url => 'http://gomiso.com/oauth/authorize',
+ :token_url =>'https://gomiso.com/oauth/access_token'
}
uid { access_token.params[:user_id] }
+ info do
+ {
+ :id => raw_info['id'],
+ :nickname => raw_info['nickname'],
+ :name => raw_info['name'],
+ :username => raw_info['username'],
+ :full_name => raw_info['full_name'],
+ :profile_image_url => raw_info['profile_image_url'],
+ :image => raw_info['image'],
+ :description => raw_info['description'],
+ :location=>raw_info['location'],
+ :urls =>{ 'Website' => raw_info['url']}
+ }
+ end
extra do
{ :raw_info => raw_info }
end
-
+
def raw_info
@raw_info ||= MultiJson.decode(@access_token.get('/api/oauth/v1/users/show.json').body)['user']
rescue ::Errno::ETIMEDOUT
View
23 spec/omniauth/strategies/miso_spec.rb
@@ -33,4 +33,27 @@
subject.options.client_options[:authorize_url].should eq('/oauth/authorize')
end
end
+ describe '#info' do
+ before :each do
+ @raw_info = {
+ :id => '362474',
+ :nickname => '',
+ :name => '',
+ :username => 'judearasu',
+ :full_name => 'Jude Arasu',
+ :profile_image_url => 'http://gomiso.com/uploads/BAhbCFsHOgZmIiEyMDEyLzA3LzA3LzA1LzQxLzI5Lzc0OC9maWxlWwc6BmU6CHBuZ1sIOgZwOgp0aHVtYiILODB4ODAj.png',
+ :image => '',
+ :description => '',
+ :location=>'',
+ :urls =>{ 'Website' => 'http://judearasu.github.com'},
+ :provider =>'miso'
+ }
+ subject.stub(:raw_info) { @raw_info }
+ end
+ context 'when data is present in raw info' do
+ it 'returns the name' do
+ subject.info[:name].should be_nil
+ end
+ end
+ end
end

0 comments on commit dfd4b75

Please sign in to comment.
Something went wrong with that request. Please try again.