From d10ec0fb1c2a20000e02098da3c0e3c50ad74299 Mon Sep 17 00:00:00 2001 From: Timothy Njoroge Date: Tue, 20 Feb 2024 15:56:57 +0300 Subject: [PATCH] Lint files --- .rubocop.yml | 2 +- spec/requests/api/cars_spec.rb | 234 ++++++++++++------------- spec/requests/api/cities_spec.rb | 120 ++++++------- spec/requests/api/initial_data_spec.rb | 77 ++++---- spec/requests/api/reservations_spec.rb | 146 +++++++-------- 5 files changed, 278 insertions(+), 301 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a70a29d..dac4c37 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -25,7 +25,7 @@ Metrics/AbcSize: Metrics/ClassLength: Max: 150 Metrics/BlockLength: - AllowedMethods: ['describe'] + AllowedMethods: ['describe', 'path', 'create', 'post', 'get', 'put'] Max: 60 Style/Documentation: diff --git a/spec/requests/api/cars_spec.rb b/spec/requests/api/cars_spec.rb index 1eb2301..a641606 100644 --- a/spec/requests/api/cars_spec.rb +++ b/spec/requests/api/cars_spec.rb @@ -2,7 +2,6 @@ RSpec.describe 'api/cars', type: :request do path '/api/v1/cars' do - post 'Creates a car' do tags 'create' consumes 'application/json' @@ -26,7 +25,7 @@ infotainment_system: { type: :string }, safety_rating: { type: :string }, tech_features: { type: :string }, - special_features: { type: :string }, + special_features: { type: :string } } } } @@ -34,49 +33,46 @@ response '201', 'car created' do schema type: :object, - properties: { - status: { - type: :object, - properties: { - code: { type: :integer }, - message: { type: :string } - } - }, - data: { - type: :object, - properties: { - id: { type: :integer }, - name: { type: :string }, - description: { type: :string }, - car_image: { type: :string }, - car_detail_attributes: { - type: :object, - properties: { - engine_type_id: { type: :string }, - horsepower: { type: :string }, - torque: { type: :string }, - fuel_economy: { type: :string }, - range: { type: :string }, - seating_capacity: { type: :string }, - cargo_space: { type: :string }, - infotainment_system: { type: :string }, - safety_rating: { type: :string }, - tech_features: { type: :string }, - special_features: { type: :string }, - } - } - } - } - } + properties: { + status: { + type: :object, + properties: { + code: { type: :integer }, + message: { type: :string } + } + }, + data: { + type: :object, + properties: { + id: { type: :integer }, + name: { type: :string }, + description: { type: :string }, + car_image: { type: :string }, + car_detail_attributes: { + type: :object, + properties: { + engine_type_id: { type: :string }, + horsepower: { type: :string }, + torque: { type: :string }, + fuel_economy: { type: :string }, + range: { type: :string }, + seating_capacity: { type: :string }, + cargo_space: { type: :string }, + infotainment_system: { type: :string }, + safety_rating: { type: :string }, + tech_features: { type: :string }, + special_features: { type: :string } + } + } + } + } + } run_test! end - end - end path '/api/v1/cars/{id}' do - get 'Retrieves a car' do tags 'Get' produces 'application/json' @@ -84,40 +80,40 @@ response '200', 'car found' do schema type: :object, - properties: { - status: { - type: :object, - properties: { - code: { type: :integer }, - message: { type: :string } - } - }, - data: { - type: :object, - properties: { - id: { type: :integer }, - name: { type: :string }, - description: { type: :string }, - car_image: { type: :string }, - car_detail_attributes: { - type: :object, - properties: { - engine_type_id: { type: :string }, - horsepower: { type: :string }, - torque: { type: :string }, - fuel_economy: { type: :string }, - range: { type: :string }, - seating_capacity: { type: :string }, - cargo_space: { type: :string }, - infotainment_system: { type: :string }, - safety_rating: { type: :string }, - tech_features: { type: :string }, - special_features: { type: :string }, - } - } - } - } - } + properties: { + status: { + type: :object, + properties: { + code: { type: :integer }, + message: { type: :string } + } + }, + data: { + type: :object, + properties: { + id: { type: :integer }, + name: { type: :string }, + description: { type: :string }, + car_image: { type: :string }, + car_detail_attributes: { + type: :object, + properties: { + engine_type_id: { type: :string }, + horsepower: { type: :string }, + torque: { type: :string }, + fuel_economy: { type: :string }, + range: { type: :string }, + seating_capacity: { type: :string }, + cargo_space: { type: :string }, + infotainment_system: { type: :string }, + safety_rating: { type: :string }, + tech_features: { type: :string }, + special_features: { type: :string } + } + } + } + } + } let(:id) { create(:car).id } run_test! @@ -152,7 +148,7 @@ infotainment_system: { type: :string }, safety_rating: { type: :string }, tech_features: { type: :string }, - special_features: { type: :string }, + special_features: { type: :string } } } } @@ -163,40 +159,40 @@ response '200', 'car updated' do schema type: :object, - properties: { - status: { - type: :object, - properties: { - code: { type: :integer }, - message: { type: :string } - } - }, - data: { - type: :object, - properties: { - id: { type: :integer }, - name: { type: :string }, - description: { type: :string }, - car_image: { type: :string }, - car_detail_attributes: { - type: :object, - properties: { - engine_type_id: { type: :string }, - horsepower: { type: :string }, - torque: { type: :string }, - fuel_economy: { type: :string }, - range: { type: :string }, - seating_capacity: { type: :string }, - cargo_space: { type: :string }, - infotainment_system: { type: :string }, - safety_rating: { type: :string }, - tech_features: { type: :string }, - special_features: { type: :string }, - } - } - } - } - } + properties: { + status: { + type: :object, + properties: { + code: { type: :integer }, + message: { type: :string } + } + }, + data: { + type: :object, + properties: { + id: { type: :integer }, + name: { type: :string }, + description: { type: :string }, + car_image: { type: :string }, + car_detail_attributes: { + type: :object, + properties: { + engine_type_id: { type: :string }, + horsepower: { type: :string }, + torque: { type: :string }, + fuel_economy: { type: :string }, + range: { type: :string }, + seating_capacity: { type: :string }, + cargo_space: { type: :string }, + infotainment_system: { type: :string }, + safety_rating: { type: :string }, + tech_features: { type: :string }, + special_features: { type: :string } + } + } + } + } + } run_test! end @@ -211,20 +207,18 @@ response '200', 'car deleted' do schema type: :object, - properties: { - status: { - type: :object, - properties: { - code: { type: :integer }, - message: { type: :string } - } - }, - } + properties: { + status: { + type: :object, + properties: { + code: { type: :integer }, + message: { type: :string } + } + } + } run_test! end end - end - -end \ No newline at end of file +end diff --git a/spec/requests/api/cities_spec.rb b/spec/requests/api/cities_spec.rb index 107db2e..37b29fa 100644 --- a/spec/requests/api/cities_spec.rb +++ b/spec/requests/api/cities_spec.rb @@ -2,7 +2,6 @@ RSpec.describe 'api/cities', type: :request do path '/api/v1/cities' do - post 'Creates a city' do tags 'create' consumes 'application/json' @@ -10,36 +9,34 @@ parameter name: :city, in: :body, schema: { type: :object, properties: { - name: { type: :string }, + name: { type: :string } } } response '201', 'city created' do schema type: :object, - properties: { - status: { - type: :object, - properties: { - code: { type: :integer }, - message: { type: :string } - } - }, - data: { - type: :object, - properties: { - id: { type: :integer }, - name: { type: :string }, - } - } - } + properties: { + status: { + type: :object, + properties: { + code: { type: :integer }, + message: { type: :string } + } + }, + data: { + type: :object, + properties: { + id: { type: :integer }, + name: { type: :string } + } + } + } run_test! end - end end path '/api/v1/cities/{id}' do - get 'Retrieves a city' do tags 'Get' produces 'application/json' @@ -49,22 +46,22 @@ let(:id) { create(:city).id } schema type: :object, - properties: { - status: { - type: :object, - properties: { - code: { type: :integer }, - message: { type: :string } - } - }, - data: { - type: :object, - properties: { - id: { type: :integer }, - name: { type: :string }, - } - } - } + properties: { + status: { + type: :object, + properties: { + code: { type: :integer }, + message: { type: :string } + } + }, + data: { + type: :object, + properties: { + id: { type: :integer }, + name: { type: :string } + } + } + } run_test! end @@ -91,22 +88,22 @@ response '200', 'city updated' do schema type: :object, - properties: { - status: { - type: :object, - properties: { - code: { type: :integer }, - message: { type: :string } - } - }, - data: { - type: :object, - properties: { - id: { type: :integer }, - name: { type: :string }, - } - } - } + properties: { + status: { + type: :object, + properties: { + code: { type: :integer }, + message: { type: :string } + } + }, + data: { + type: :object, + properties: { + id: { type: :integer }, + name: { type: :string } + } + } + } run_test! end @@ -121,19 +118,18 @@ response '200', 'city deleted' do schema type: :object, - properties: { - status: { - type: :object, - properties: { - code: { type: :integer }, - message: { type: :string } - } - }, - } + properties: { + status: { + type: :object, + properties: { + code: { type: :integer }, + message: { type: :string } + } + } + } run_test! end end - end end diff --git a/spec/requests/api/initial_data_spec.rb b/spec/requests/api/initial_data_spec.rb index 6d3e5a5..3fef039 100644 --- a/spec/requests/api/initial_data_spec.rb +++ b/spec/requests/api/initial_data_spec.rb @@ -2,7 +2,6 @@ RSpec.describe 'api/initial_data', type: :request do path '/api/v1/initial_data' do - get 'Retrieves initial data' do tags 'Get' produces 'application/json' @@ -13,48 +12,46 @@ let(:engine_type) { create(:engine_type) } schema type: :object, - properties: { - status: { - type: :object, - properties: { - code: { type: :integer }, - message: { type: :string } - } - }, - data: { - type: :object, - properties: { - cars: { - type: :array, - properties: { - id: { type: :string }, - name: { type: :string }, - description: { type: :string }, - image_url: { type: :string } - } - }, - cities: { - type: :array, - properties: { - id: { type: :string }, - name: { type: :string } - } - }, - engine_types: { - type: :array, - properties: { - id: { type: :string }, - name: { type: :string } - } - } - } - } - } + properties: { + status: { + type: :object, + properties: { + code: { type: :integer }, + message: { type: :string } + } + }, + data: { + type: :object, + properties: { + cars: { + type: :array, + properties: { + id: { type: :string }, + name: { type: :string }, + description: { type: :string }, + image_url: { type: :string } + } + }, + cities: { + type: :array, + properties: { + id: { type: :string }, + name: { type: :string } + } + }, + engine_types: { + type: :array, + properties: { + id: { type: :string }, + name: { type: :string } + } + } + } + } + } run_test! end - end - end end diff --git a/spec/requests/api/reservations_spec.rb b/spec/requests/api/reservations_spec.rb index f380969..dfe82bb 100644 --- a/spec/requests/api/reservations_spec.rb +++ b/spec/requests/api/reservations_spec.rb @@ -2,7 +2,6 @@ RSpec.describe 'api/reservations', type: :request do path '/api/v1/reservations' do - get 'Retrieves reservations belonging to a user' do tags 'Get' produces 'application/json' @@ -11,22 +10,16 @@ let(:id) { create(:reservation).id } schema type: :object, - properties: { - status: { - type: :object, - properties: { - code: { type: :integer }, - message: { type: :string } - } - }, - data: { - type: :array, - properties: [{ - id: { type: :integer }, - date: { type: :string }, - }] - } - } + properties: { + status: { + type: :object, + properties: { code: { type: :integer }, message: { type: :string } } + }, + data: { type: :array, properties: [{ + id: { type: :integer }, + date: { type: :string } + }] } + } run_test! end @@ -48,36 +41,34 @@ city_id: { type: :integer }, car_id: { type: :integer }, user_id: { type: :integer }, - required: [ 'date', 'city_id', 'user_id', 'car_id' ] + required: %w[date city_id user_id car_id] } } response '201', 'reservation created' do schema type: :object, - properties: { - status: { - type: :object, - properties: { - code: { type: :integer }, - message: { type: :string } - } - }, - data: { - type: :object, - properties: { - id: { type: :integer }, - date: { type: :string }, - } - } - } + properties: { + status: { + type: :object, + properties: { + code: { type: :integer }, + message: { type: :string } + } + }, + data: { + type: :object, + properties: { + id: { type: :integer }, + date: { type: :string } + } + } + } run_test! end - end end path '/api/v1/reservations/{id}' do - get 'Retrieves a reservation' do tags 'Get' produces 'application/json' @@ -87,22 +78,22 @@ let(:id) { create(:reservation).id } schema type: :object, - properties: { - status: { - type: :object, - properties: { - code: { type: :integer }, - message: { type: :string } - } - }, - data: { - type: :object, - properties: { - id: { type: :integer }, - date: { type: :string }, - } - } - } + properties: { + status: { + type: :object, + properties: { + code: { type: :integer }, + message: { type: :string } + } + }, + data: { + type: :object, + properties: { + id: { type: :integer }, + date: { type: :string } + } + } + } run_test! end @@ -129,22 +120,22 @@ response '200', 'reservation updated' do schema type: :object, - properties: { - status: { - type: :object, - properties: { - code: { type: :integer }, - message: { type: :string } - } - }, - data: { - type: :object, - properties: { - id: { type: :integer }, - date: { type: :string }, - } - } - } + properties: { + status: { + type: :object, + properties: { + code: { type: :integer }, + message: { type: :string } + } + }, + data: { + type: :object, + properties: { + id: { type: :integer }, + date: { type: :string } + } + } + } run_test! end @@ -159,19 +150,18 @@ response '200', 'reservation deleted' do schema type: :object, - properties: { - status: { - type: :object, - properties: { - code: { type: :integer }, - message: { type: :string } - } - }, - } + properties: { + status: { + type: :object, + properties: { + code: { type: :integer }, + message: { type: :string } + } + } + } run_test! end end - end end