mirror of
https://github.com/omniauth/omniauth.git
synced 2022-11-09 12:31:49 -05:00
Fix Rubocop Offenses
This commit is contained in:
parent
867165ab23
commit
c4fc115f3b
9 changed files with 29 additions and 28 deletions
8
Gemfile
8
Gemfile
|
@ -14,14 +14,14 @@ end
|
|||
group :test do
|
||||
gem 'coveralls', :require => false
|
||||
gem 'hashie', '>= 3.4.6', '< 3.6.0', :platforms => [:jruby_18]
|
||||
gem 'json', '~> 2.0.3', :platforms => [:jruby_18, :jruby_19, :ruby_19]
|
||||
gem 'json', '~> 2.0.3', :platforms => %i[jruby_18 jruby_19 ruby_19]
|
||||
gem 'mime-types', '~> 3.1', :platforms => [:jruby_18]
|
||||
gem 'rack', '>= 1.6.2', :platforms => [:jruby_18, :jruby_19, :ruby_19, :ruby_20, :ruby_21]
|
||||
gem 'rack', '>= 1.6.2', :platforms => %i[jruby_18 jruby_19 ruby_19 ruby_20 ruby_21]
|
||||
gem 'rack-test'
|
||||
gem 'rest-client', '~> 2.0.0', :platforms => [:jruby_18]
|
||||
gem 'rspec', '~> 3.5.0'
|
||||
gem 'rubocop', '>= 0.47', :platforms => [:ruby_20, :ruby_21, :ruby_22, :ruby_23, :ruby_24]
|
||||
gem 'tins', '~> 1.13.0', :platforms => [:jruby_18, :jruby_19, :ruby_19]
|
||||
gem 'rubocop', '>= 0.47', :platforms => %i[ruby_20 ruby_21 ruby_22 ruby_23 ruby_24]
|
||||
gem 'tins', '~> 1.13.0', :platforms => %i[jruby_18 jruby_19 ruby_19]
|
||||
end
|
||||
|
||||
gemspec
|
||||
|
|
2
Rakefile
2
Rakefile
|
@ -14,7 +14,7 @@ rescue LoadError
|
|||
end
|
||||
end
|
||||
|
||||
task :default => [:spec, :rubocop]
|
||||
task :default => %i[spec rubocop]
|
||||
|
||||
namespace :perf do
|
||||
task :setup do
|
||||
|
|
|
@ -41,7 +41,7 @@ module OmniAuth
|
|||
:form_css => Form::DEFAULT_CSS,
|
||||
:test_mode => false,
|
||||
:logger => default_logger,
|
||||
:allowed_request_methods => [:get, :post],
|
||||
:allowed_request_methods => %i[get post],
|
||||
:mock_auth => {:default => AuthHash.new('provider' => 'default', 'uid' => '1234', 'info' => {'name' => 'Example User'})}
|
||||
}
|
||||
end
|
||||
|
@ -141,7 +141,7 @@ module OmniAuth
|
|||
def deep_merge(hash, other_hash)
|
||||
target = hash.dup
|
||||
|
||||
other_hash.keys.each do |key|
|
||||
other_hash.each_key do |key|
|
||||
if other_hash[key].is_a?(::Hash) && hash[key].is_a?(::Hash)
|
||||
target[key] = deep_merge(target[key], other_hash[key])
|
||||
next
|
||||
|
|
|
@ -31,7 +31,7 @@ module OmniAuth
|
|||
class Developer
|
||||
include OmniAuth::Strategy
|
||||
|
||||
option :fields, [:name, :email]
|
||||
option :fields, %i[name email]
|
||||
option :uid_field, :email
|
||||
|
||||
def request_phase
|
||||
|
|
|
@ -88,7 +88,7 @@ module OmniAuth
|
|||
(instance_variable_defined?(:@args) && @args) || existing
|
||||
end
|
||||
|
||||
%w(uid info extra credentials).each do |fetcher|
|
||||
%w[uid info extra credentials].each do |fetcher|
|
||||
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
||||
attr_reader :#{fetcher}_proc
|
||||
private :#{fetcher}_proc
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# coding: utf-8
|
||||
|
||||
lib = File.expand_path('../lib', __FILE__)
|
||||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
||||
require 'omniauth/version'
|
||||
|
@ -13,9 +14,9 @@ Gem::Specification.new do |spec|
|
|||
spec.email = ['michael@intridea.com', 'sferik@gmail.com', 'tmilewski@gmail.com']
|
||||
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.start_with?('spec/') }
|
||||
spec.homepage = 'https://github.com/omniauth/omniauth'
|
||||
spec.licenses = %w(MIT)
|
||||
spec.licenses = %w[MIT]
|
||||
spec.name = 'omniauth'
|
||||
spec.require_paths = %w(lib)
|
||||
spec.require_paths = %w[lib]
|
||||
spec.required_rubygems_version = '>= 1.3.5'
|
||||
spec.required_ruby_version = '>= 2.1.9'
|
||||
spec.summary = spec.description
|
||||
|
|
|
@ -64,13 +64,13 @@ describe OmniAuth::AuthHash do
|
|||
|
||||
it 'displays the nickname if no name, first, or last is available' do
|
||||
subject.info.name = nil
|
||||
%w(first_name last_name).each { |k| subject.info[k] = nil }
|
||||
%w[first_name last_name].each { |k| subject.info[k] = nil }
|
||||
expect(subject.info.name).to eq('meatbag')
|
||||
end
|
||||
|
||||
it 'displays the email if no name, first, last, or nick is available' do
|
||||
subject.info.name = nil
|
||||
%w(first_name last_name nickname).each { |k| subject.info[k] = nil }
|
||||
%w[first_name last_name nickname].each { |k| subject.info[k] = nil }
|
||||
expect(subject.info.name).to eq('fry@planetexpress.com')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -51,13 +51,13 @@ describe OmniAuth::Strategies::Developer do
|
|||
let(:app) do
|
||||
Rack::Builder.new do |b|
|
||||
b.use Rack::Session::Cookie, :secret => 'abc123'
|
||||
b.use OmniAuth::Strategies::Developer, :fields => [:first_name, :last_name], :uid_field => :last_name
|
||||
b.use OmniAuth::Strategies::Developer, :fields => %i[first_name last_name], :uid_field => :last_name
|
||||
b.run lambda { |_env| [200, {}, ['Not Found']] }
|
||||
end.to_app
|
||||
end
|
||||
|
||||
before do
|
||||
@options = {:uid_field => :last_name, :fields => [:first_name, :last_name]}
|
||||
@options = {:uid_field => :last_name, :fields => %i[first_name last_name]}
|
||||
post '/auth/developer/callback', :first_name => 'Example', :last_name => 'User'
|
||||
end
|
||||
|
||||
|
|
|
@ -106,18 +106,18 @@ describe OmniAuth::Strategy do
|
|||
end
|
||||
|
||||
it 'sets args to the specified argument if there is one' do
|
||||
subject.args [:abc, :def]
|
||||
expect(subject.args).to eq([:abc, :def])
|
||||
subject.args %i[abc def]
|
||||
expect(subject.args).to eq(%i[abc def])
|
||||
end
|
||||
|
||||
it 'is inheritable' do
|
||||
subject.args [:abc, :def]
|
||||
subject.args %i[abc def]
|
||||
c = Class.new(subject)
|
||||
expect(c.args).to eq([:abc, :def])
|
||||
expect(c.args).to eq(%i[abc def])
|
||||
end
|
||||
|
||||
it 'accepts corresponding options as default arg values' do
|
||||
subject.args [:a, :b]
|
||||
subject.args %i[a b]
|
||||
subject.option :a, '1'
|
||||
subject.option :b, '2'
|
||||
|
||||
|
@ -130,7 +130,7 @@ describe OmniAuth::Strategy do
|
|||
|
||||
context 'fetcher procs' do
|
||||
subject { fresh_strategy }
|
||||
%w(uid info credentials extra).each do |fetcher|
|
||||
%w[uid info credentials extra].each do |fetcher|
|
||||
describe ".#{fetcher}" do
|
||||
it 'sets and retrieve a proc' do
|
||||
proc = lambda { 'Hello' }
|
||||
|
@ -143,7 +143,7 @@ describe OmniAuth::Strategy do
|
|||
|
||||
context 'fetcher stacks' do
|
||||
subject { fresh_strategy }
|
||||
%w(uid info credentials extra).each do |fetcher|
|
||||
%w[uid info credentials extra].each do |fetcher|
|
||||
describe ".#{fetcher}_stack" do
|
||||
it 'is an array of called ancestral procs' do
|
||||
fetchy = proc { 'Hello' }
|
||||
|
@ -154,7 +154,7 @@ describe OmniAuth::Strategy do
|
|||
end
|
||||
end
|
||||
|
||||
%w(request_phase).each do |abstract_method|
|
||||
%w[request_phase].each do |abstract_method|
|
||||
context abstract_method.to_s do
|
||||
it 'raises a NotImplementedError' do
|
||||
strat = Class.new
|
||||
|
@ -208,7 +208,7 @@ describe OmniAuth::Strategy do
|
|||
end
|
||||
|
||||
it 'sets options based on the arguments if they are supplied' do
|
||||
subject.args [:abc, :def]
|
||||
subject.args %i[abc def]
|
||||
s = subject.new app, 123, 456
|
||||
expect(s.options[:abc]).to eq(123)
|
||||
expect(s.options[:def]).to eq(456)
|
||||
|
@ -277,7 +277,7 @@ describe OmniAuth::Strategy do
|
|||
end
|
||||
end
|
||||
|
||||
%w(info credentials extra).each do |fetcher|
|
||||
%w[info credentials extra].each do |fetcher|
|
||||
subject { fresh_strategy }
|
||||
it "is the current class's proc call if one exists" do
|
||||
subject.send(fetcher) { {:abc => 123} }
|
||||
|
@ -302,7 +302,7 @@ describe OmniAuth::Strategy do
|
|||
context 'omniauth.origin' do
|
||||
context 'disabled' do
|
||||
it 'does not set omniauth.origin' do
|
||||
@options = { :origin_param => false }
|
||||
@options = {:origin_param => false}
|
||||
expect { strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'return=/foo')) }.to raise_error('Request Phase')
|
||||
expect(strategy.last_env['rack.session']['omniauth.origin']).to eq(nil)
|
||||
end
|
||||
|
@ -310,7 +310,7 @@ describe OmniAuth::Strategy do
|
|||
|
||||
context 'custom' do
|
||||
it 'sets from a custom param' do
|
||||
@options = { :origin_param => 'return' }
|
||||
@options = {:origin_param => 'return'}
|
||||
expect { strategy.call(make_env('/auth/test', 'QUERY_STRING' => 'return=/foo')) }.to raise_error('Request Phase')
|
||||
expect(strategy.last_env['rack.session']['omniauth.origin']).to eq('/foo')
|
||||
end
|
||||
|
@ -528,7 +528,7 @@ describe OmniAuth::Strategy do
|
|||
end
|
||||
|
||||
after do
|
||||
OmniAuth.config.allowed_request_methods = [:get, :post]
|
||||
OmniAuth.config.allowed_request_methods = %i[get post]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue