From 6e786684c2d9a39aec548985b9529405b7bc6ff6 Mon Sep 17 00:00:00 2001 From: Rubocop Challenger Date: Wed, 7 Feb 2024 23:31:45 +0000 Subject: [PATCH 1/3] :police_car: regenerate rubocop todo --- .rubocop_todo.yml | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index ae394a82..90e95c1c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by -# `rubocop --auto-gen-config --exclude-limit 200` -# on 2023-10-11 12:02:42 UTC using RuboCop version 1.57.0. +# `rubocop --auto-gen-config --exclude-limit 180` +# on 2024-02-07 23:31:43 UTC using RuboCop version 1.60.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -154,7 +154,7 @@ Layout/EmptyLineBetweenDefs: - 'spec/dummy/app/controllers/pets_using_auto_views_controller.rb' - 'spec/dummy/app/controllers/pets_using_self_describing_classes_controller.rb' -# Offense count: 56 +# Offense count: 55 # This cop supports safe autocorrection (--autocorrect). Layout/EmptyLines: Exclude: @@ -192,7 +192,7 @@ Layout/EmptyLinesAroundAttributeAccessor: Exclude: - 'lib/apipie/configuration.rb' -# Offense count: 92 +# Offense count: 91 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, no_empty_lines @@ -213,7 +213,6 @@ Layout/EmptyLinesAroundBlockBody: - 'spec/lib/apipie/extractor/writer_spec.rb' - 'spec/lib/apipie/file_handler_spec.rb' - 'spec/lib/apipie/generator/swagger/param_description/composite_spec.rb' - - 'spec/lib/apipie/generator/swagger/param_description/type_spec.rb' - 'spec/lib/apipie/param_description_spec.rb' - 'spec/lib/apipie/param_group_spec.rb' - 'spec/lib/apipie/validator_spec.rb' @@ -454,7 +453,7 @@ Layout/SpaceAfterColon: Exclude: - 'spec/dummy/app/controllers/included_param_group_controller.rb' -# Offense count: 42 +# Offense count: 41 # This cop supports safe autocorrection (--autocorrect). Layout/SpaceAfterComma: Exclude: @@ -490,8 +489,9 @@ Layout/SpaceAfterNot: # Offense count: 142 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. +# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator, EnforcedStyleForRationalLiterals. # SupportedStylesForExponentOperator: space, no_space +# SupportedStylesForRationalLiterals: space, no_space Layout/SpaceAroundOperators: Exclude: - 'app/controllers/apipie/apipies_controller.rb' @@ -726,21 +726,18 @@ Lint/UnderscorePrefixedVariableName: - 'lib/apipie/application.rb' - 'lib/apipie/dsl_definition.rb' -# Offense count: 26 +# Offense count: 22 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. Lint/UnusedBlockArgument: Exclude: - 'lib/apipie/configuration.rb' - - 'lib/apipie/extractor/collector.rb' - - 'lib/apipie/extractor/recorder.rb' - 'lib/apipie/param_description.rb' - 'lib/apipie/resource_description.rb' - 'lib/apipie/rspec/response_validation_helper.rb' - 'lib/tasks/apipie.rake' - 'spec/controllers/users_controller_spec.rb' - 'spec/lib/apipie/apipies_controller_spec.rb' - - 'spec/lib/apipie/extractor_spec.rb' - 'spec/lib/swagger/swagger_dsl_spec.rb' - 'spec/spec_helper.rb' @@ -802,7 +799,7 @@ Metrics/MethodLength: Metrics/ModuleLength: Max: 119 -# Offense count: 4 +# Offense count: 5 # Configuration parameters: CountKeywordArgs. Metrics/ParameterLists: MaxOptionalParameters: 5 @@ -974,7 +971,7 @@ RSpec/BeforeAfterAll: Exclude: - 'spec/controllers/users_controller_spec.rb' -# Offense count: 53 +# Offense count: 54 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: @@ -1141,7 +1138,7 @@ RSpec/MessageSpies: RSpec/MultipleExpectations: Max: 19 -# Offense count: 160 +# Offense count: 163 # Configuration parameters: AllowSubject. RSpec/MultipleMemoizedHelpers: Max: 15 @@ -1166,7 +1163,7 @@ RSpec/NamedSubject: - 'spec/lib/swagger/rake_swagger_spec.rb' - 'spec/lib/swagger/swagger_dsl_spec.rb' -# Offense count: 96 +# Offense count: 97 # Configuration parameters: AllowedGroups. RSpec/NestedGroups: Max: 6 @@ -1293,7 +1290,7 @@ Rails/NegateInclude: - 'lib/apipie/extractor/writer.rb' - 'spec/spec_helper.rb' -# Offense count: 7 +# Offense count: 6 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Include. # Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb @@ -1921,7 +1918,7 @@ Style/StringConcatenation: - 'lib/apipie/application.rb' - 'lib/apipie/extractor/writer.rb' -# Offense count: 1214 +# Offense count: 1229 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes @@ -2021,7 +2018,7 @@ Style/TrailingCommaInArrayLiteral: - 'spec/controllers/users_controller_spec.rb' - 'spec/dummy/app/controllers/pets_using_self_describing_classes_controller.rb' -# Offense count: 4 +# Offense count: 5 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma From 0e38b4d1c69ce934d7716fd39177b7e1c12e6029 Mon Sep 17 00:00:00 2001 From: Rubocop Challenger Date: Wed, 7 Feb 2024 23:31:53 +0000 Subject: [PATCH 2/3] :police_car: RSpec/ExampleWording --- .rubocop_todo.yml | 21 ----- .../api/v1/architectures_controller_spec.rb | 6 +- .../v2/nested/resources_controller_spec.rb | 2 +- spec/controllers/concerns_controller_spec.rb | 4 +- spec/controllers/extended_controller_spec.rb | 4 +- .../included_param_group_controller_spec.rb | 2 +- spec/controllers/users_controller_spec.rb | 78 +++++++-------- spec/lib/apipie/application_spec.rb | 4 +- spec/lib/apipie/extractor/writer_spec.rb | 8 +- spec/lib/apipie/method_description_spec.rb | 4 +- spec/lib/apipie/param_description_spec.rb | 94 +++++++++---------- spec/lib/apipie/param_group_spec.rb | 8 +- spec/lib/apipie/resource_description_spec.rb | 4 +- spec/lib/apipie/validator_spec.rb | 24 ++--- spec/lib/swagger/swagger_dsl_spec.rb | 74 +++++++-------- spec/test_engine/memes_controller_spec.rb | 2 +- 16 files changed, 159 insertions(+), 180 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 90e95c1c..3bec84fb 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1049,27 +1049,6 @@ RSpec/EmptyLineAfterHook: RSpec/ExampleLength: Max: 85 -# Offense count: 159 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. -# DisallowedExamples: works -RSpec/ExampleWording: - Exclude: - - 'spec/controllers/api/v1/architectures_controller_spec.rb' - - 'spec/controllers/api/v2/nested/resources_controller_spec.rb' - - 'spec/controllers/concerns_controller_spec.rb' - - 'spec/controllers/extended_controller_spec.rb' - - 'spec/controllers/included_param_group_controller_spec.rb' - - 'spec/controllers/users_controller_spec.rb' - - 'spec/lib/apipie/application_spec.rb' - - 'spec/lib/apipie/extractor/writer_spec.rb' - - 'spec/lib/apipie/method_description_spec.rb' - - 'spec/lib/apipie/param_description_spec.rb' - - 'spec/lib/apipie/param_group_spec.rb' - - 'spec/lib/apipie/resource_description_spec.rb' - - 'spec/lib/apipie/validator_spec.rb' - - 'spec/lib/swagger/swagger_dsl_spec.rb' - - 'spec/test_engine/memes_controller_spec.rb' # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). diff --git a/spec/controllers/api/v1/architectures_controller_spec.rb b/spec/controllers/api/v1/architectures_controller_spec.rb index da1eec39..7d78e66f 100644 --- a/spec/controllers/api/v1/architectures_controller_spec.rb +++ b/spec/controllers/api/v1/architectures_controller_spec.rb @@ -4,7 +4,7 @@ describe "resource description" do subject { Apipie.get_resource_description(Api::V1::ArchitecturesController, "1.0") } - it "should be version 1.0" do + it "is version 1.0" do expect(subject._version).to eq('1.0') expect(Apipie.resource_descriptions['1.0'].size).to eq(2) @@ -14,11 +14,11 @@ context "there is another version" do let(:v2) { archv2 = Apipie.get_resource_description(Api::V2::ArchitecturesController, "2.0") } - it "should have unique doc url" do + it "has unique doc url" do expect(subject.doc_url).not_to eq(v2.doc_url) end - it "should have unique methods" do + it "has unique methods" do expect(subject._methods.keys).to include(:index) expect(v2._methods.keys).to include(:index) expect(subject._methods[:index]).not_to eq(v2._methods[:index]) diff --git a/spec/controllers/api/v2/nested/resources_controller_spec.rb b/spec/controllers/api/v2/nested/resources_controller_spec.rb index 81adf6e1..e52b97f8 100644 --- a/spec/controllers/api/v2/nested/resources_controller_spec.rb +++ b/spec/controllers/api/v2/nested/resources_controller_spec.rb @@ -20,7 +20,7 @@ describe '.get_resource_id' do subject { Apipie.get_resource_id(Api::V2::Nested::ResourcesController) } - it "should have resource_id set" do + it "has resource_id set" do expect(subject).to eq("resource") end end diff --git a/spec/controllers/concerns_controller_spec.rb b/spec/controllers/concerns_controller_spec.rb index 027cfc50..2abec52b 100644 --- a/spec/controllers/concerns_controller_spec.rb +++ b/spec/controllers/concerns_controller_spec.rb @@ -7,12 +7,12 @@ expect(Apipie["concern_resources#show"]).to be end - it "should reply to valid request" do + it "replies to valid request" do get :show, :params => { :id => '5' }, :session => { :user_id => "secret_hash" } assert_response :success end - it "should pass if required parameter is missing" do + it "passes if required parameter is missing" do expect { get :show, :params => { :id => '5' } }.not_to raise_error end diff --git a/spec/controllers/extended_controller_spec.rb b/spec/controllers/extended_controller_spec.rb index d79c17bc..ec466a4c 100644 --- a/spec/controllers/extended_controller_spec.rb +++ b/spec/controllers/extended_controller_spec.rb @@ -2,13 +2,13 @@ describe ExtendedController do - it 'should include params from both original controller and extending concern' do + it 'includes params from both original controller and extending concern' do expect(Apipie["extended#create"].params.keys).to eq [:oauth, :user, :admin] user_param = Apipie["extended#create"].params[:user] expect(user_param.validator.params_ordered.map(&:name)).to eq [:name, :password, :from_concern] end - it 'should include updated metadata' do + it 'includes updated metadata' do expect(Apipie['extended#create'].metadata).to eq metadata: 'data' end end diff --git a/spec/controllers/included_param_group_controller_spec.rb b/spec/controllers/included_param_group_controller_spec.rb index 8e0f53bc..c15eff72 100644 --- a/spec/controllers/included_param_group_controller_spec.rb +++ b/spec/controllers/included_param_group_controller_spec.rb @@ -5,7 +5,7 @@ let(:dsl_data) { ActionController::Base.send(:_apipie_dsl_data_init) } - it "should not error when there is a param_group that is deeply nested in response description" do + it "does not error when there is a param_group that is deeply nested in response description" do subject = Apipie.get_resource_description(IncludedParamGroupController, Apipie.configuration.default_version) expect(subject._methods.keys).to include(:show) end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index f4fff6f4..822331d3 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -28,7 +28,7 @@ def compare_hashes(h1, h2) Apipie.get_resource_description(UsersController, Apipie.configuration.default_version) end - it "should contain all resource methods" do + it "contains all resource methods" do methods = subject._methods expect(methods.keys).to include(:show) expect(methods.keys).to include(:create_route) @@ -40,7 +40,7 @@ def compare_hashes(h1, h2) expect(methods.keys).to include(:multiple_required_params) end - it "should contain info about resource" do + it "contains info about resource" do expect(subject._short_description).to eq('Site members') expect(subject._id).to eq('users') expect(subject._path).to eq('/users') @@ -49,7 +49,7 @@ def compare_hashes(h1, h2) expect(subject._formats).to eq(['json']) end - it "should contain params defined on resource level" do + it "contains params defined on resource level" do expect(subject._params_args.count).to eq(2) name, type, options = subject._params_args.first expect(name).to eq(:id) @@ -67,12 +67,12 @@ def compare_hashes(h1, h2) Apipie.configuration.validate_presence = true end - it "should reply to valid request" do + it "replies to valid request" do get :show, :params => { :id => '5', :session => "secret_hash" } assert_response :success end - it "should pass if required parameter is missing" do + it "passes if required parameter is missing" do expect { get :show, :params => { :id => 5 } }.not_to raise_error end @@ -93,20 +93,20 @@ def reload_controllers Apipie.configuration.validate_key = false end - it "should reply to valid request" do + it "replies to valid request" do expect { get :show, :params => { :id => 5, :session => "secret_hash" }}.not_to raise_error assert_response :success end - it "should fail if required parameter is missing" do + it "fails if required parameter is missing" do expect { get :show, :params => { :id => 5 }}.to raise_error(Apipie::ParamMissing, /session_parameter_is_required/) end - it "should fail if multiple required parameters are missing" do + it "fails if multiple required parameters are missing" do expect { get :multiple_required_params }.to raise_error(Apipie::ParamMultipleMissing, /required_param1.*\n.*required_param2|required_param2.*\n.*required_parameter1/) end - it "should pass if required parameter has wrong type" do + it "passes if required parameter has wrong type" do expect { get :show, :params => { :id => 5 , :session => "secret_hash" }}.not_to raise_error expect { get :show, :params => { :id => "ten" , :session => "secret_hash" }}.not_to raise_error end @@ -120,12 +120,12 @@ def reload_controllers Apipie.configuration.validate_key = true end - it "should reply to valid request" do + it "replies to valid request" do expect { get :show, :params => { :id => 5, :session => 'secret_hash' }}.not_to raise_error assert_response :success end - it "should fail if extra parameter is passed in" do + it "fails if extra parameter is passed in" do expect { get :show, :params => { :id => 5 , :badparam => 'badfoo', :session => "secret_hash" }}.to raise_error(Apipie::UnknownParam, /\bbadparam\b/) end end @@ -138,12 +138,12 @@ def reload_controllers Apipie.configuration.action_on_non_validated_keys = :skip end - it "should reply to valid request" do + it "replies to valid request" do expect { get :show, :params => { :id => 5, :session => 'secret_hash' }}.not_to raise_error assert_response :success end - it "should delete the param and not fail if an extra parameter is passed." do + it "deletes the param and not fail if an extra parameter is passed." do expect { get :show, :params => { :id => 5 , :badparam => 'badfoo', :session => "secret_hash" }}.not_to raise_error expect(controller.params.as_json).to eq({"session"=>"secret_hash", "id"=>"5", "controller"=>"users", "action"=>"show"}) end @@ -160,30 +160,30 @@ def reload_controllers Apipie.configuration.validate_key = false end - it "should reply to valid request" do + it "replies to valid request" do get :show, :params => { :id => '5', :session => "secret_hash" } assert_response :success end - it "should work with nil value for a required hash param" do + it "works with nil value for a required hash param" do expect { get :show, :params => { :id => '5', :session => "secret_hash", :hash_param => {:dummy_hash => nil} } }.to raise_error(Apipie::ParamInvalid, /dummy_hash/) assert_response :success end - it "should fail if required parameter is missing" do + it "fails if required parameter is missing" do expect { get :show, :params => { :id => 5 }}.to raise_error(Apipie::ParamMissing, /session_parameter_is_required/) end - it "should work with custom Type validator" do + it "works with custom Type validator" do expect { get :show, :params => { :id => "not a number", :session => "secret_hash" } }.to raise_error(Apipie::ParamError, /id/) # old-style error rather than ParamInvalid end - it "should work with Regexp validator" do + it "works with Regexp validator" do get :show, :params => { :id => 5, :session => "secret_hash", :regexp_param => "24 years" } assert_response :success @@ -194,7 +194,7 @@ def reload_controllers }.to raise_error(Apipie::ParamInvalid, /regexp_param/) end - it "should work with Array validator" do + it "works with Array validator" do get :show, :params => { :id => 5, :session => "secret_hash", :array_param => "one" } assert_response :success get :show, :params => { :id => 5, :session => "secret_hash", :array_param => "two" } @@ -216,7 +216,7 @@ def reload_controllers }.to raise_error(Apipie::ParamInvalid, /array_param/) end - it "should work with Proc validator" do + it "works with Proc validator" do expect { get :show, :params => { @@ -233,7 +233,7 @@ def reload_controllers assert_response :success end - it "should work with Hash validator" do + it "works with Hash validator" do post :create, params: { :user => { :name => "root", :pass => "12345", :membership => "standard" } } assert_response :success @@ -268,7 +268,7 @@ def reload_controllers assert_response :success end - it "should support Hash validator without specifying keys" do + it "supports Hash validator without specifying keys" do params = Apipie[UsersController, :create].to_json[:params] expect(params).to include(:name => "facts", :full_name => "facts", @@ -284,7 +284,7 @@ def reload_controllers :validations => []) end - it "should allow nil when allow_nil is set to true" do + it "allows nil when allow_nil is set to true" do post :create, :params => { :user => { @@ -297,7 +297,7 @@ def reload_controllers assert_response :success end - it "should allow blank when allow_blank is set to true" do + it "allows blank when allow_blank is set to true" do post :create, :params => { :user => { @@ -313,7 +313,7 @@ def reload_controllers describe "nested elements" do context "with valid input" do - it "should succeed" do + it "succeeds" do put :update, :params => { :id => 5, @@ -335,7 +335,7 @@ def reload_controllers end end context "with bad input" do - it "should raise an error" do + it "raises an error" do expect{ put :update, :params => { @@ -356,7 +356,7 @@ def reload_controllers }.to raise_error(Apipie::ParamInvalid) end end - it "should work with empty array" do + it "works with empty array" do put :update, :params => { :id => 5, @@ -407,7 +407,7 @@ def reload_controllers describe "method description" do - it "should contain basic info about method" do + it "contains basic info about method" do a = Apipie[UsersController, :create] expect(a.apis.count).to eq(1) expect(a.formats).to eq(['json']) @@ -431,7 +431,7 @@ def reload_controllers end context "Usign routes.rb" do - it "should contain basic info about method" do + it "contains basic info about method" do a = Apipie[UsersController, :create_route] expect(a.apis.count).to eq(1) expect(a.formats).to eq(['json']) @@ -446,7 +446,7 @@ def reload_controllers context "contain :see option" do context "the key is valid" do - it "should contain reference to another method" do + it "contains reference to another method" do api = Apipie[UsersController, :see_another] expect(api.show).to be false see = api.see.first @@ -464,7 +464,7 @@ def reload_controllers end context "the key is not valid" do - it "should raise exception" do + it "raises exception" do api = Apipie[UsersController, :see_another] api.instance_variable_set :@see, [Apipie::SeeDescription.new(['doesnot#exist'])] expect { @@ -475,7 +475,7 @@ def reload_controllers end end - it "should contain possible errors description" do + it "contains possible errors description" do a = Apipie.get_method_description(UsersController, :show) expect(a.errors[0].code).to eq(500) @@ -486,7 +486,7 @@ def reload_controllers expect(a.errors[2].description).to eq("Not Found") end - it 'should recognize Rack symbols as error codes' do + it 'recognizes Rack symbols as error codes' do a = Apipie.get_method_description(UsersController, :create) error = a.errors.find { |e| e.code == 422 } @@ -494,7 +494,7 @@ def reload_controllers expect(error.description).to include("Unprocessable Entity") end - it "should contain all params description" do + it "contains all params description" do a = Apipie.get_method_description(UsersController, :show) expect(a.params.count).to eq(12) expect(a.instance_variable_get('@params_ordered').count).to eq(10) @@ -564,7 +564,7 @@ def reload_controllers end end - it "should contain all api method description" do + it "contains all api method description" do method_description = Apipie[UsersController, :two_urls] expect(method_description.class).to be(Apipie::MethodDescription) expect(method_description.apis.count).to eq(2) @@ -579,7 +579,7 @@ def reload_controllers expect(a2.http_method).to eq('GET') end - it "should be described by valid json" do + it "is described by valid json" do json = Apipie[UsersController, :two_urls].to_json expected_hash = { :errors => [{:code=>404, :description=>"Missing", :metadata => {:some => "metadata"}}, @@ -672,7 +672,7 @@ def reload_controllers describe "examples" do - it "should be able to load examples from yml file" do + it "is able to load examples from yml file" do expect(Apipie.get_method_description(UsersController, :show).examples).to eq [< 32, :weight => '830g' @@ -32,12 +32,12 @@ describe "show option" do - it "should return true when show option is not provided" do + it "returns true when show option is not provided" do param = Apipie::ParamDescription.new(method_desc, :some_param, String) expect(param.to_json[:show]).to eq(true) end - it "should return the show option" do + it "returns the show option" do param = Apipie::ParamDescription.new(method_desc, :some_param, String, :show => true) expect(param.to_json[:show]).to eq(true) @@ -50,7 +50,7 @@ describe "full_name" do context "with no nested parameters" do - it "should return name" do + it "returns name" do param = Apipie::ParamDescription.new(method_desc, :some_param, String) expect(param.to_json[:full_name]).to eq('some_param') end @@ -59,7 +59,7 @@ context "with nested parameters" do - it "should return the parameter's name nested in the parents name" do + it "returns the parameter's name nested in the parents name" do parent_param = Apipie::ParamDescription.new(method_desc, :parent, String) nested_param = Apipie::ParamDescription.new(method_desc, :nested, String, :parent => parent_param) @@ -68,7 +68,7 @@ context "with the parent parameter set to not show" do - it "should return just the parameter's name" do + it "returns just the parameter's name" do parent_param = Apipie::ParamDescription.new(method_desc, :parent, String, :show => false) nested_param = Apipie::ParamDescription.new(method_desc, :nested, String, :parent => parent_param) @@ -80,13 +80,13 @@ end describe "manual validation text" do - it "should allow manual text" do + it "allows manual text" do param = Apipie::ParamDescription.new(method_desc, :hidden_param, nil, :validations => "must be foo") expect(param.validations).to include("\n

