diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..23112f3 --- /dev/null +++ b/.rspec @@ -0,0 +1,2 @@ +--colour +--format=progress diff --git a/Rakefile b/Rakefile index f57ae68..d2dc1d6 100644 --- a/Rakefile +++ b/Rakefile @@ -1,2 +1,9 @@ #!/usr/bin/env rake require "bundler/gem_tasks" +require 'rspec/core/rake_task' + +desc 'Default: run specs.' +task :default => :spec + +desc "Run specs" +RSpec::Core::RakeTask.new diff --git a/lib/omniauth/strategies/oauth2.rb b/lib/omniauth/strategies/oauth2.rb index 6a003cb..13df166 100644 --- a/lib/omniauth/strategies/oauth2.rb +++ b/lib/omniauth/strategies/oauth2.rb @@ -22,7 +22,7 @@ class OAuth2 attr_accessor :access_token def client - ::OAuth2::Client.new(options.client_id, options.client_secret, options.client_options) + ::OAuth2::Client.new(options.client_id, options.client_secret, options.client_options.inject({}){|h,(k,v)| h[k.to_sym] = v; h}) end def callback_url @@ -36,7 +36,7 @@ def callback_url end def request_phase - redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(options)) + redirect client.auth_code.authorize_url({:redirect_uri => callback_url}.merge(options.authorize_params)) end def callback_phase diff --git a/spec/omniauth/strategies/oauth2_spec.rb b/spec/omniauth/strategies/oauth2_spec.rb new file mode 100644 index 0000000..e8b1fae --- /dev/null +++ b/spec/omniauth/strategies/oauth2_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe OmniAuth::Strategies::OAuth2 do + def app; lambda{|env| [200, {}, ["Hello."]]} end + let(:fresh_strategy){ Class.new(OmniAuth::Strategies::OAuth2) } + + describe '#client' do + subject{ fresh_strategy } + + it 'should be initialized with symbolized client_options' do + instance = subject.new(app, :client_options => {'authorize_url' => 'https://example.com'}) + instance.client.options[:authorize_url].should == 'https://example.com' + end + end +end