diff --git a/.rubocop.yml b/.rubocop.yml index b949aa2..889dfbc 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,8 +1,9 @@ inherit_gem: - my-rubocop: default.yml + rubocop-config: default.yml AllCops: TargetRubyVersion: 2.5 + SuggestExtensions: false Exclude: - vendor/**/* diff --git a/Gemfile b/Gemfile index aa8c243..e544204 100644 --- a/Gemfile +++ b/Gemfile @@ -14,5 +14,5 @@ gem 'rspec' gem 'webmock', '~> 3.0' group :test do - gem 'my-rubocop', github: 'jgraichen/my-rubocop' + gem 'rubocop-config', github: 'jgraichen/rubocop-config', ref: 'v11', require: false end diff --git a/lib/rack/remote.rb b/lib/rack/remote.rb index 67fcd11..94969b9 100644 --- a/lib/rack/remote.rb +++ b/lib/rack/remote.rb @@ -68,16 +68,16 @@ def call(env) else [ 200, {'Content-Type' => 'application/json'}, - StringIO.new(MultiJson.dump(response)) + StringIO.new(MultiJson.dump(response)), ] end rescue StandardError => e [ 500, {'Content-Type' => 'application/json'}, StringIO.new( MultiJson.dump( - error: e.message, backtrace: e.backtrace, class: e.class.name - ) - ) + error: e.message, backtrace: e.backtrace, class: e.class.name, + ), + ), ] end else @@ -86,9 +86,9 @@ def call(env) MultiJson.dump( error: 'remote call not defined', calls: call, - list: self.class.calls.keys - ) - ) + list: self.class.calls.keys, + ), + ), ] end end diff --git a/rack-remote.gemspec b/rack-remote.gemspec index 01cc068..61fdb73 100644 --- a/rack-remote.gemspec +++ b/rack-remote.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |spec| spec.name = 'rack-remote' spec.version = Rack::Remote::VERSION spec.authors = ['Jan Graichen'] - spec.email = %w[jg@altimos.de] + spec.email = %w[jgraichen@altimos.de] spec.summary = 'Small request intercepting rack middleware to ' \ 'invoke remote calls over HTTP.' spec.description = 'Small request intercepting rack middleware to ' \ @@ -19,11 +19,12 @@ Gem::Specification.new do |spec| spec.files = `git ls-files -z`.split("\x0") spec.executables = spec.files.grep(%r{^bin/}) {|f| File.basename(f) } - spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = %w[lib] spec.add_dependency 'multi_json' spec.add_dependency 'rack' - spec.add_development_dependency 'bundler' + spec.metadata['rubygems_mfa_required'] = 'true' + + spec.required_ruby_version = Gem::Requirement.new('>= 2.5.0') end diff --git a/spec/rack/remote_spec.rb b/spec/rack/remote_spec.rb index cbf9821..5eadbc3 100644 --- a/spec/rack/remote_spec.rb +++ b/spec/rack/remote_spec.rb @@ -74,14 +74,22 @@ end it 'invokes remote call' do - expect(block).to receive(:call).with({'param1' => 'val1'}, kind_of(Hash), kind_of(Rack::Request)).and_return({id: 1}) + allow(block).to receive(:call) + .with({'param1' => 'val1'}, kind_of(Hash), kind_of(Rack::Request)) + .and_return({id: 1}) + ret = described_class.invoke :users, :factory_bot, param1: 'val1' + expect(ret).to eq({'id' => 1}) end it 'invokes remote call (2)' do - expect(block).to receive(:call).with({'param1' => ['val1', {'abc' => 'cde'}]}, kind_of(Hash), kind_of(Rack::Request)).and_return({id: 1}) + allow(block).to receive(:call) + .with({'param1' => ['val1', {'abc' => 'cde'}]}, kind_of(Hash), kind_of(Rack::Request)) + .and_return({id: 1}) + ret = described_class.invoke :users, :factory_bot, param1: ['val1', {abc: :cde}] + expect(ret).to eq({'id' => 1}) end end