Skip to content

Commit d1773cf

Browse files
committed
Prefer double-quoted strings
1 parent 9f41c88 commit d1773cf

File tree

8 files changed

+139
-93
lines changed

8 files changed

+139
-93
lines changed

.rubocop.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Metrics/BlockNesting:
2+
Max: 2
3+
4+
Metrics/LineLength:
5+
AllowURI: true
6+
Enabled: false
7+
8+
Metrics/MethodLength:
9+
CountComments: false
10+
Max: 10
11+
12+
Metrics/ParameterLists:
13+
Max: 4
14+
CountKeywordArgs: true
15+
16+
Style/AccessModifierIndentation:
17+
EnforcedStyle: outdent
18+
19+
Style/CollectionMethods:
20+
PreferredMethods:
21+
map: 'collect'
22+
reduce: 'inject'
23+
find: 'detect'
24+
find_all: 'select'
25+
26+
Style/Documentation:
27+
Enabled: false
28+
29+
DotPosition:
30+
EnforcedStyle: trailing
31+
32+
Style/DoubleNegation:
33+
Enabled: false
34+
35+
Style/HashSyntax:
36+
EnforcedStyle: hash_rockets
37+
38+
Style/SpaceInsideHashLiteralBraces:
39+
EnforcedStyle: no_space
40+
41+
Style/StringLiterals:
42+
EnforcedStyle: double_quotes
43+
44+
Style/TrailingComma:
45+
EnforcedStyleForMultiline: 'comma'

Gemfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
source 'http://rubygems.org'
1+
source "http://rubygems.org"
22

33
gemspec
44

5+
gem "rake"
6+
57
group :test do
6-
gem 'rack-test'
7-
gem 'rake'
8-
gem 'rspec', '~> 3.2'
9-
gem 'simplecov'
10-
gem 'webmock'
8+
gem "rack-test"
9+
gem "rspec", "~> 3.2"
10+
gem "simplecov"
11+
gem "webmock"
1112
end

Rakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env rake
22
require "bundler/gem_tasks"
3-
require 'rspec/core/rake_task'
3+
require "rspec/core/rake_task"
44

5-
desc 'Default: run specs.'
5+
desc "Default: run specs."
66
task :default => :spec
77

88
desc "Run specs"

lib/omniauth-oauth.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
require "omniauth-oauth/version"
2-
require 'omniauth/strategies/oauth'
2+
require "omniauth/strategies/oauth"
33

lib/omniauth/strategies/oauth.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
require 'oauth'
2-
require 'omniauth'
1+
require "oauth"
2+
require "omniauth"
33

44
module OmniAuth
55
module Strategies
@@ -26,8 +26,8 @@ def consumer
2626

2727
def request_phase
2828
request_token = consumer.get_request_token({:oauth_callback => callback_url}, options.request_params)
29-
session['oauth'] ||= {}
30-
session['oauth'][name.to_s] = {'callback_confirmed' => request_token.callback_confirmed?, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
29+
session["oauth"] ||= {}
30+
session["oauth"][name.to_s] = {"callback_confirmed" => request_token.callback_confirmed?, "request_token" => request_token.token, "request_secret" => request_token.secret}
3131

3232
if request_token.callback_confirmed?
3333
redirect request_token.authorize_url(options[:authorize_params])
@@ -42,13 +42,13 @@ def request_phase
4242
end
4343

4444
def callback_phase
45-
raise OmniAuth::NoSessionError.new("Session Expired") if session['oauth'].nil?
45+
raise OmniAuth::NoSessionError.new("Session Expired") if session["oauth"].nil?
4646

47-
request_token = ::OAuth::RequestToken.new(consumer, session['oauth'][name.to_s].delete('request_token'), session['oauth'][name.to_s].delete('request_secret'))
47+
request_token = ::OAuth::RequestToken.new(consumer, session["oauth"][name.to_s].delete("request_token"), session["oauth"][name.to_s].delete("request_secret"))
4848

4949
opts = {}
50-
if session['oauth'][name.to_s]['callback_confirmed']
51-
opts[:oauth_verifier] = request['oauth_verifier']
50+
if session["oauth"][name.to_s]["callback_confirmed"]
51+
opts[:oauth_verifier] = request["oauth_verifier"]
5252
else
5353
opts[:oauth_callback] = callback_url
5454
end
@@ -66,14 +66,14 @@ def callback_phase
6666
end
6767

6868
credentials do
69-
{'token' => access_token.token, 'secret' => access_token.secret}
69+
{"token" => access_token.token, "secret" => access_token.secret}
7070
end
7171

7272
extra do
73-
{'access_token' => access_token}
73+
{"access_token" => access_token}
7474
end
7575
end
7676
end
7777
end
7878

79-
OmniAuth.config.add_camelization 'oauth', 'OAuth'
79+
OmniAuth.config.add_camelization "oauth", "OAuth"

omniauth-oauth.gemspec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- encoding: utf-8 -*-
2-
require File.expand_path('../lib/omniauth-oauth/version', __FILE__)
2+
require File.expand_path("../lib/omniauth-oauth/version", __FILE__)
33

44
Gem::Specification.new do |gem|
55
gem.authors = ["Michael Bleigh"]
@@ -9,15 +9,15 @@ Gem::Specification.new do |gem|
99
gem.homepage = "https://github.com/intridea/omniauth-oauth"
1010
gem.license = "MIT"
1111

12-
gem.add_dependency 'omniauth', '~> 1.0'
13-
gem.add_dependency 'oauth'
14-
gem.add_development_dependency 'bundler', '~> 1.9'
12+
gem.add_dependency "omniauth", "~> 1.0"
13+
gem.add_dependency "oauth"
14+
gem.add_development_dependency "bundler", "~> 1.9"
1515

1616
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
1717
gem.files = `git ls-files`.split("\n")
1818
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
1919
gem.name = "omniauth-oauth"
2020
gem.require_paths = ["lib"]
2121
gem.version = OmniAuth::OAuth::VERSION
22-
gem.license = 'MIT'
22+
gem.license = "MIT"
2323
end
Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,147 +1,147 @@
1-
require 'spec_helper'
1+
require "spec_helper"
22

33
describe "OmniAuth::Strategies::OAuth" do
44
class MyOAuthProvider < OmniAuth::Strategies::OAuth
55
uid{ access_token.token }
6-
info{ {'name' => access_token.token} }
6+
info{ {"name" => access_token.token} }
77
end
88

99
def app
1010
Rack::Builder.new {
1111
use OmniAuth::Test::PhonySession
1212
use OmniAuth::Builder do
13-
provider MyOAuthProvider, 'abc', 'def', :client_options => {:site => 'https://api.example.org'}, :name => 'example.org'
14-
provider MyOAuthProvider, 'abc', 'def', :client_options => {:site => 'https://api.example.org'}, :authorize_params => {:abc => 'def'}, :name => 'example.org_with_authorize_params'
15-
provider MyOAuthProvider, 'abc', 'def', :client_options => {:site => 'https://api.example.org'}, :request_params => {:scope => 'http://foobar.example.org'}, :name => 'example.org_with_request_params'
13+
provider MyOAuthProvider, "abc", "def", :client_options => {:site => "https://api.example.org"}, :name => "example.org"
14+
provider MyOAuthProvider, "abc", "def", :client_options => {:site => "https://api.example.org"}, :authorize_params => {:abc => "def"}, :name => "example.org_with_authorize_params"
15+
provider MyOAuthProvider, "abc", "def", :client_options => {:site => "https://api.example.org"}, :request_params => {:scope => "http://foobar.example.org"}, :name => "example.org_with_request_params"
1616
end
17-
run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] }
17+
run lambda { |env| [404, {"Content-Type" => "text/plain"}, [env.key?("omniauth.auth").to_s]] }
1818
}.to_app
1919
end
2020

2121
def session
22-
last_request.env['rack.session']
22+
last_request.env["rack.session"]
2323
end
2424

2525
before do
26-
stub_request(:post, 'https://api.example.org/oauth/request_token').
26+
stub_request(:post, "https://api.example.org/oauth/request_token").
2727
to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret&oauth_callback_confirmed=true")
2828
end
2929

30-
it 'should add a camelization for itself' do
31-
expect(OmniAuth::Utils.camelize('oauth')).to eq('OAuth')
30+
it "should add a camelization for itself" do
31+
expect(OmniAuth::Utils.camelize("oauth")).to eq("OAuth")
3232
end
3333

34-
describe '/auth/{name}' do
35-
context 'successful' do
34+
describe "/auth/{name}" do
35+
context "successful" do
3636
before do
37-
get '/auth/example.org'
37+
get "/auth/example.org"
3838
end
3939

40-
it 'should redirect to authorize_url' do
40+
it "should redirect to authorize_url" do
4141
expect(last_response).to be_redirect
42-
expect(last_response.headers['Location']).to eq('https://api.example.org/oauth/authorize?oauth_token=yourtoken')
42+
expect(last_response.headers["Location"]).to eq("https://api.example.org/oauth/authorize?oauth_token=yourtoken")
4343
end
4444

45-
it 'should redirect to authorize_url with authorize_params when set' do
46-
get '/auth/example.org_with_authorize_params'
45+
it "should redirect to authorize_url with authorize_params when set" do
46+
get "/auth/example.org_with_authorize_params"
4747
expect(last_response).to be_redirect
4848
expect([
49-
'https://api.example.org/oauth/authorize?abc=def&oauth_token=yourtoken',
50-
'https://api.example.org/oauth/authorize?oauth_token=yourtoken&abc=def'
51-
]).to be_include(last_response.headers['Location'])
49+
"https://api.example.org/oauth/authorize?abc=def&oauth_token=yourtoken",
50+
"https://api.example.org/oauth/authorize?oauth_token=yourtoken&abc=def"
51+
]).to be_include(last_response.headers["Location"])
5252
end
5353

54-
it 'should set appropriate session variables' do
55-
expect(session['oauth']).to eq({"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}})
54+
it "should set appropriate session variables" do
55+
expect(session["oauth"]).to eq({"example.org" => {"callback_confirmed" => true, "request_token" => "yourtoken", "request_secret" => "yoursecret"}})
5656
end
5757

58-
it 'should pass request_params to get_request_token' do
59-
get '/auth/example.org_with_request_params'
60-
expect(WebMock).to have_requested(:post, 'https://api.example.org/oauth/request_token').
58+
it "should pass request_params to get_request_token" do
59+
get "/auth/example.org_with_request_params"
60+
expect(WebMock).to have_requested(:post, "https://api.example.org/oauth/request_token").
6161
with {|req| req.body == "scope=http%3A%2F%2Ffoobar.example.org" }
6262
end
6363
end
6464

65-
context 'unsuccessful' do
65+
context "unsuccessful" do
6666
before do
67-
stub_request(:post, 'https://api.example.org/oauth/request_token').
67+
stub_request(:post, "https://api.example.org/oauth/request_token").
6868
to_raise(::Net::HTTPFatalError.new(%Q{502 "Bad Gateway"}, nil))
69-
get '/auth/example.org'
69+
get "/auth/example.org"
7070
end
7171

72-
it 'should call fail! with :service_unavailable' do
73-
expect(last_request.env['omniauth.error']).to be_kind_of(::Net::HTTPFatalError)
74-
last_request.env['omniauth.error.type'] = :service_unavailable
72+
it "should call fail! with :service_unavailable" do
73+
expect(last_request.env["omniauth.error"]).to be_kind_of(::Net::HTTPFatalError)
74+
last_request.env["omniauth.error.type"] = :service_unavailable
7575
end
7676

7777
context "SSL failure" do
7878
before do
79-
stub_request(:post, 'https://api.example.org/oauth/request_token').
79+
stub_request(:post, "https://api.example.org/oauth/request_token").
8080
to_raise(::OpenSSL::SSL::SSLError.new("SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed"))
81-
get '/auth/example.org'
81+
get "/auth/example.org"
8282
end
8383

84-
it 'should call fail! with :service_unavailable' do
85-
expect(last_request.env['omniauth.error']).to be_kind_of(::OpenSSL::SSL::SSLError)
86-
last_request.env['omniauth.error.type'] = :service_unavailable
84+
it "should call fail! with :service_unavailable" do
85+
expect(last_request.env["omniauth.error"]).to be_kind_of(::OpenSSL::SSL::SSLError)
86+
last_request.env["omniauth.error.type"] = :service_unavailable
8787
end
8888
end
8989
end
9090
end
9191

92-
describe '/auth/{name}/callback' do
92+
describe "/auth/{name}/callback" do
9393
before do
94-
stub_request(:post, 'https://api.example.org/oauth/access_token').
94+
stub_request(:post, "https://api.example.org/oauth/access_token").
9595
to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret")
96-
get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {'oauth' => {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}}}
96+
get "/auth/example.org/callback", {:oauth_verifier => "dudeman"}, {"rack.session" => {"oauth" => {"example.org" => {"callback_confirmed" => true, "request_token" => "yourtoken", "request_secret" => "yoursecret"}}}}
9797
end
9898

99-
it 'should exchange the request token for an access token' do
100-
expect(last_request.env['omniauth.auth']['provider']).to eq('example.org')
101-
expect(last_request.env['omniauth.auth']['extra']['access_token']).to be_kind_of(OAuth::AccessToken)
99+
it "should exchange the request token for an access token" do
100+
expect(last_request.env["omniauth.auth"]["provider"]).to eq("example.org")
101+
expect(last_request.env["omniauth.auth"]["extra"]["access_token"]).to be_kind_of(OAuth::AccessToken)
102102
end
103103

104-
it 'should call through to the master app' do
105-
expect(last_response.body).to eq('true')
104+
it "should call through to the master app" do
105+
expect(last_response.body).to eq("true")
106106
end
107107

108108
context "bad gateway (or any 5xx) for access_token" do
109109
before do
110-
stub_request(:post, 'https://api.example.org/oauth/access_token').
110+
stub_request(:post, "https://api.example.org/oauth/access_token").
111111
to_raise(::Net::HTTPFatalError.new(%Q{502 "Bad Gateway"}, nil))
112-
get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {'oauth' => {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}}}
112+
get "/auth/example.org/callback", {:oauth_verifier => "dudeman"}, {"rack.session" => {"oauth" => {"example.org" => {"callback_confirmed" => true, "request_token" => "yourtoken", "request_secret" => "yoursecret"}}}}
113113
end
114114

115-
it 'should call fail! with :service_unavailable' do
116-
expect(last_request.env['omniauth.error']).to be_kind_of(::Net::HTTPFatalError)
117-
last_request.env['omniauth.error.type'] = :service_unavailable
115+
it "should call fail! with :service_unavailable" do
116+
expect(last_request.env["omniauth.error"]).to be_kind_of(::Net::HTTPFatalError)
117+
last_request.env["omniauth.error.type"] = :service_unavailable
118118
end
119119
end
120120

121121
context "SSL failure" do
122122
before do
123-
stub_request(:post, 'https://api.example.org/oauth/access_token').
123+
stub_request(:post, "https://api.example.org/oauth/access_token").
124124
to_raise(::OpenSSL::SSL::SSLError.new("SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed"))
125-
get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {'oauth' => {"example.org" => {'callback_confirmed' => true, 'request_token' => 'yourtoken', 'request_secret' => 'yoursecret'}}}}
125+
get "/auth/example.org/callback", {:oauth_verifier => "dudeman"}, {"rack.session" => {"oauth" => {"example.org" => {"callback_confirmed" => true, "request_token" => "yourtoken", "request_secret" => "yoursecret"}}}}
126126
end
127127

128-
it 'should call fail! with :service_unavailable' do
129-
expect(last_request.env['omniauth.error']).to be_kind_of(::OpenSSL::SSL::SSLError)
130-
last_request.env['omniauth.error.type'] = :service_unavailable
128+
it "should call fail! with :service_unavailable" do
129+
expect(last_request.env["omniauth.error"]).to be_kind_of(::OpenSSL::SSL::SSLError)
130+
last_request.env["omniauth.error.type"] = :service_unavailable
131131
end
132132
end
133133
end
134134

135-
describe '/auth/{name}/callback with expired session' do
135+
describe "/auth/{name}/callback with expired session" do
136136
before do
137-
stub_request(:post, 'https://api.example.org/oauth/access_token').
137+
stub_request(:post, "https://api.example.org/oauth/access_token").
138138
to_return(:body => "oauth_token=yourtoken&oauth_token_secret=yoursecret")
139-
get '/auth/example.org/callback', {:oauth_verifier => 'dudeman'}, {'rack.session' => {}}
139+
get "/auth/example.org/callback", {:oauth_verifier => "dudeman"}, {"rack.session" => {}}
140140
end
141141

142-
it 'should call fail! with :session_expired' do
143-
expect(last_request.env['omniauth.error']).to be_kind_of(::OmniAuth::NoSessionError)
144-
last_request.env['omniauth.error.type'] = :session_expired
142+
it "should call fail! with :session_expired" do
143+
expect(last_request.env["omniauth.error"]).to be_kind_of(::OmniAuth::NoSessionError)
144+
last_request.env["omniauth.error.type"] = :session_expired
145145
end
146146
end
147147
end

spec/spec_helper.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
$:.unshift File.expand_path('..', __FILE__)
2-
$:.unshift File.expand_path('../../lib', __FILE__)
3-
require 'simplecov'
1+
$:.unshift File.expand_path("..", __FILE__)
2+
$:.unshift File.expand_path("../../lib", __FILE__)
3+
require "simplecov"
44
SimpleCov.start do
55
minimum_coverage(89.8)
66
end
7-
require 'rspec'
8-
require 'rack/test'
9-
require 'webmock/rspec'
10-
require 'omniauth'
11-
require 'omniauth-oauth'
7+
require "rspec"
8+
require "rack/test"
9+
require "webmock/rspec"
10+
require "omniauth"
11+
require "omniauth-oauth"
1212

1313
RSpec.configure do |config|
1414
config.include WebMock::API

0 commit comments

Comments
 (0)