must be foo

\n") end - it "should allow multiple items" do + it "allows multiple items" do param = Apipie::ParamDescription.new(method_desc, :hidden_param, nil, :validations => ["> 0", "< 5"]) expect(param.validations).to include("\n

> 0

\n") @@ -96,16 +96,16 @@ describe "validator selection" do - it "should allow nil validator" do + it "allows nil validator" do param = Apipie::ParamDescription.new(method_desc, :hidden_param, nil) expect(param.validator).to be_nil end - it "should throw exception on unknown validator" do + it "throws exception on unknown validator" do expect { Apipie::ParamDescription.new(method_desc, :param, :unknown) }.to raise_error(RuntimeError, /Validator.*not found/) end - it "should pick type validator" do + it "picks type validator" do expect(Apipie::Validator::BaseValidator).to receive(:find).and_return(:validator_instance) param = Apipie::ParamDescription.new(method_desc, :param, String) expect(param.validator).to eq(:validator_instance) @@ -137,7 +137,7 @@ context 'when validation value is false' do let(:validation_value) { false } - it 'should not raise an error' do + it 'does not raise an error' do expect { subject }.not_to raise_error end end @@ -145,7 +145,7 @@ context 'when validation value is an empty string' do let(:validation_value) { '' } - it 'should raise an error' do + it 'raises an error' do expect { subject }.to raise_error(Apipie::ParamInvalid) end end @@ -157,7 +157,7 @@ context 'when validation value is false' do let(:validation_value) { false } - it 'should not raise an error' do + it 'does not raise an error' do expect { subject }.not_to raise_error end end @@ -165,7 +165,7 @@ context 'when validation value is true' do let(:validation_value) { true } - it 'should not raise an error' do + it 'does not raise an error' do expect { subject }.not_to raise_error end end @@ -173,7 +173,7 @@ context 'when validation value is an empty string' do let(:validation_value) { '' } - it 'should raise an error' do + it 'raises an error' do expect { subject }.to raise_error(Apipie::ParamInvalid) end end @@ -185,14 +185,14 @@ context 'when validation value is empty string' do let(:validation_value) { '' } - it 'should not raise an error' do + it 'does not raise an error' do expect { subject }.not_to raise_error end context 'when allow_blank is specified as true' do let(:allow_blank) { true } - it 'should not raise an error' do + it 'does not raise an error' do expect { subject }.not_to raise_error end end @@ -206,14 +206,14 @@ context 'when validation value' do let(:validation_value) { false } - it 'should not raise an error' do + it 'does not raise an error' do expect { subject }.not_to raise_error end context 'when allow_blank is false' do let(:allow_blank) { false } - it 'should not raise an error' do + it 'does not raise an error' do expect { subject }.not_to raise_error end end @@ -221,7 +221,7 @@ context 'when allow_blank is true' do let(:allow_blank) { true } - it 'should not raise an error' do + it 'does not raise an error' do expect { subject }.not_to raise_error end end @@ -230,7 +230,7 @@ context 'when validation value is empty string' do let(:validation_value) { '' } - it 'should raise an error' do + it 'raises an error' do expect { subject }.to raise_error(Apipie::ParamInvalid) end end @@ -242,7 +242,7 @@ context 'when validation value is false' do let(:validation_value) { false } - it 'should not raise an error' do + it 'does not raise an error' do expect { subject }.not_to raise_error end end @@ -250,7 +250,7 @@ context 'when validation value is true' do let(:validation_value) { true } - it 'should not raise an error' do + it 'does not raise an error' do expect { subject }.not_to raise_error end end @@ -258,7 +258,7 @@ context 'when validation value is an empty string' do let(:validation_value) { '' } - it 'should raise an error' do + it 'raises an error' do expect { subject }.to raise_error(Apipie::ParamInvalid) end end @@ -275,14 +275,14 @@ context 'when a blank but valid value is passed' do let(:validation_value) { false } - it 'should not raise an error' do + it 'does not raise an error' do expect { subject }.not_to raise_error end context 'when allow_blank is false' do let(:allow_blank) { false } - it 'should not raise an error' do + it 'does not raise an error' do expect { subject }.not_to raise_error end end @@ -291,7 +291,7 @@ context 'when a blank but invalid value is passed' do let(:validation_value) { '' } - it 'should raise an error' do + it 'raises an error' do expect { subject }.to raise_error(Apipie::ParamInvalid) end end @@ -304,7 +304,7 @@ context 'when a blank but invalid value is passed' do let(:validation_value) { '' } - it 'should raise an error' do + it 'raises an error' do expect { subject }.to raise_error(Apipie::ParamInvalid) end end @@ -315,7 +315,7 @@ context 'when and empty string is given' do let(:validation_value) { '' } - it 'should not raise an error' do + it 'does not raise an error' do expect { subject }.not_to raise_error end end @@ -335,27 +335,27 @@ Apipie::MethodDescription.new(:show, concern_resource_desc, concern_dsl_data) end - it "should replace string parameter name with colon prefix" do + it "replaces string parameter name with colon prefix" do param = Apipie::ParamDescription.new(concern_method_desc, ":string_subst", String) expect(param.name).to eq("string") end - it "should replace symbol parameter name" do + it "replaces symbol parameter name" do param = Apipie::ParamDescription.new(concern_method_desc, :concern, String) expect(param.name).to eq(:user) end - it "should keep original value for strings without colon prefixes" do + it "keeps original value for strings without colon prefixes" do param = Apipie::ParamDescription.new(concern_method_desc, "string_subst", String) expect(param.name).to eq("string_subst") end - it "should keep the original value when a string can't be replaced" do + it "keeps the original value when a string can't be replaced" do param = Apipie::ParamDescription.new(concern_method_desc, ":param", String) expect(param.name).to eq(":param") end - it "should keep the original value when a symbol can't be replaced" do + it "keeps the original value when a symbol can't be replaced" do param = Apipie::ParamDescription.new(concern_method_desc, :param, String) expect(param.name).to eq(:param) end @@ -366,12 +366,12 @@ before { Apipie.configuration.required_by_default = true } - it "should set param as required by default" do + it "sets param as required by default" do param = Apipie::ParamDescription.new(method_desc, :required_by_default, String) expect(param.required).to be true end - it "should be possible to set param as optional" do + it "is possible to set param as optional" do param = Apipie::ParamDescription.new(method_desc, :optional, String, :required => false) expect(param.required).to be false end @@ -382,12 +382,12 @@ before { Apipie.configuration.required_by_default = false } - it "should set param as optional by default" do + it "sets param as optional by default" do param = Apipie::ParamDescription.new(method_desc, :optional_by_default, String) expect(param.required).to be false end - it "should be possible to set param as required" do + it "is possible to set param as required" do param = Apipie::ParamDescription.new(method_desc, :required, String, 'description','required' => true) expect(param.required).to be true end @@ -402,21 +402,21 @@ end context "when the param is required for current action" do - it "should set param as required" do + it "sets param as required" do param = Apipie::ParamDescription.new(method_desc, :required, String, 'description','required' => :create) expect(param.required).to be true end end context "when the param is required for multiple actions" do - it "should set param as required if it match current action" do + it "sets param as required if it match current action" do param = Apipie::ParamDescription.new(method_desc, :required, String, 'description','required' => [:update, :create]) expect(param.required).to be true end end context "when the param is not required for current action" do - it "should set param as not required" do + it "sets param as not required" do param = Apipie::ParamDescription.new(method_desc, :required, String, 'description','required' => :update) expect(param.required).to be false end @@ -500,7 +500,7 @@ end end - it "should include the nested params in the json" do + it "includes the nested params in the json" do sub_params = subject.to_json[:params] expect(sub_params.size).to eq(1) sub_param = sub_params.first @@ -518,7 +518,7 @@ end end - it "should include the nested params in the json" do + it "includes the nested params in the json" do sub_params = subject.to_json[:params] expect(sub_params.size).to eq(1) sub_param = sub_params.first @@ -534,7 +534,7 @@ Apipie::ParamDescription.new(method_desc, :param, String) end - it "should include the nested params in the json" do + it "includes the nested params in the json" do expect(subject.to_json[:params]).to be_nil end @@ -543,7 +543,7 @@ end describe "Array with classes" do - it "should be valid for objects included in class array" do + it "is valid for objects included in class array" do param = Apipie::ParamDescription.new(method_desc, :param, [Integer, String]) expect { param.validate("1") }.not_to raise_error expect { param.validate(Integer) }.to raise_error(Apipie::ParamInvalid) diff --git a/spec/lib/apipie/param_group_spec.rb b/spec/lib/apipie/param_group_spec.rb index 3ddcf749..993567f8 100644 --- a/spec/lib/apipie/param_group_spec.rb +++ b/spec/lib/apipie/param_group_spec.rb @@ -20,7 +20,7 @@ expect(user_create_params.map(&:to_s).sort).to eq(%w[membership name pass]) end - it "should allow adding additional params to group" do + it "allows adding additional params to group" do user_create_desc = Apipie["users#create"].params[:user] user_create_params = user_create_desc.validator.params_ordered.map(&:name) expect(user_create_params.map(&:to_s).sort).to eq(%w[membership name pass permalink]) @@ -43,16 +43,16 @@ expect(arch_v1_params.sort_by(&:to_s)).to eq(arch_v2_params.sort_by(&:to_s)) end - it "should replace parameter name in a group when it comes from concern" do + it "replaces parameter name in a group when it comes from concern" do expect(Apipie["overridden_concern_resources#update"].params.key?(:user)).to eq(true) end - it "shouldn't replace parameter name in a group redefined in the controller" do + it "does not replace parameter name in a group redefined in the controller" do expect(Apipie["overridden_concern_resources#create"].params.key?(:concern)).to eq(true) expect(Apipie["overridden_concern_resources#create"].params.key?(:user)).to eq(false) end -it "shouldn't replace name of a parameter defined in the controller" do +it "does not replace name of a parameter defined in the controller" do expect(Apipie["overridden_concern_resources#custom"].params.key?(:concern)).to eq(true) expect(Apipie["overridden_concern_resources#custom"].params.key?(:user)).to eq(false) end diff --git a/spec/lib/apipie/resource_description_spec.rb b/spec/lib/apipie/resource_description_spec.rb index a7f60aae..7d26e82a 100644 --- a/spec/lib/apipie/resource_description_spec.rb +++ b/spec/lib/apipie/resource_description_spec.rb @@ -25,7 +25,7 @@ ) end - it 'should be ordered' do + it 'is ordered' do expect(methods.keys).to eq([:a, :b, :c]) end end @@ -63,7 +63,7 @@ ) end - it 'should be ordered' do + it 'is ordered' do expect(methods_as_json.map { |h| h[:name] }).to eq(%w[a b c]) end end diff --git a/spec/lib/apipie/validator_spec.rb b/spec/lib/apipie/validator_spec.rb index 831daba0..10eca9b1 100644 --- a/spec/lib/apipie/validator_spec.rb +++ b/spec/lib/apipie/validator_spec.rb @@ -20,22 +20,22 @@ context "expected type" do - it "should return hash for type Hash" do + it "returns hash for type Hash" do validator = Apipie::Validator::TypeValidator.new(params_desc, Hash) expect(validator.expected_type).to eq('hash') end - it "should return array for type Array" do + it "returns array for type Array" do validator = Apipie::Validator::TypeValidator.new(params_desc, Array) expect(validator.expected_type).to eq('array') end - it "should return numeric for type Numeric" do + it "returns numeric for type Numeric" do validator = Apipie::Validator::TypeValidator.new(params_desc, Numeric) expect(validator.expected_type).to eq('numeric') end - it "should return string by default" do + it "returns string by default" do validator = Apipie::Validator::TypeValidator.new(params_desc, Symbol) expect(validator.expected_type).to eq('string') end @@ -43,7 +43,7 @@ end describe 'NumberValidator' do - it 'should expect a Numeric type' do + it 'expects a Numeric type' do validator = Apipie::Validator::BaseValidator.find(params_desc, :number, nil, nil) expect(validator.expected_type).to eq('numeric') end @@ -86,7 +86,7 @@ end describe '#validate' do - it "should validate by object class" do + it "validates by object class" do expect(validator_instance.validate("1")).to be_truthy expect(validator_instance.validate(1)).to be_truthy expect(validator_instance.validate(true)).to be_truthy @@ -104,21 +104,21 @@ end describe 'ArrayClassValidator' do - it "should validate by object class" do + it "validates by object class" do validator = Apipie::Validator::ArrayClassValidator.new(params_desc, [Integer, String]) expect(validator.validate("1")).to be_truthy expect(validator.validate(1)).to be_truthy expect(validator.validate({ 1 => 1 })).to be_falsey end - it "should have a valid description" do + it "has a valid description" do validator = Apipie::Validator::ArrayClassValidator.new(params_desc, [Float, String]) expect(validator.description).to eq('Must be one of: Float, String.') end end describe 'RegexpValidator' do - it "should validate by object class" do + it "validates by object class" do validator = Apipie::Validator::RegexpValidator.new(params_desc, /^valid( extra)*$/) expect(validator.validate("valid")).to be_truthy expect(validator.validate("valid extra")).to be_truthy @@ -126,14 +126,14 @@ expect(validator.validate("invalid")).to be_falsey end - it "should have a valid description" do + it "has a valid description" do validator = Apipie::Validator::RegexpValidator.new(params_desc, /^valid( extra)*$/) expect(validator.description).to eq('Must match regular expression /^valid( extra)*$/.') end end describe 'EnumValidator' do - it "should validate by object class" do + it "validates by object class" do validator = Apipie::Validator::EnumValidator.new(params_desc, ['first', 'second & third']) expect(validator.validate("first")).to be_truthy expect(validator.validate("second & third")).to be_truthy @@ -141,7 +141,7 @@ expect(validator.validate({ 1 => 1 })).to be_falsey end - it "should have a valid description" do + it "has a valid description" do validator = Apipie::Validator::EnumValidator.new(params_desc, ['first', 'second & third']) expect(validator.description).to eq('Must be one of: first, second & third.') end diff --git a/spec/lib/swagger/swagger_dsl_spec.rb b/spec/lib/swagger/swagger_dsl_spec.rb index 563c1b63..aea9ba24 100644 --- a/spec/lib/swagger/swagger_dsl_spec.rb +++ b/spec/lib/swagger/swagger_dsl_spec.rb @@ -122,7 +122,7 @@ def have_field?(field, expected_name, breadcrumb) desc._methods[:index] end - it "should return code 200 with array of entries of the format {'pet_name', 'animal_type'}" do + it "returns code 200 with array of entries of the format {'pet_name', 'animal_type'}" do returns_obj = subject.returns.detect{|e| e.code == 200 } puts returns_obj.to_json @@ -132,7 +132,7 @@ def have_field?(field, expected_name, breadcrumb) expect(returns_obj).to match_field_structure([:pet_name, :animal_type]) end - it 'should have the response described in the swagger' do + it 'has the response described in the swagger' do response = swagger_response_for('/pets') expect(response[:description]).to eq("list of pets") @@ -145,7 +145,7 @@ def have_field?(field, expected_name, breadcrumb) end - it "should return code 401 with a String description field" do + it "returns code 401 with a String description field" do returns_obj = subject.returns.detect{|e| e.code == 404 } expect(returns_obj.code).to eq(404) @@ -155,7 +155,7 @@ def have_field?(field, expected_name, breadcrumb) end - it "should return code 401 with a :reason field (defined in the superclass)" do + it "returns code 401 with a :reason field (defined in the superclass)" do returns_obj = subject.returns.detect{|e| e.code == 401 } expect(returns_obj.code).to eq(401) @@ -164,7 +164,7 @@ def have_field?(field, expected_name, breadcrumb) expect(returns_obj).to match_field_structure([:reason]) end - it 'should have the 404 response described in the swagger' do + it 'has the 404 response described in the swagger' do response = swagger_response_for('/pets', 404) expect(response[:description]).to eq("Not Found") @@ -181,7 +181,7 @@ def have_field?(field, expected_name, breadcrumb) desc._methods[:show_plain_response_with_tags] end - it "should return tags with 'Dogs', 'Cats', and 'LivingBeings'" do + it "returns tags with 'Dogs', 'Cats', and 'LivingBeings'" do returns_obj = subject.tag_list puts returns_obj.inspect @@ -194,7 +194,7 @@ def have_field?(field, expected_name, breadcrumb) desc._methods[:show_as_properties] end - it "should return code 200 with 'pet_name' and 'animal_type'" do + it "returns code 200 with 'pet_name' and 'animal_type'" do returns_obj = subject.returns.detect{|e| e.code == 200 } puts returns_obj.to_json @@ -204,7 +204,7 @@ def have_field?(field, expected_name, breadcrumb) expect(returns_obj).to match_field_structure([:pet_name, :animal_type]) end - it 'should have the response described in the swagger' do + it 'has the response described in the swagger' do response = swagger_response_for('/pets/{id}/as_properties') expect(response[:description]).to eq("OK") @@ -213,7 +213,7 @@ def have_field?(field, expected_name, breadcrumb) expect(schema).to have_field(:animal_type, 'string', {:description => 'Type of pet', :enum => %w[dog cat iguana kangaroo]}) end - it 'should have the 404 response description overridden' do + it 'has the 404 response description overridden' do returns_obj = subject.returns.detect{|e| e.code == 404 } # puts returns_obj.to_json @@ -229,7 +229,7 @@ def have_field?(field, expected_name, breadcrumb) desc._methods[:show_as_param_group_of_properties] end - it "should return code 200 with 'pet_name' and 'animal_type'" do + it "returns code 200 with 'pet_name' and 'animal_type'" do returns_obj = subject.returns.detect{|e| e.code == 200 } puts returns_obj.to_json @@ -241,7 +241,7 @@ def have_field?(field, expected_name, breadcrumb) expect(returns_obj.params_ordered[1].is_required?).to be_truthy end - it 'should have the response described in the swagger' do + it 'has the response described in the swagger' do response = swagger_response_for('/pets/{id}/as_param_group_of_properties') expect(response[:description]).to eq("The pet") @@ -256,7 +256,7 @@ def have_field?(field, expected_name, breadcrumb) desc._methods[:show_pet_by_id] end - it "should have only oauth (from ApplicationController), common_param (from resource) and pet_id as an input parameters" do + it "has only oauth (from ApplicationController), common_param (from resource) and pet_id as an input parameters" do params_obj = subject.params_ordered expect(params_obj[0].name).to eq(:oauth) @@ -264,7 +264,7 @@ def have_field?(field, expected_name, breadcrumb) expect(params_obj[2].name).to eq(:pet_id) end - it "should return code 200 with 'pet_id', pet_name' and 'animal_type'" do + it "returns code 200 with 'pet_id', pet_name' and 'animal_type'" do returns_obj = subject.returns.detect{|e| e.code == 200 } puts returns_obj.to_json @@ -275,7 +275,7 @@ def have_field?(field, expected_name, breadcrumb) expect(returns_obj).to match_field_structure([:pet_id, :pet_name, :animal_type]) end - it 'should have the response described in the swagger' do + it 'has the response described in the swagger' do response = swagger_response_for('/pets/pet_by_id') expect(response[:description]).to eq("OK") @@ -304,7 +304,7 @@ def have_field?(field, expected_name, breadcrumb) desc._methods[:get_vote_by_owner_name] end - it "should return code 200 with 'owner_name' and 'vote'" do + it "returns code 200 with 'owner_name' and 'vote'" do returns_obj = subject.returns.detect{|e| e.code == 200 } puts returns_obj.to_json @@ -314,7 +314,7 @@ def have_field?(field, expected_name, breadcrumb) expect(returns_obj).to match_field_structure([:owner_name, :vote]) end - it 'should have the response described in the swagger' do + it 'has the response described in the swagger' do response = swagger_response_for('/pets/by_owner_name/did_vote') expect(response[:description]).to eq("OK") @@ -329,7 +329,7 @@ def have_field?(field, expected_name, breadcrumb) desc._methods[:show_extra_info] end - it "should return code 201 with 'pet_name' and 'animal_type'" do + it "returns code 201 with 'pet_name' and 'animal_type'" do returns_obj = subject.returns.detect{|e| e.code == 201 } puts returns_obj.to_json @@ -339,7 +339,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 + it 'has 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") @@ -348,7 +348,7 @@ def have_field?(field, expected_name, breadcrumb) expect(schema).to have_field(:animal_type, 'string') end - it "should return code 202 with spread out 'pet' and encapsulated 'pet_measurements'" do + it "returns code 202 with spread out 'pet' and encapsulated 'pet_measurements'" do returns_obj = subject.returns.detect{|e| e.code == 202 } puts returns_obj.to_json @@ -361,7 +361,7 @@ def have_field?(field, expected_name, breadcrumb) ]) end - it 'should have the 202 response described in the swagger' do + it 'has the 202 response described in the swagger' do response = swagger_response_for('/pets/{id}/extra_info', 202) expect(response[:description]).to eq('Accepted') @@ -376,7 +376,7 @@ def have_field?(field, expected_name, breadcrumb) expect(pm_schema).to have_field(:num_legs, 'number', {:description => "Number of legs", :required => false}) end - it "should return code 203 with spread out 'pet', encapsulated 'pet_measurements' and encapsulated 'pet_history'" do + it "returns code 203 with spread out 'pet', encapsulated 'pet_measurements' and encapsulated 'pet_history'" do returns_obj = subject.returns.detect{|e| e.code == 203 } puts returns_obj.to_json @@ -391,7 +391,7 @@ def have_field?(field, expected_name, breadcrumb) ]) end - it 'should have the 203 response described in the swagger' do + it 'has 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') @@ -418,7 +418,7 @@ def have_field?(field, expected_name, breadcrumb) expect(pai_schema).to have_field(:avg_meals_per_day, 'number') end - it "should return code 204 with array of integer" do + it "returns code 204 with array of integer" do returns_obj = subject.returns.detect{|e| e.code == 204 } puts returns_obj.to_json @@ -428,7 +428,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 + it 'has the 204 response described in the swagger' do response = swagger_response_for('/pets/{id}/extra_info', 204) schema = response[:schema] @@ -437,7 +437,7 @@ def have_field?(field, expected_name, breadcrumb) end - it "should return code matching :unprocessable_entity (422) with spread out 'pet' and 'num_fleas'" do + it "returns code matching :unprocessable_entity (422) with spread out 'pet' and 'num_fleas'" do returns_obj = subject.returns.detect{|e| e.code == 422 } puts returns_obj.to_json @@ -449,7 +449,7 @@ def have_field?(field, expected_name, breadcrumb) ]) end - it 'should have the 422 response described in the swagger' do + it 'has 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') @@ -475,7 +475,7 @@ def have_field?(field, expected_name, breadcrumb) desc._methods[:show_as_properties] end - it "should return tags with 'Dogs', and 'Wolves'" do + it "returns tags with 'Dogs', and 'Wolves'" do returns_obj = subject.tag_list puts returns_obj.inspect @@ -496,7 +496,7 @@ def have_field?(field, expected_name, breadcrumb) desc._methods[:show_as_properties] end - it "should return tags with 'Dogs', 'Pets', and 'Animals'" do + it "returns tags with 'Dogs', 'Pets', and 'Animals'" do returns_obj = subject.tag_list puts returns_obj.inspect @@ -509,7 +509,7 @@ def have_field?(field, expected_name, breadcrumb) desc._methods[:show_as_same_properties] end - it "should return tags with 'Dogs', 'Pets', 'Puma', and 'Animals'" do + it "returns tags with 'Dogs', 'Pets', 'Puma', and 'Animals'" do returns_obj = subject.tag_list puts returns_obj.inspect @@ -532,7 +532,7 @@ def have_field?(field, expected_name, breadcrumb) desc._methods[:pets_described_as_class] end - it "should return code 200 with array of entries of the format {'pet_name', 'animal_type'}" do + it "returns code 200 with array of entries of the format {'pet_name', 'animal_type'}" do returns_obj = subject.returns.detect{|e| e.code == 200 } puts returns_obj.to_json @@ -542,7 +542,7 @@ def have_field?(field, expected_name, breadcrumb) expect(returns_obj).to match_field_structure([:pet_name, :animal_type]) end - it 'should have the response described in the swagger' do + it 'has the response described in the swagger' do response = swagger_response_for('/pets_described_as_class') expect(response[:description]).to eq("list of pets") @@ -561,7 +561,7 @@ def have_field?(field, expected_name, breadcrumb) desc._methods[:pets_with_measurements_described_as_class] end - it "should return code 200 with spread out 'pet' and encapsulated 'pet_measurements'" do + it "returns code 200 with spread out 'pet' and encapsulated 'pet_measurements'" do returns_obj = subject.returns.detect{|e| e.code == 200 } puts returns_obj.to_json @@ -574,7 +574,7 @@ def have_field?(field, expected_name, breadcrumb) ]) end - it 'should have the 200 response described in the swagger' do + it 'has 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') @@ -595,7 +595,7 @@ def have_field?(field, expected_name, breadcrumb) desc._methods[:pets_with_many_measurements_as_class] end - it "should return code 200 with pet_name (string) and many_pet_measurements (array of objects)" do + it "returns code 200 with pet_name (string) and many_pet_measurements (array of objects)" do returns_obj = subject.returns.detect{|e| e.code == 200 } puts returns_obj.to_json @@ -608,7 +608,7 @@ def have_field?(field, expected_name, breadcrumb) end - it 'should have the 200 response described in the swagger' do + it 'has the 200 response described in the swagger' do response = swagger_response_for('/pets_with_many_measurements_as_class/{id}', 200) expect(response[:description]).to eq('measurements of the pet') @@ -637,7 +637,7 @@ def have_field?(field, expected_name, breadcrumb) desc._methods[:pet_described_using_automated_view] end - it "should return code 200 with array of entries of the format {'pet_name', 'animal_type'}" do + it "returns code 200 with array of entries of the format {'pet_name', 'animal_type'}" do returns_obj = subject.returns.detect{|e| e.code == 200 } expect(returns_obj.code).to eq(200) @@ -646,7 +646,7 @@ def have_field?(field, expected_name, breadcrumb) expect(returns_obj).to match_field_structure([:pet_name, :animal_type, :age]) end - it 'should have the response described in the swagger' do + it 'has the response described in the swagger' do response = swagger_response_for('/pet_described_using_automated_view/{id}') expect(response[:description]).to eq("like Pet, but different") diff --git a/spec/test_engine/memes_controller_spec.rb b/spec/test_engine/memes_controller_spec.rb index 5cfb0e65..f9bd26d9 100644 --- a/spec/test_engine/memes_controller_spec.rb +++ b/spec/test_engine/memes_controller_spec.rb @@ -3,7 +3,7 @@ describe TestEngine::MemesController do describe "#index" do - it "should have the full mounted path of engine" do + it "has the full mounted path of engine" do expect(Apipie.routes_for_action(TestEngine::MemesController, :index, {}).first[:path]).to eq("/test/memes") end end From 4e131a48cc5570851eee3cbea9138bec79282599 Mon Sep 17 00:00:00 2001 From: Rubocop Challenger Date: Wed, 7 Feb 2024 23:32:04 +0000 Subject: [PATCH 3/3] :police_car: regenerate rubocop todo --- .rubocop_todo.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3bec84fb..018ff3c2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 180` -# on 2024-02-07 23:31:43 UTC using RuboCop version 1.60.2. +# on 2024-02-07 23:32:02 UTC using RuboCop version 1.60.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -1049,7 +1049,6 @@ RSpec/EmptyLineAfterHook: RSpec/ExampleLength: Max: 85 - # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). RSpec/ExcessiveDocstringSpacing: @@ -1897,7 +1896,7 @@ Style/StringConcatenation: - 'lib/apipie/application.rb' - 'lib/apipie/extractor/writer.rb' -# Offense count: 1229 +# Offense count: 1231 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes