From 9a0b16d4f1f9ff039c31b3f17fb0e94d3a3ac610 Mon Sep 17 00:00:00 2001 From: Matt Bearman Date: Thu, 12 Sep 2024 10:04:32 +0100 Subject: [PATCH] chore: Fix linting issues - add_runtime_dependency is deprecated in favour of add_dependency - params are not required for `super` when the method signature is unchanged --- apia.gemspec | 4 ++-- lib/apia/dsls/endpoint.rb | 2 +- spec/specs/apia/argument_set_spec.rb | 2 +- spec/specs/apia/endpoint_spec.rb | 22 +++++++++++----------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/apia.gemspec b/apia.gemspec index a695cb5..8842c73 100644 --- a/apia.gemspec +++ b/apia.gemspec @@ -13,6 +13,6 @@ Gem::Specification.new do |s| s.authors = ['Adam Cooke'] s.email = ['adam@k.io'] s.licenses = ['MIT'] - s.add_runtime_dependency 'json' - s.add_runtime_dependency 'rack' + s.add_dependency 'json' + s.add_dependency 'rack' end diff --git a/lib/apia/dsls/endpoint.rb b/lib/apia/dsls/endpoint.rb index df939e3..f9a8d18 100644 --- a/lib/apia/dsls/endpoint.rb +++ b/lib/apia/dsls/endpoint.rb @@ -69,7 +69,7 @@ def field(name, *args, type: nil, **options, &block) field :pagination, type: PaginationObject end - super(name, *args, type: type, **options, &block) + super end def fields(fieldset) diff --git a/spec/specs/apia/argument_set_spec.rb b/spec/specs/apia/argument_set_spec.rb index 6fa4fac..def493b 100644 --- a/spec/specs/apia/argument_set_spec.rb +++ b/spec/specs/apia/argument_set_spec.rb @@ -40,7 +40,7 @@ end it 'should create a new set using HTTP params if provided' do - env = Rack::MockRequest.env_for('/?name=michael', :input => '') + env = Rack::MockRequest.env_for('/?name=michael', input: '') request = Apia::Request.new(env) as = Apia::ArgumentSet.create('ExampleSet') do argument :name, type: :string diff --git a/spec/specs/apia/endpoint_spec.rb b/spec/specs/apia/endpoint_spec.rb index 35caf0f..58a7c93 100644 --- a/spec/specs/apia/endpoint_spec.rb +++ b/spec/specs/apia/endpoint_spec.rb @@ -12,7 +12,7 @@ context '.execute' do context 'authenticators' do it 'should call the endpoint authenticator if one has been set' do - request = Apia::Request.new(Rack::MockRequest.env_for('/', :input => '')) + request = Apia::Request.new(Rack::MockRequest.env_for('/', input: '')) api_auth = Apia::Authenticator.create('ExampleAPIAuthenticator') api_auth.action { response.add_header 'x-auth', 'api' } @@ -45,7 +45,7 @@ end it 'should call the controller authenticator if one has been set' do - request = Apia::Request.new(Rack::MockRequest.env_for('/', :input => '')) + request = Apia::Request.new(Rack::MockRequest.env_for('/', input: '')) api_auth = Apia::Authenticator.create('ExampleAPIAuthenticator') api_auth.action { response.add_header 'x-auth', 'api' } @@ -75,7 +75,7 @@ end it 'should call the API authenticator' do - request = Apia::Request.new(Rack::MockRequest.env_for('/', :input => '')) + request = Apia::Request.new(Rack::MockRequest.env_for('/', input: '')) api_auth = Apia::Authenticator.create('ExampleAPIAuthenticator') api_auth.action { response.add_header 'x-auth', 'api' } @@ -92,7 +92,7 @@ end it 'checks the scopes are valid' do - request = Apia::Request.new(Rack::MockRequest.env_for('/', :input => '')) + request = Apia::Request.new(Rack::MockRequest.env_for('/', input: '')) api_auth = Apia::Authenticator.create('ExampleAPIAuthenticator') do scope_validator { |e| e == 'not-example' } @@ -130,7 +130,7 @@ end it 'should create an argument set from standard HTTP query string parameters' do - request = Apia::Request.new(Rack::MockRequest.env_for('/?name=Adam', :input => '')) + request = Apia::Request.new(Rack::MockRequest.env_for('/?name=Adam', input: '')) request.endpoint = Apia::Endpoint.create('Endpoint') do argument :name, type: :string end @@ -144,7 +144,7 @@ context 'it includes CORS headers in the response' do context 'when nothing is specified' do it 'includes wildcard CORS headers' do - request = Apia::Request.new(Rack::MockRequest.env_for('/', :input => '')) + request = Apia::Request.new(Rack::MockRequest.env_for('/', input: '')) endpoint = Apia::Endpoint.create('Endpoint') response = endpoint.execute(request) expect(response.headers['Access-Control-Allow-Origin']).to eq '*' @@ -154,7 +154,7 @@ context 'when cors values are set by the authenticator' do it 'includes the CORS headers from the authenticator in the response' do - request = Apia::Request.new(Rack::MockRequest.env_for('/', :input => '')) + request = Apia::Request.new(Rack::MockRequest.env_for('/', input: '')) authenticator = Apia::Authenticator.create('ExampleAPIAuthenticator') authenticator.action do @@ -176,7 +176,7 @@ context 'when cors values are set by the authenticator and it throws an error' do it 'includes the CORS headers from the authenticator in the response' do - request = Apia::Request.new(Rack::MockRequest.env_for('/', :input => '')) + request = Apia::Request.new(Rack::MockRequest.env_for('/', input: '')) authenticator = Apia::Authenticator.create('ExampleAPIAuthenticator') do potential_error 'Failed' do @@ -207,7 +207,7 @@ context 'when the request is an OPTIONS request' do it 'returns a 200 OK status' do - request = Apia::Request.new(Rack::MockRequest.env_for('/', :input => '', method: 'OPTIONS')) + request = Apia::Request.new(Rack::MockRequest.env_for('/', input: '', method: 'OPTIONS')) endpoint = Apia::Endpoint.create('Endpoint') response = endpoint.execute(request) expect(response.headers['Access-Control-Allow-Origin']).to eq '*' @@ -217,7 +217,7 @@ end it 'does not execute the endpoint' do - request = Apia::Request.new(Rack::MockRequest.env_for('/', :input => '', method: 'OPTIONS')) + request = Apia::Request.new(Rack::MockRequest.env_for('/', input: '', method: 'OPTIONS')) endpoint = Apia::Endpoint.create('Endpoint') expect(endpoint).not_to receive(:new) endpoint.execute(request) @@ -226,7 +226,7 @@ context 'when the request is not an OPTIONS request' do it 'executes the endpoint' do - request = Apia::Request.new(Rack::MockRequest.env_for('/', :input => '', method: 'GET')) + request = Apia::Request.new(Rack::MockRequest.env_for('/', input: '', method: 'GET')) endpoint = Apia::Endpoint.create('Endpoint') expect(endpoint).to receive(:new).and_call_original endpoint.execute(request)