spec/omniauth/strategies/twitter_spec.rb in omniauth-twitter-1.0.1 vs spec/omniauth/strategies/twitter_spec.rb in omniauth-twitter-1.1.0
- old
+ new
@@ -4,11 +4,11 @@
let(:request) { double('Request', :params => {}, :cookies => {}, :env => {}) }
subject do
args = ['appid', 'secret', @options || {}].compact
OmniAuth::Strategies::Twitter.new(*args).tap do |strategy|
- strategy.stub(:request) {
+ allow(strategy).to receive(:request) {
request
}
end
end
@@ -28,43 +28,57 @@
describe 'image_size option' do
context 'when user has an image' do
it 'should return image with size specified' do
@options = { :image_size => 'original' }
- subject.stub(:raw_info).and_return(
+ allow(subject).to receive(:raw_info).and_return(
{ 'profile_image_url' => 'http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_normal.png' }
)
expect(subject.info[:image]).to eq('http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0.png')
end
it 'should return secure image with size specified' do
@options = { :secure_image_url => 'true', :image_size => 'mini' }
- subject.stub(:raw_info).and_return(
+ allow(subject).to receive(:raw_info).and_return(
{ 'profile_image_url_https' => 'https://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_normal.png' }
)
expect(subject.info[:image]).to eq('https://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_mini.png')
end
it 'should return normal image by default' do
- subject.stub(:raw_info).and_return(
+ allow(subject).to receive(:raw_info).and_return(
{ 'profile_image_url' => 'http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_normal.png' }
)
expect(subject.info[:image]).to eq('http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_normal.png')
end
end
end
describe 'request_phase' do
context 'with no request params set and x_auth_access_type specified' do
before do
- subject.stub(:request).and_return(
+ allow(subject).to receive(:request).and_return(
double('Request', {:params => {'x_auth_access_type' => 'read'}})
)
- subject.stub(:old_request_phase).and_return(:whatever)
+ allow(subject).to receive(:old_request_phase).and_return(:whatever)
end
it 'should not break' do
expect { subject.request_phase }.not_to raise_error
+ end
+ end
+
+ context "with no request params set and use_authorize options provided" do
+ before do
+ @options = { :use_authorize => true }
+ subject.stub(:request).and_return(
+ double('Request', {:params => {}})
+ )
+ subject.stub(:old_request_phase).and_return(:whatever)
+ end
+
+ it "should switch authorize_path from authenticate to authorize" do
+ expect { subject.request_phase }.to change { subject.options.client_options.authorize_path }.from('/oauth/authenticate').to('/oauth/authorize')
end
end
end
end