From 2e37a038101e90db855a7a29e939ed3c1617b124 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 20 Mar 2023 14:07:30 +0900 Subject: [PATCH] RSpec/EmptyLineAfterExample-20230301233314 (#834) * :police_car: regenerate rubocop todo * :police_car: RSpec/EmptyLineAfterExample * :police_car: regenerate rubocop todo --------- Co-authored-by: Rubocop Challenger Co-authored-by: Mathieu Jobin <99191+mathieujobin@users.noreply.github.com> --- .rubocop_todo.yml | 9 --------- spec/lib/apipie/apipies_controller_spec.rb | 4 ++++ spec/lib/apipie/generator/swagger/context_spec.rb | 1 + spec/lib/swagger/swagger_dsl_spec.rb | 6 ++++++ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4b58a622..57db45bb 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1115,15 +1115,6 @@ RSpec/EmptyExampleGroup: Exclude: - 'spec/lib/apipie/generator/swagger/param_description/composite_spec.rb' -# Offense count: 11 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowConsecutiveOneLiners. -RSpec/EmptyLineAfterExample: - Exclude: - - 'spec/lib/apipie/apipies_controller_spec.rb' - - 'spec/lib/apipie/generator/swagger/context_spec.rb' - - 'spec/lib/swagger/swagger_dsl_spec.rb' - # Offense count: 6 # This cop supports safe autocorrection (--autocorrect). RSpec/EmptyLineAfterExampleGroup: diff --git a/spec/lib/apipie/apipies_controller_spec.rb b/spec/lib/apipie/apipies_controller_spec.rb index 513deb4a..713b9424 100644 --- a/spec/lib/apipie/apipies_controller_spec.rb +++ b/spec/lib/apipie/apipies_controller_spec.rb @@ -209,6 +209,7 @@ get :index expect(test).to eq(true) end + it "remove all resources" do Apipie.configuration.authorize = Proc.new do |&args| false @@ -216,6 +217,7 @@ get :index expect(assigns(:doc)[:resources]).to eq({}) end + it "remove all methods" do Apipie.configuration.authorize = Proc.new do |controller, method, doc| !method @@ -225,6 +227,7 @@ expect(assigns(:doc)[:resources]["twitter_example"][:methods]).to eq([]) expect(assigns(:doc)[:resources]["users"][:methods]).to eq([]) end + it "remove specific method" do Apipie.configuration.authorize = nil get :index @@ -241,6 +244,7 @@ expect(assigns(:doc)[:resources]["users"][:methods].size).to eq(users_methods - 1) expect(assigns(:doc)[:resources]["twitter_example"][:methods].size).to eq(twitter_example_methods) end + it "does not allow access to swagger when authorization is set" do get :index, :params => { :format => "json", :type => "swagger"} diff --git a/spec/lib/apipie/generator/swagger/context_spec.rb b/spec/lib/apipie/generator/swagger/context_spec.rb index b14c0cf7..f419e63f 100644 --- a/spec/lib/apipie/generator/swagger/context_spec.rb +++ b/spec/lib/apipie/generator/swagger/context_spec.rb @@ -16,6 +16,7 @@ describe '#in_schema?' do it { is_expected.to be_in_schema } + context 'when in_schema is false' do let(:in_schema) { false } diff --git a/spec/lib/swagger/swagger_dsl_spec.rb b/spec/lib/swagger/swagger_dsl_spec.rb index c3dcb057..2b76a2b9 100644 --- a/spec/lib/swagger/swagger_dsl_spec.rb +++ b/spec/lib/swagger/swagger_dsl_spec.rb @@ -338,6 +338,7 @@ def have_field?(field, expected_name, breadcrumb) expect(returns_obj).to match_field_structure([:pet_name, :animal_type]) end + it 'should have the 201 response described in the swagger' do response = swagger_response_for('/pets/{id}/extra_info', 201) expect(response[:description]).to eq("Found a pet") @@ -359,6 +360,7 @@ def have_field?(field, expected_name, breadcrumb) {:pet_measurements => [:weight, :height, :num_legs]} ]) end + it 'should have the 202 response described in the swagger' do response = swagger_response_for('/pets/{id}/extra_info', 202) expect(response[:description]).to eq('Accepted') @@ -388,6 +390,7 @@ def have_field?(field, expected_name, breadcrumb) {:additional_histories => [:did_visit_vet, :avg_meals_per_day]} ]) end + it 'should have the 203 response described in the swagger' do response = swagger_response_for('/pets/{id}/extra_info', 203) expect(response[:description]).to eq('Non-Authoritative Information') @@ -424,6 +427,7 @@ def have_field?(field, expected_name, breadcrumb) expect(returns_obj).to match_field_structure([:int_array, :enum_array]) end + it 'should have the 204 response described in the swagger' do response = swagger_response_for('/pets/{id}/extra_info', 204) @@ -444,6 +448,7 @@ def have_field?(field, expected_name, breadcrumb) :num_fleas ]) end + it 'should have the 422 response described in the swagger' do response = swagger_response_for('/pets/{id}/extra_info', 422) expect(response[:description]).to eq('Fleas were discovered on the pet') @@ -568,6 +573,7 @@ def have_field?(field, expected_name, breadcrumb) {:pet_measurements => [:weight, :height, :num_legs]} ]) end + it 'should have the 200 response described in the swagger' do response = swagger_response_for('/pets_with_measurements_described_as_class/{id}', 200) expect(response[:description]).to eq('measurements of the pet')