Skip to content

Commit 443a6b3

Browse files
authored
Bring omniauth-github up-to-date (#61)
* Prefer https Rubygems URL * Bring everything up-to-date * Basic standardization of specs * Bump version to 1.2.0 * Update omniauth to 1.3.2
1 parent 45f2fc7 commit 443a6b3

File tree

4 files changed

+60
-60
lines changed

4 files changed

+60
-60
lines changed

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
source 'http://rubygems.org'
1+
source 'https://rubygems.org'
22

33
# Specify your gem's dependencies in omniauth-github.gemspec
44
gemspec

lib/omniauth-github/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module OmniAuth
22
module GitHub
3-
VERSION = "1.1.2"
3+
VERSION = "1.2.0"
44
end
55
end

omniauth-github.gemspec

+3-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ Gem::Specification.new do |gem|
1616
gem.require_paths = ["lib"]
1717
gem.version = OmniAuth::GitHub::VERSION
1818

19-
gem.add_dependency 'omniauth', '~> 1.0'
20-
# Nothing lower than omniauth-oauth2 1.1.1
21-
# http://www.rubysec.com/advisories/CVE-2012-6134/
22-
gem.add_dependency 'omniauth-oauth2', '>= 1.1.1', '< 2.0'
23-
gem.add_development_dependency 'rspec', '~> 2.7'
19+
gem.add_dependency 'omniauth', '~> 1.3.2'
20+
gem.add_dependency 'omniauth-oauth2', '>= 1.4.0', '< 2.0'
21+
gem.add_development_dependency 'rspec', '~> 3.5'
2422
gem.add_development_dependency 'rack-test'
2523
gem.add_development_dependency 'simplecov'
2624
gem.add_development_dependency 'webmock'
+55-53
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
require 'spec_helper'
22

33
describe OmniAuth::Strategies::GitHub do
4-
let(:access_token) { stub('AccessToken', :options => {}) }
5-
let(:parsed_response) { stub('ParsedResponse') }
6-
let(:response) { stub('Response', :parsed => parsed_response) }
4+
let(:access_token) { instance_double('AccessToken', :options => {}) }
5+
let(:parsed_response) { instance_double('ParsedResponse') }
6+
let(:response) { instance_double('Response', :parsed => parsed_response) }
77

88
let(:enterprise_site) { 'https://some.other.site.com/api/v3' }
99
let(:enterprise_authorize_url) { 'https://some.other.site.com/login/oauth/authorize' }
@@ -25,118 +25,120 @@
2525
end
2626

2727
before(:each) do
28-
subject.stub!(:access_token).and_return(access_token)
28+
allow(subject).to receive(:access_token).and_return(access_token)
2929
end
3030

31-
context "client options" do
31+
context 'client options' do
3232
it 'should have correct site' do
33-
subject.options.client_options.site.should eq("https://api.github.com")
33+
expect(subject.options.client_options.site).to eq('https://api.github.com')
3434
end
3535

3636
it 'should have correct authorize url' do
37-
subject.options.client_options.authorize_url.should eq('https://github.com/login/oauth/authorize')
37+
expect(subject.options.client_options.authorize_url).to eq('https://github.com/login/oauth/authorize')
3838
end
3939

4040
it 'should have correct token url' do
41-
subject.options.client_options.token_url.should eq('https://github.com/login/oauth/access_token')
41+
expect(subject.options.client_options.token_url).to eq('https://github.com/login/oauth/access_token')
4242
end
4343

44-
describe "should be overrideable" do
45-
it "for site" do
46-
enterprise.options.client_options.site.should eq(enterprise_site)
44+
describe 'should be overrideable' do
45+
it 'for site' do
46+
expect(enterprise.options.client_options.site).to eq(enterprise_site)
4747
end
4848

49-
it "for authorize url" do
50-
enterprise.options.client_options.authorize_url.should eq(enterprise_authorize_url)
49+
it 'for authorize url' do
50+
expect(enterprise.options.client_options.authorize_url).to eq(enterprise_authorize_url)
5151
end
5252

53-
it "for token url" do
54-
enterprise.options.client_options.token_url.should eq(enterprise_token_url)
53+
it 'for token url' do
54+
expect(enterprise.options.client_options.token_url).to eq(enterprise_token_url)
5555
end
5656
end
5757
end
5858

59-
context "#email_access_allowed?" do
60-
it "should not allow email if scope is nil" do
61-
subject.options['scope'].should be_nil
62-
subject.should_not be_email_access_allowed
59+
context '#email_access_allowed?' do
60+
it 'should not allow email if scope is nil' do
61+
expect(subject.options['scope']).to be_nil
62+
expect(subject).to_not be_email_access_allowed
6363
end
6464

65-
it "should allow email if scope is user" do
65+
it 'should allow email if scope is user' do
6666
subject.options['scope'] = 'user'
67-
subject.should be_email_access_allowed
67+
expect(subject).to be_email_access_allowed
6868
end
6969

70-
it "should allow email if scope is a bunch of stuff including user" do
70+
it 'should allow email if scope is a bunch of stuff including user' do
7171
subject.options['scope'] = 'public_repo,user,repo,delete_repo,gist'
72-
subject.should be_email_access_allowed
72+
expect(subject).to be_email_access_allowed
7373
end
7474

75-
it "should not allow email if scope does not grant email access" do
75+
it 'should not allow email if scope does not grant email access' do
7676
subject.options['scope'] = 'repo,user:follow'
77-
subject.should_not be_email_access_allowed
77+
expect(subject).to_not be_email_access_allowed
7878
end
7979

80-
it "should assume email access not allowed if scope is something currently not documented " do
80+
it 'should assume email access not allowed if scope is something currently not documented' do
8181
subject.options['scope'] = 'currently_not_documented'
82-
subject.should_not be_email_access_allowed
82+
expect(subject).to_not be_email_access_allowed
8383
end
8484
end
8585

86-
context "#email" do
87-
it "should return email from raw_info if available" do
88-
subject.stub!(:raw_info).and_return({'email' => '[email protected]'})
89-
subject.email.should eq('[email protected]')
86+
context '#email' do
87+
it 'should return email from raw_info if available' do
88+
allow(subject).to receive(:raw_info).and_return({ 'email' => '[email protected]' })
89+
expect(subject.email).to eq('[email protected]')
9090
end
9191

92-
it "should return nil if there is no raw_info and email access is not allowed" do
93-
subject.stub!(:raw_info).and_return({})
94-
subject.email.should be_nil
92+
it 'should return nil if there is no raw_info and email access is not allowed' do
93+
allow(subject).to receive(:raw_info).and_return({})
94+
expect(subject.email).to be_nil
9595
end
9696

97-
it "should not return the primary email if there is no raw_info and email access is allowed" do
97+
it 'should not return the primary email if there is no raw_info and email access is allowed' do
9898
emails = [
9999
{ 'email' => '[email protected]', 'primary' => false },
100100
{ 'email' => '[email protected]', 'primary' => true }
101101
]
102-
subject.stub!(:raw_info).and_return({})
102+
allow(subject).to receive(:raw_info).and_return({})
103103
subject.options['scope'] = 'user'
104-
subject.stub!(:emails).and_return(emails)
105-
subject.email.should eq(nil)
104+
allow(subject).to receive(:emails).and_return(emails)
105+
expect(subject.email).to be_nil
106106
end
107107

108-
it "should not return the first email if there is no raw_info and email access is allowed" do
108+
it 'should not return the first email if there is no raw_info and email access is allowed' do
109109
emails = [
110110
{ 'email' => '[email protected]', 'primary' => false },
111111
{ 'email' => '[email protected]', 'primary' => false }
112112
]
113-
subject.stub!(:raw_info).and_return({})
113+
allow(subject).to receive(:raw_info).and_return({})
114114
subject.options['scope'] = 'user'
115-
subject.stub!(:emails).and_return(emails)
116-
subject.email.should eq(nil)
115+
allow(subject).to receive(:emails).and_return(emails)
116+
expect(subject.email).to be_nil
117117
end
118118
end
119119

120-
context "#raw_info" do
121-
it "should use relative paths" do
122-
access_token.should_receive(:get).with('user').and_return(response)
123-
subject.raw_info.should eq(parsed_response)
120+
context '#raw_info' do
121+
it 'should use relative paths' do
122+
expect(access_token).to receive(:get).with('user').and_return(response)
123+
expect(subject.raw_info).to eq(parsed_response)
124124
end
125125
end
126126

127-
context "#emails" do
128-
it "should use relative paths" do
129-
access_token.should_receive(:get).with('user/emails', :headers=>{"Accept"=>"application/vnd.github.v3"}).and_return(response)
127+
context '#emails' do
128+
it 'should use relative paths' do
129+
expect(access_token).to receive(:get).with('user/emails', :headers => {
130+
'Accept' => 'application/vnd.github.v3'
131+
}).and_return(response)
132+
130133
subject.options['scope'] = 'user'
131-
subject.emails.should eq(parsed_response)
134+
expect(subject.emails).to eq(parsed_response)
132135
end
133136
end
134137

135138
context '#info.urls' do
136139
it 'should use html_url from raw_info' do
137-
subject.stub(:raw_info).and_return({ 'login' => 'me', 'html_url' => 'http://enterprise/me' })
138-
subject.info['urls']['GitHub'].should == 'http://enterprise/me'
140+
allow(subject).to receive(:raw_info).and_return({ 'login' => 'me', 'html_url' => 'http://enterprise/me' })
141+
expect(subject.info['urls']['GitHub']).to eq('http://enterprise/me')
139142
end
140143
end
141-
142144
end

0 commit comments

Comments
 (0)