Permalink
Browse files

Refactor spec.

We should stub the request and not the session (which is set after the
request by omniauth)
https://github.com/intridea/omniauth/blob/deea8f23642734217fc8a91cfe9a09a69595d638/lib/omniauth/strategy.rb#L200

It also doesn't make sense to set options[:request_params] to nil when
omniauth-oauth is already initializing it as an empty hash
https://github.com/intridea/omniauth-oauth/blob/43008e42b257d9b7c0b98122cf03ce14b021d782/lib/omniauth/strategies/oauth.rb#L16
  • Loading branch information...
1 parent 3f8a930 commit 991a8017250cbe0cfeeca010d82a2562197c7b6c @guilhermesimoes guilhermesimoes committed Aug 5, 2013
Showing with 10 additions and 4 deletions.
  1. +10 −4 spec/omniauth/strategies/twitter_spec.rb
@@ -1,9 +1,15 @@
require 'spec_helper'
describe OmniAuth::Strategies::Twitter do
+ let(:request) { double('Request', :params => {}, :cookies => {}, :env => {}) }
+
subject do
args = ['appid', 'secret', @options || {}].compact
- OmniAuth::Strategies::Twitter.new(*args)
+ OmniAuth::Strategies::Twitter.new(*args).tap do |strategy|
+ strategy.stub(:request) {
+ request
+ }
+ end
end
describe 'client options' do
@@ -50,9 +56,9 @@
describe 'request_phase' do
context 'with no request params set and x_auth_access_type specified' do
before do
- subject.options[:request_params] = nil
- subject.stub(:session).and_return(
- {'omniauth.params' => {'x_auth_access_type' => 'read'}})
+ subject.stub(:request).and_return(
+ double('Request', {:params => {'x_auth_access_type' => 'read'}})
+ )
subject.stub(:old_request_phase).and_return(:whatever)
end

0 comments on commit 991a801

Please sign in to comment.