diff --git a/.rubocop_cc.yml b/.rubocop_cc.yml index 1e3cfb9b941..4196adc141d 100644 --- a/.rubocop_cc.yml +++ b/.rubocop_cc.yml @@ -130,8 +130,28 @@ Migration/TooManyMigrationRuns: #### ENABLED SECTION Capybara/FindAllFirst: Enabled: true +Capybara/AbsoluteXPathInElementScope: + Enabled: true +Capybara/AlwaysTrueCountQuery: + Enabled: true Capybara/AssertStyle: Enabled: true +Capybara/ChainedFind: + Enabled: true +Capybara/IgnoredQueryOption: + Enabled: true +Capybara/ModalMethodWithoutBlock: + Enabled: true +Capybara/NativeAttribute: + Enabled: true +Capybara/UnorderedWindowAccess: + Enabled: true +Capybara/VisibilityOption: + Enabled: true +Capybara/RSpec/CurrentUrlExpectation: + Enabled: true +Capybara/RSpec/FindElementValueEq: + Enabled: true Capybara/RSpec/MatchStyle: Enabled: true Capybara/RSpec/NegationMatcher: @@ -192,6 +212,8 @@ Lint/AmbiguousOperatorPrecedence: Enabled: true Lint/AmbiguousRange: Enabled: true +Lint/ArgumentMismatch: + Enabled: true Lint/ArrayLiteralInRegexp: Enabled: true Lint/ConstantDefinitionInBlock: @@ -202,8 +224,12 @@ Lint/ConstantReassignment: Enabled: true Lint/CopDirectiveSyntax: Enabled: true +Lint/DataDefineOverride: + Enabled: true Lint/DeprecatedConstants: Enabled: true +Lint/DeprecatedReference: + Enabled: true Lint/DuplicateBranch: Enabled: true Lint/DuplicateMagicComment: @@ -232,10 +258,14 @@ Lint/LambdaWithoutLiteralBlock: Enabled: true Lint/LiteralAssignmentInCondition: Enabled: true +Lint/MisplacedMagicComment: + Enabled: true Lint/MissingSuper: Enabled: true Lint/MixedCaseRange: Enabled: true +Lint/NameTypo: + Enabled: true Lint/NoReturnInBeginEndBlocks: Enabled: true Lint/NonAtomicFileOperation: @@ -260,6 +290,8 @@ Lint/RequireRelativeSelfPath: Enabled: true Lint/SharedMutableDefault: Enabled: true +Lint/SuperArgumentMismatch: + Enabled: true Lint/SuppressedException: Enabled: true Lint/SuppressedExceptionInNumberConversion: @@ -278,6 +310,8 @@ Lint/UnifiedInteger: Enabled: true Lint/UnmodifiedReduceAccumulator: Enabled: true +Lint/UnreachablePatternBranch: + Enabled: true Lint/UnusedMethodArgument: Enabled: true Lint/UselessConstantScoping: @@ -468,6 +502,8 @@ RSpec/DescribeClass: Enabled: true RSpec/DescribedClass: Enabled: true +RSpec/DiscardedMatcher: + Enabled: true RSpec/DuplicatedMetadata: Enabled: true RSpec/EmptyExampleGroup: @@ -504,6 +540,8 @@ RSpec/LetSetup: Enabled: true RSpec/MatchArray: Enabled: true +RSpec/MatchWithSimpleRegex: + Enabled: true RSpec/MessageChain: Enabled: true RSpec/MessageSpies: @@ -570,14 +608,20 @@ RSpec/VoidExpect: Enabled: true RSpecRails/AvoidSetupHook: Enabled: true +RSpecRails/FileFixture: + Enabled: true RSpecRails/HaveHttpStatus: Enabled: true +RSpecRails/HttpStatusNameConsistency: + Enabled: true RSpecRails/InferredSpecType: Enabled: true RSpecRails/MinitestAssertions: Enabled: true RSpecRails/NegationBeValid: Enabled: true +RSpecRails/ReceivePerformLater: + Enabled: true RSpecRails/TravelAround: Enabled: true Security/CompoundHash: @@ -738,6 +782,8 @@ Style/RedundantInterpolationUnfreeze: Enabled: true Style/RedundantLineContinuation: Enabled: true +Style/RedundantMinMaxBy: + Enabled: true Style/RedundantRegexpArgument: Enabled: true Style/RedundantRegexpConstructor: @@ -754,6 +800,8 @@ Style/SafeNavigation: Enabled: true Style/SafeNavigationChainLength: Enabled: true +Style/SelectByRange: + Enabled: true Style/SelectByRegexp: Enabled: true Style/SendWithLiteralMethodName: @@ -772,8 +820,12 @@ Style/SuperWithArgsParentheses: Enabled: true Style/SwapValues: Enabled: true +Style/TallyMethod: + Enabled: true Style/TernaryParentheses: Enabled: true +Style/TimeNow: + Enabled: true Style/YAMLFileRead: Enabled: true diff --git a/spec/acceptance/managed_service_instance_spec.rb b/spec/acceptance/managed_service_instance_spec.rb index acad4afcba8..50200e5c230 100644 --- a/spec/acceptance/managed_service_instance_spec.rb +++ b/spec/acceptance/managed_service_instance_spec.rb @@ -67,7 +67,7 @@ module VCAP::CloudController parsed_response = Oj.load(last_response.body) expect(parsed_response).to include( 'error_code' => 'CF-ServiceInstanceWithInaccessiblePlanNotUpdateable', - 'description' => match(/Cannot update parameters of a service instance that belongs to inaccessible plan/) + 'description' => include('Cannot update parameters of a service instance that belongs to inaccessible plan') ) end end @@ -111,7 +111,7 @@ module VCAP::CloudController parsed_response = Oj.load(last_response.body) expect(parsed_response).to include( 'error_code' => 'CF-NotAuthorized', - 'description' => match(/You are not authorized to perform the requested action/) + 'description' => include('You are not authorized to perform the requested action') ) end end diff --git a/spec/api/documentation/job_api_spec.rb b/spec/api/documentation/job_api_spec.rb index 53a8786321c..d5399cb348b 100644 --- a/spec/api/documentation/job_api_spec.rb +++ b/spec/api/documentation/job_api_spec.rb @@ -55,7 +55,7 @@ def perform expect(parsed_response['entity']['error_details']).to include('error_code') expect(parsed_response['entity']['error_details']['code']).to eq(1001) - expect(parsed_response['entity']['error_details']['description']).to match(/arbitrary string/) + expect(parsed_response['entity']['error_details']['description']).to include('arbitrary string') expect(parsed_response['entity']['error_details']['error_code']).to eq('CF-MessageParseError') end end diff --git a/spec/isolated_specs/steno/codec_rfc3339_spec.rb b/spec/isolated_specs/steno/codec_rfc3339_spec.rb index 7b2ae948e03..cb8731a7637 100644 --- a/spec/isolated_specs/steno/codec_rfc3339_spec.rb +++ b/spec/isolated_specs/steno/codec_rfc3339_spec.rb @@ -18,12 +18,12 @@ it 'escapes newlines' do rec = make_record(message: "newline\ntest") - expect(codec.encode_record(rec)).to match(/newline\\ntest/) + expect(codec.encode_record(rec)).to include('newline\ntest') end it 'escapes carriage returns' do rec = make_record(message: "newline\rtest") - expect(codec.encode_record(rec)).to match(/newline\\rtest/) + expect(codec.encode_record(rec)).to include('newline\rtest') end it 'allows messages with valid encodings to pass through untouched' do @@ -35,7 +35,7 @@ it 'treats messages with invalid encodings as binary data' do msg = "HI\u2026".force_encoding('US-ASCII') rec = make_record(message: msg) - expect(codec.encode_record(rec)).to match(/HI\\\\xe2\\\\x80\\\\xa6/) + expect(codec.encode_record(rec)).to include('HI\\\\xe2\\\\x80\\\\xa6') end it 'encodes timestamps as UTC-formatted strings' do diff --git a/spec/isolated_specs/steno/unit/json_codec_spec.rb b/spec/isolated_specs/steno/unit/json_codec_spec.rb index d5414537e1a..6f6debb5757 100644 --- a/spec/isolated_specs/steno/unit/json_codec_spec.rb +++ b/spec/isolated_specs/steno/unit/json_codec_spec.rb @@ -17,12 +17,12 @@ it 'escapes newlines' do rec = make_record(message: "newline\ntest") - expect(codec.encode_record(rec)).to match(/newline\\ntest/) + expect(codec.encode_record(rec)).to include('newline\ntest') end it 'escapes carriage returns' do rec = make_record(message: "newline\rtest") - expect(codec.encode_record(rec)).to match(/newline\\rtest/) + expect(codec.encode_record(rec)).to include('newline\rtest') end it 'allows messages with valid encodings to pass through untouched' do @@ -34,7 +34,7 @@ it 'treats messages with invalid encodings as binary data' do msg = "HI\u2026".force_encoding('US-ASCII') rec = make_record(message: msg) - expect(codec.encode_record(rec)).to match(/HI\\\\xe2\\\\x80\\\\xa6/) + expect(codec.encode_record(rec)).to include('HI\\\\xe2\\\\x80\\\\xa6') end it 'does not use readable dates by default' do diff --git a/spec/isolated_specs/steno/unit/logger_io_spec.rb b/spec/isolated_specs/steno/unit/logger_io_spec.rb index a0ca39e141b..cd45c69c54e 100644 --- a/spec/isolated_specs/steno/unit/logger_io_spec.rb +++ b/spec/isolated_specs/steno/unit/logger_io_spec.rb @@ -24,7 +24,7 @@ it 'removes logger_io.rb from the callstack' do expect(Steno::Record).to receive(:new).and_wrap_original do |original_method, source, log_level, message, loc, data| - expect(loc[0]).not_to match(/logger_io\.rb/) + expect(loc[0]).not_to include('logger_io.rb') original_method.call(source, log_level, message, loc, data) end diff --git a/spec/isolated_specs/steno/unit/logger_spec.rb b/spec/isolated_specs/steno/unit/logger_spec.rb index d30e9b3947d..b7facc45212 100644 --- a/spec/isolated_specs/steno/unit/logger_spec.rb +++ b/spec/isolated_specs/steno/unit/logger_spec.rb @@ -81,7 +81,7 @@ it 'creates a record with logger.rb being removed from the callstack' do expect(Steno::Record).to receive(:new).and_wrap_original do |original_method, source, log_level, message, loc, data| - expect(loc[0]).not_to match(/logger\.rb/) + expect(loc[0]).not_to include('logger.rb') original_method.call(source, log_level, message, loc, data) end diff --git a/spec/request/internal/metrics_spec.rb b/spec/request/internal/metrics_spec.rb index cfa882b5f8d..c7011c076da 100644 --- a/spec/request/internal/metrics_spec.rb +++ b/spec/request/internal/metrics_spec.rb @@ -80,8 +80,8 @@ it 'includes job queue length metric labelled for each queue' do get '/internal/v4/metrics', nil - expect(last_response.body).to match(/cc_job_queues_length_total{queue="cc_api_0"} 1\.0/) - expect(last_response.body).to match(/cc_job_queues_length_total{queue="cc_generic"} 1\.0/) + expect(last_response.body).to include('cc_job_queues_length_total{queue="cc_api_0"} 1.0') + expect(last_response.body).to include('cc_job_queues_length_total{queue="cc_generic"} 1.0') end end @@ -104,8 +104,8 @@ it 'includes job queue load metric labelled for each queue' do get '/internal/v4/metrics', nil - expect(last_response.body).to match(/cc_job_queues_load_total{queue="cc_api_0"} 1\.0/) - expect(last_response.body).to match(/cc_job_queues_load_total{queue="cc_generic"} 1\.0/) + expect(last_response.body).to include('cc_job_queues_load_total{queue="cc_api_0"} 1.0') + expect(last_response.body).to include('cc_job_queues_load_total{queue="cc_generic"} 1.0') end end @@ -125,8 +125,8 @@ it 'reports failed job count' do get '/internal/v4/metrics', nil - expect(last_response.body).to match(/cc_failed_jobs_total{queue="cc_api_0"} 1\.0/) - expect(last_response.body).to match(/cc_failed_jobs_total{queue="cc_generic"} 1\.0/) + expect(last_response.body).to include('cc_failed_jobs_total{queue="cc_api_0"} 1.0') + expect(last_response.body).to include('cc_failed_jobs_total{queue="cc_generic"} 1.0') end end diff --git a/spec/request/organizations_spec.rb b/spec/request/organizations_spec.rb index 0c914aafa5a..dc7956cb912 100644 --- a/spec/request/organizations_spec.rb +++ b/spec/request/organizations_spec.rb @@ -838,13 +838,13 @@ module VCAP::CloudController it 'returns a 400 when the label selector is missing a value' do get "#{base_link}?label_selector", nil, admin_header expect(last_response.status).to eq(400) - expect(parsed_response['errors'].first['detail']).to match(/Missing label_selector value/) + expect(parsed_response['errors'].first['detail']).to include('Missing label_selector value') end it "returns a 400 when the label selector's value is invalid" do get "#{base_link}?label_selector=!", nil, admin_header expect(last_response.status).to eq(400) - expect(parsed_response['errors'].first['detail']).to match(/Invalid label_selector value/) + expect(parsed_response['errors'].first['detail']).to include('Invalid label_selector value') end end end diff --git a/spec/request/service_plan_visibility_spec.rb b/spec/request/service_plan_visibility_spec.rb index 5b391834ee8..00b47a393d9 100644 --- a/spec/request/service_plan_visibility_spec.rb +++ b/spec/request/service_plan_visibility_spec.rb @@ -320,7 +320,7 @@ it 'cannot be updated' do api_call.call(admin_headers) expect(last_response).to have_status_code(422) - expect(parsed_response['errors'][0]['detail']).to match(/cannot update plans with visibility type 'space'/) + expect(parsed_response['errors'][0]['detail']).to include("cannot update plans with visibility type 'space'") end end @@ -345,7 +345,7 @@ api_call.call(admin_headers) expect(last_response).to have_status_code(400) - expect(parsed_response['errors'][0]['detail']).to match(/must be one of 'public', 'admin', 'organization'/) + expect(parsed_response['errors'][0]['detail']).to include("must be one of 'public', 'admin', 'organization'") end end @@ -506,7 +506,7 @@ post api_url, body, admin_headers expect(last_response).to have_status_code(422) - expect(parsed_response['errors'][0]['detail']).to match(/cannot update plans with visibility type 'space'/) + expect(parsed_response['errors'][0]['detail']).to include("cannot update plans with visibility type 'space'") end end diff --git a/spec/request/service_plans_spec.rb b/spec/request/service_plans_spec.rb index 72b746ef801..6fb9610638c 100644 --- a/spec/request/service_plans_spec.rb +++ b/spec/request/service_plans_spec.rb @@ -749,7 +749,7 @@ delete "/v3/service_plans/#{service_plan.guid}", {}, admin_headers expect(last_response).to have_status_code(422) - expect(parsed_response['errors'][0]['detail']).to match(/Please delete the service_instances associations for your service_plans/) + expect(parsed_response['errors'][0]['detail']).to include('Please delete the service_instances associations for your service_plans') end end diff --git a/spec/request/v2/apps_spec.rb b/spec/request/v2/apps_spec.rb index d30c9c8998f..813f546f914 100644 --- a/spec/request/v2/apps_spec.rb +++ b/spec/request/v2/apps_spec.rb @@ -1779,7 +1779,7 @@ def make_actual_lrp(instance_guid:, index:, state:, error:, since:) # The response includes process 'state' (STARTED/STOPPED) which is different from stack 'state' # We verify stack state is not exposed by checking it's not in the stack-related fields expect(parsed_response['entity']['stack_guid']).to be_present - expect(parsed_response.to_s).not_to match(/DEPRECATED/) + expect(parsed_response.to_s).not_to include('DEPRECATED') end end diff --git a/spec/request/v2/auth_spec.rb b/spec/request/v2/auth_spec.rb index 831422df5a1..d5e25e42147 100644 --- a/spec/request/v2/auth_spec.rb +++ b/spec/request/v2/auth_spec.rb @@ -22,7 +22,7 @@ get '/v2/organizations', nil, headers_for(user, expired: true) expect(last_response.status).to eq 401 - expect(last_response.body).to match(/InvalidAuthToken/) + expect(last_response.body).to include('InvalidAuthToken') end end diff --git a/spec/unit/actions/space_delete_spec.rb b/spec/unit/actions/space_delete_spec.rb index f09e6c59980..5e850d14c24 100644 --- a/spec/unit/actions/space_delete_spec.rb +++ b/spec/unit/actions/space_delete_spec.rb @@ -278,7 +278,7 @@ module VCAP::CloudController errors = space_delete.delete(Space.where(guid: space.guid)) expect(errors.map(&:name)).to include('SpaceDeletionFailed', 'SpaceDeletionFailed') - expect(errors.map(&:message).join).to match(/service instance fake-name is in progress/) + expect(errors.map(&:message).join).to include('service instance fake-name is in progress') expect(errors.map(&:message).join).to match(/associated service instances: #{broker_to_be_deleted.name}/) end end diff --git a/spec/unit/controllers/base/base_controller_spec.rb b/spec/unit/controllers/base/base_controller_spec.rb index f99a658d869..feb7a19de5f 100644 --- a/spec/unit/controllers/base/base_controller_spec.rb +++ b/spec/unit/controllers/base/base_controller_spec.rb @@ -115,7 +115,7 @@ def self.translate_validation_exception(_error, _attrs) it 'processes BlobstoreError using translate_validation_exception' do get '/test_blobstore_error' expect(decoded_response['code']).to eq(150_007) - expect(decoded_response['description']).to match(/three retries/) + expect(decoded_response['description']).to include('three retries') end it 'returns InvalidRequest when Sequel HookFailed error occurs' do @@ -189,7 +189,7 @@ def self.translate_validation_exception(_error, _attrs) it 'returns an invalid token error to the user' do get '/test_endpoint' expect(last_response.status).to eq 401 - expect(last_response.body).to match(/InvalidAuthToken/) + expect(last_response.body).to include('InvalidAuthToken') end end end diff --git a/spec/unit/controllers/base/model_controller_spec.rb b/spec/unit/controllers/base/model_controller_spec.rb index 3b581768369..0ca6d4b1323 100644 --- a/spec/unit/controllers/base/model_controller_spec.rb +++ b/spec/unit/controllers/base/model_controller_spec.rb @@ -128,7 +128,7 @@ module VCAP::CloudController set_current_user(user, scopes: ['bogus.scope']) post '/v2/test_models', Oj.dump({ required_attr: true, unique_value: 'foobar' }) expect(decoded_response['code']).to eq(10_007) - expect(decoded_response['description']).to match(/lacks the necessary scopes/) + expect(decoded_response['description']).to include('lacks the necessary scopes') end end @@ -139,7 +139,7 @@ module VCAP::CloudController end.not_to(change(TestModel, :count)) expect(decoded_response['code']).to eq(10_003) - expect(decoded_response['description']).to match(/not authorized/) + expect(decoded_response['description']).to include('not authorized') end it 'returns the right values on a successful create' do @@ -199,7 +199,7 @@ module VCAP::CloudController get "/v2/test_models/#{model.guid}" expect(decoded_response['code']).to eq(10_003) - expect(decoded_response['description']).to match(/not authorized/) + expect(decoded_response['description']).to include('not authorized') end it 'returns the serialized object if access is validated' do @@ -248,7 +248,7 @@ module VCAP::CloudController expect(model.reload.unique_value).not_to eq('something') expect(decoded_response['code']).to eq(10_003) - expect(decoded_response['description']).to match(/not authorized/) + expect(decoded_response['description']).to include('not authorized') end it 'prevents other processes from updating the same row until the transaction finishes' do @@ -356,7 +356,7 @@ def run_delayed_job delete "/v2/test_models/#{model.guid}?#{query_params}" expect(last_response.status).to eq(400) expect(decoded_response['code']).to eq(10_006) - expect(decoded_response['description']).to match(/associations/) + expect(decoded_response['description']).to include('associations') end end end @@ -540,21 +540,21 @@ def run_delayed_job get '/v2/test_models/99999' expect(last_response.status).to eq(404) expect(decoded_response['code']).to eq 999_999_999 - expect(decoded_response['description']).to match(/Test Model Not Found/) + expect(decoded_response['description']).to include('Test Model Not Found') end it 'returns not found for updates' do put '/v2/test_models/99999', '{}' expect(last_response.status).to eq(404) expect(decoded_response['code']).to eq 999_999_999 - expect(decoded_response['description']).to match(/Test Model Not Found/) + expect(decoded_response['description']).to include('Test Model Not Found') end it 'returns not found for deletes' do delete '/v2/test_models/99999' expect(last_response.status).to eq(404) expect(decoded_response['code']).to eq 999_999_999 - expect(decoded_response['description']).to match(/Test Model Not Found/) + expect(decoded_response['description']).to include('Test Model Not Found') end end @@ -572,7 +572,7 @@ def run_delayed_job post '/v2/test_models', '{}' expect(last_response.status).to eq(400) expect(decoded_response['code']).to eq 1001 - expect(decoded_response['description']).to match(/invalid/) + expect(decoded_response['description']).to include('invalid') expect(last_response.location).to be_nil end @@ -581,7 +581,7 @@ def run_delayed_job post '/v2/test_models', Oj.dump({ required_attr: true, unique_value: 'unique' }) expect(last_response.status).to eq(400) expect(decoded_response['code']).to eq 999_999_998 - expect(decoded_response['description']).to match(/Validation Error/) + expect(decoded_response['description']).to include('Validation Error') end it 'returns 400 error when validation fails on update' do @@ -590,7 +590,7 @@ def run_delayed_job put "/v2/test_models/#{test_model.guid}", Oj.dump({ unique_value: 'unique' }) expect(last_response.status).to eq(400) expect(decoded_response['code']).to eq 999_999_998 - expect(decoded_response['description']).to match(/Validation Error/) + expect(decoded_response['description']).to include('Validation Error') end end end diff --git a/spec/unit/controllers/internal/app_crashed_controller_spec.rb b/spec/unit/controllers/internal/app_crashed_controller_spec.rb index 1fbd958e9b3..944096524a6 100644 --- a/spec/unit/controllers/internal/app_crashed_controller_spec.rb +++ b/spec/unit/controllers/internal/app_crashed_controller_spec.rb @@ -26,7 +26,7 @@ module VCAP::CloudController post url, 'this is not json' expect(last_response.status).to eq(400) - expect(last_response.body).to match(/MessageParseError/) + expect(last_response.body).to include('MessageParseError') end end end @@ -78,7 +78,7 @@ module VCAP::CloudController post url, Oj.dump(crashed_request) expect(last_response.status).to eq(404) - expect(last_response.body).to match(/ProcessNotFound/) + expect(last_response.body).to include('ProcessNotFound') end end end diff --git a/spec/unit/controllers/internal/app_readiness_changed_controller_spec.rb b/spec/unit/controllers/internal/app_readiness_changed_controller_spec.rb index 12a25708122..6df055e496c 100644 --- a/spec/unit/controllers/internal/app_readiness_changed_controller_spec.rb +++ b/spec/unit/controllers/internal/app_readiness_changed_controller_spec.rb @@ -24,7 +24,7 @@ module VCAP::CloudController post url, 'this is not json' expect(last_response.status).to eq(400) - expect(last_response.body).to match(/MessageParseError/) + expect(last_response.body).to include('MessageParseError') end end end @@ -74,7 +74,7 @@ module VCAP::CloudController post url, Oj.dump(readiness_changed_request) expect(last_response.status).to eq(404) - expect(last_response.body).to match(/ProcessNotFound/) + expect(last_response.body).to include('ProcessNotFound') end end end diff --git a/spec/unit/controllers/internal/app_rescheduling_controller_spec.rb b/spec/unit/controllers/internal/app_rescheduling_controller_spec.rb index b1d06c9a899..bded179aaf7 100644 --- a/spec/unit/controllers/internal/app_rescheduling_controller_spec.rb +++ b/spec/unit/controllers/internal/app_rescheduling_controller_spec.rb @@ -24,7 +24,7 @@ module VCAP::CloudController post url, 'this is not json' expect(last_response.status).to eq(400) - expect(last_response.body).to match(/MessageParseError/) + expect(last_response.body).to include('MessageParseError') end end end @@ -56,7 +56,7 @@ module VCAP::CloudController post url, Oj.dump(rescheduling_request) expect(last_response.status).to eq(404) - expect(last_response.body).to match(/ProcessNotFound/) + expect(last_response.body).to include('ProcessNotFound') end end end diff --git a/spec/unit/controllers/internal/staging_completion_controller_spec.rb b/spec/unit/controllers/internal/staging_completion_controller_spec.rb index 6dd96d167a5..231b92839b3 100644 --- a/spec/unit/controllers/internal/staging_completion_controller_spec.rb +++ b/spec/unit/controllers/internal/staging_completion_controller_spec.rb @@ -91,7 +91,7 @@ module VCAP::CloudController post url, Oj.dump(staging_response) expect(last_response.status).to eq(524) - expect(last_response.body).to match(/JobTimeout/) + expect(last_response.body).to include('JobTimeout') end context 'when receiving the callback directly from BBS' do @@ -203,7 +203,7 @@ module VCAP::CloudController post url, Oj.dump(staging_response) expect(last_response.status).to eq(524) - expect(last_response.body).to match(/JobTimeout/) + expect(last_response.body).to include('JobTimeout') end it 'propagates other errors from staging_response' do @@ -242,7 +242,7 @@ module VCAP::CloudController it 'returns 404' do post url, Oj.dump(staging_response) expect(last_response.status).to eq(404) - expect(last_response.body).to match(/Build not found/) + expect(last_response.body).to include('Build not found') end end @@ -261,7 +261,7 @@ module VCAP::CloudController post url, 'this is not json' expect(last_response.status).to eq(400) - expect(last_response.body).to match(/MessageParseError/) + expect(last_response.body).to include('MessageParseError') end end end diff --git a/spec/unit/controllers/internal/task_completion_controller_spec.rb b/spec/unit/controllers/internal/task_completion_controller_spec.rb index e664ebc53db..810a3791539 100644 --- a/spec/unit/controllers/internal/task_completion_controller_spec.rb +++ b/spec/unit/controllers/internal/task_completion_controller_spec.rb @@ -55,7 +55,7 @@ module VCAP::CloudController post url, Oj.dump(task_response) expect(last_response.status).to eq(404) - expect(last_response.body).to match(/NotFound/) + expect(last_response.body).to include('NotFound') end end @@ -67,7 +67,7 @@ module VCAP::CloudController post url, Oj.dump(task_response) expect(last_response.status).to eq(400) - expect(last_response.body).to match(/InvalidRequest/) + expect(last_response.body).to include('InvalidRequest') end end @@ -78,7 +78,7 @@ module VCAP::CloudController post url, Oj.dump(task_response) expect(last_response.status).to eq(400) - expect(last_response.body).to match(/InvalidRequest/) + expect(last_response.body).to include('InvalidRequest') end end end @@ -89,7 +89,7 @@ module VCAP::CloudController post url, 'this is not json' expect(last_response.status).to eq(400) - expect(last_response.body).to match(/MessageParseError/) + expect(last_response.body).to include('MessageParseError') end end @@ -101,7 +101,7 @@ module VCAP::CloudController post url, Oj.dump(task_response) expect(last_response.status).to eq(400) - expect(last_response.body).to match(/InvalidRequest/) + expect(last_response.body).to include('InvalidRequest') end end end diff --git a/spec/unit/controllers/runtime/app_bits_upload_controller_spec.rb b/spec/unit/controllers/runtime/app_bits_upload_controller_spec.rb index e1a10868c16..bc9f2861d41 100644 --- a/spec/unit/controllers/runtime/app_bits_upload_controller_spec.rb +++ b/spec/unit/controllers/runtime/app_bits_upload_controller_spec.rb @@ -60,8 +60,8 @@ def make_request it 'returns FeatureDisabled and does not upload' do expect(last_response.status).to eq(403) - expect(decoded_response['error_code']).to match(/FeatureDisabled/) - expect(decoded_response['description']).to match(/app_bits_upload/) + expect(decoded_response['error_code']).to include('FeatureDisabled') + expect(decoded_response['description']).to include('app_bits_upload') expect(process.package_hash).to be_nil end @@ -181,7 +181,7 @@ def make_request make_request expect(last_response.status).to eq(400) - expect(decoded_response['error_code']).to match(/AppBitsUploadInvalid/) + expect(decoded_response['error_code']).to include('AppBitsUploadInvalid') end end @@ -409,8 +409,8 @@ def make_request make_request expect(last_response.status).to eq(422) - expect(decoded_response['error_code']).to match(/UnprocessableEntity/) - expect(decoded_response['description']).to match(/cannot upload bits to a docker app/) + expect(decoded_response['error_code']).to include('UnprocessableEntity') + expect(decoded_response['description']).to include('cannot upload bits to a docker app') end end end @@ -447,8 +447,8 @@ class << self expect(last_response.status).to eq(400) - expect(decoded_response['error_code']).to match(/AppBitsCopyInvalid/) - expect(decoded_response['description']).to match(/missing source_app_guid/) + expect(decoded_response['error_code']).to include('AppBitsCopyInvalid') + expect(decoded_response['description']).to include('missing source_app_guid') end end diff --git a/spec/unit/controllers/runtime/apps_controller_spec.rb b/spec/unit/controllers/runtime/apps_controller_spec.rb index 2fe9ca91045..5ade57c2431 100644 --- a/spec/unit/controllers/runtime/apps_controller_spec.rb +++ b/spec/unit/controllers/runtime/apps_controller_spec.rb @@ -466,8 +466,8 @@ module VCAP::CloudController post '/v2/apps', Oj.dump(request) expect(last_response.status).to eq(422) - expect(last_response.body).to match(/UnprocessableEntity/) - expect(last_response.body).to match(/oops/) + expect(last_response.body).to include('UnprocessableEntity') + expect(last_response.body).to include('oops') end end end @@ -718,8 +718,8 @@ def update_app it 'fails with the proper error code and message' do put "/v2/apps/#{process.app.guid}", '{ "memory": 2 }' expect(last_response.status).to eq(403) - expect(decoded_response['error_code']).to match(/FeatureDisabled/) - expect(decoded_response['description']).to match(/app_scaling/) + expect(decoded_response['error_code']).to include('FeatureDisabled') + expect(decoded_response['description']).to include('app_scaling') end end end @@ -1087,8 +1087,8 @@ def update_app put "/v2/apps/#{process.app.guid}", Oj.dump({ docker_credentials: { username: 'username', password: 'foo' } }) expect(last_response.status).to eq(422) - expect(last_response.body).to match(/UnprocessableEntity/) - expect(last_response.body).to match(/oops/) + expect(last_response.body).to include('UnprocessableEntity') + expect(last_response.body).to include('oops') end end end @@ -2010,7 +2010,7 @@ def delete_app put "/v2/apps/#{stopped_process.app.guid}", Oj.dump(state: 'STARTED') expect(last_response.status).to eq(400) - expect(last_response.body).to match(/Docker support has not been enabled/) + expect(last_response.body).to include('Docker support has not been enabled') expect(decoded_response['code']).to eq(320_003) end @@ -2208,7 +2208,7 @@ def delete_app put "/v2/apps/#{process.app.guid}", Oj.dump(instances: -1) expect(last_response.status).to eq(400) - expect(last_response.body).to match(/instances less than 0/) + expect(last_response.body).to include('instances less than 0') expect(decoded_response['code']).to eq(100_001) end @@ -2216,7 +2216,7 @@ def delete_app put "/v2/apps/#{process.app.guid}", Oj.dump(state: 'mississippi') expect(last_response.status).to eq(400) - expect(last_response.body).to match(/Invalid app state provided/) + expect(last_response.body).to include('Invalid app state provided') expect(decoded_response['code']).to eq(100_001) end diff --git a/spec/unit/controllers/runtime/buildpack_bits_controller_spec.rb b/spec/unit/controllers/runtime/buildpack_bits_controller_spec.rb index 9d80227fc4c..e269e0a35bd 100644 --- a/spec/unit/controllers/runtime/buildpack_bits_controller_spec.rb +++ b/spec/unit/controllers/runtime/buildpack_bits_controller_spec.rb @@ -177,7 +177,7 @@ module VCAP::CloudController expect(last_response.status).to be 400 json = Oj.load(last_response.body) expect(json['code']).to eq(290_002) - expect(json['description']).to match(/a filename must be specified/) + expect(json['description']).to include('a filename must be specified') end it 'requires a file to be uploaded' do @@ -186,7 +186,7 @@ module VCAP::CloudController expect(last_response.status).to eq(400) json = Oj.load(last_response.body) expect(json['code']).to eq(290_002) - expect(json['description']).to match(/a file must be provided/) + expect(json['description']).to include('a file must be provided') end it 'does not allow non-zip files' do @@ -197,7 +197,7 @@ module VCAP::CloudController expect(last_response.status).to be 400 json = Oj.load(last_response.body) expect(json['code']).to eq(290_002) - expect(json['description']).to match(/only zip files allowed/) + expect(json['description']).to include('only zip files allowed') end it 'removes the old buildpack binary when a new one is uploaded' do @@ -318,7 +318,7 @@ module VCAP::CloudController allow_any_instance_of(CloudController::Blobstore::LocalBlob).to receive(:public_download_url).and_return('http://blobstore.example.com/cc-buildpacks/download') get "/v2/buildpacks/#{test_buildpack.guid}/download" expect(last_response.status).to eq(302) - expect(last_response.headers['Location']).to match(/cc-buildpacks/) + expect(last_response.headers['Location']).to include('cc-buildpacks') end it 'returns 404 for missing bits' do diff --git a/spec/unit/controllers/runtime/buildpacks_controller_spec.rb b/spec/unit/controllers/runtime/buildpacks_controller_spec.rb index 95daca9bf95..e733df5ec54 100644 --- a/spec/unit/controllers/runtime/buildpacks_controller_spec.rb +++ b/spec/unit/controllers/runtime/buildpacks_controller_spec.rb @@ -49,7 +49,7 @@ def ordered_buildpacks it 'does not include order-by in the next_url' do get '/v2/buildpacks?results-per-page=1' - expect(parsed_response['next_url']).not_to match(/order-by=position/) + expect(parsed_response['next_url']).not_to include('order-by=position') end end diff --git a/spec/unit/controllers/runtime/domains_controller_spec.rb b/spec/unit/controllers/runtime/domains_controller_spec.rb index 3a5097c7aba..ec3ab404731 100644 --- a/spec/unit/controllers/runtime/domains_controller_spec.rb +++ b/spec/unit/controllers/runtime/domains_controller_spec.rb @@ -229,7 +229,7 @@ module VCAP::CloudController domains[guid] = link end - expect(domains[private_domain.guid]).to match(/private_domains/) + expect(domains[private_domain.guid]).to include('private_domains') end end @@ -250,7 +250,7 @@ module VCAP::CloudController domains[guid] = link end - expect(domains[private_domain.guid]).to match(/private_domains/) + expect(domains[private_domain.guid]).to include('private_domains') end end @@ -299,8 +299,8 @@ module VCAP::CloudController post '/v2/domains', request_body expect(last_response.status).to eq(403) - expect(decoded_response['error_code']).to match(/FeatureDisabled/) - expect(decoded_response['description']).to match(/private_domain_creation/) + expect(decoded_response['error_code']).to include('FeatureDisabled') + expect(decoded_response['description']).to include('private_domain_creation') end end end diff --git a/spec/unit/controllers/runtime/environment_variable_groups_controller_spec.rb b/spec/unit/controllers/runtime/environment_variable_groups_controller_spec.rb index 4ac92588d7b..20872c9dbcd 100644 --- a/spec/unit/controllers/runtime/environment_variable_groups_controller_spec.rb +++ b/spec/unit/controllers/runtime/environment_variable_groups_controller_spec.rb @@ -11,7 +11,7 @@ module VCAP::CloudController get '/v2/config/environment_variable_groups/flibble' expect(last_response.status).to eq(404) - expect(decoded_response['error_code']).to match(/CF-NotFound/) + expect(decoded_response['error_code']).to include('CF-NotFound') end end @@ -66,7 +66,7 @@ module VCAP::CloudController set_current_user_as_admin put '/v2/config/environment_variable_groups/flibble', '{}' expect(last_response.status).to eq(404) - expect(decoded_response['error_code']).to match(/CF-NotFound/) + expect(decoded_response['error_code']).to include('CF-NotFound') end end @@ -100,7 +100,7 @@ module VCAP::CloudController put '/v2/config/environment_variable_groups/staging', 'jam sandwich' expect(last_response.status).to eq(400) expect(decoded_response['error_code']).to eq('CF-MessageParseError') - expect(decoded_response['description']).to match(/Request invalid due to parse error/) + expect(decoded_response['description']).to include('Request invalid due to parse error') end it 'does not update the group' do @@ -149,7 +149,7 @@ module VCAP::CloudController put '/v2/config/environment_variable_groups/running', req_body expect(last_response.status).to eq(400) expect(decoded_response['error_code']).to eq('CF-MessageParseError') - expect(decoded_response['description']).to match(/Request invalid due to parse error/) + expect(decoded_response['description']).to include('Request invalid due to parse error') end it 'does not update the group' do @@ -171,7 +171,7 @@ module VCAP::CloudController put '/v2/config/environment_variable_groups/running', req_body expect(last_response.status).to eq(400), last_response.body expect(decoded_response['error_code']).to eq('CF-EnvironmentVariableGroupInvalid') - expect(decoded_response['description']).to match(/VCAP_/) + expect(decoded_response['description']).to include('VCAP_') end it 'does not update the group' do diff --git a/spec/unit/controllers/runtime/feature_flags_controller_spec.rb b/spec/unit/controllers/runtime/feature_flags_controller_spec.rb index 7bc0f52d456..78445786dc8 100644 --- a/spec/unit/controllers/runtime/feature_flags_controller_spec.rb +++ b/spec/unit/controllers/runtime/feature_flags_controller_spec.rb @@ -41,8 +41,8 @@ module VCAP::CloudController put '/v2/config/feature_flags/bogus', {} expect(last_response.status).to eq(404) - expect(decoded_response['description']).to match(/feature flag could not be found/) - expect(decoded_response['error_code']).to match(/FeatureFlagNotFound/) + expect(decoded_response['description']).to include('feature flag could not be found') + expect(decoded_response['error_code']).to include('FeatureFlagNotFound') end end @@ -51,8 +51,8 @@ module VCAP::CloudController put '/v2/config/feature_flags/user_org_creation', Oj.dump({ enabled: nil }) expect(last_response.status).to eq(400) - expect(decoded_response['description']).to match(/feature flag is invalid/) - expect(decoded_response['error_code']).to match(/FeatureFlagInvalid/) + expect(decoded_response['description']).to include('feature flag is invalid') + expect(decoded_response['error_code']).to include('FeatureFlagInvalid') end end end @@ -63,8 +63,8 @@ module VCAP::CloudController put '/v2/config/feature_flags/user_org_creation', Oj.dump({ enabled: true }) expect(last_response.status).to eq(403) - expect(decoded_response['description']).to match(/not authorized/) - expect(decoded_response['error_code']).to match(/NotAuthorized/) + expect(decoded_response['description']).to include('not authorized') + expect(decoded_response['error_code']).to include('NotAuthorized') end end end @@ -193,8 +193,8 @@ module VCAP::CloudController get '/v2/config/feature_flags/bogus-flag' expect(last_response.status).to eq(404) - expect(decoded_response['description']).to match(/feature flag could not be found/) - expect(decoded_response['error_code']).to match(/FeatureFlagNotFound/) + expect(decoded_response['description']).to include('feature flag could not be found') + expect(decoded_response['error_code']).to include('FeatureFlagNotFound') end end end diff --git a/spec/unit/controllers/runtime/jobs_controller_spec.rb b/spec/unit/controllers/runtime/jobs_controller_spec.rb index eaa0d63cd60..0b34eefe986 100644 --- a/spec/unit/controllers/runtime/jobs_controller_spec.rb +++ b/spec/unit/controllers/runtime/jobs_controller_spec.rb @@ -15,7 +15,7 @@ module VCAP::CloudController set_current_user(user, scopes: ['cloud_controller.write']) get "/v2/jobs/#{job_request_id}" expect(last_response.status).to eq(403) - expect(last_response.body).to match(/InsufficientScope/) + expect(last_response.body).to include('InsufficientScope') end end diff --git a/spec/unit/controllers/runtime/organizations_controller_spec.rb b/spec/unit/controllers/runtime/organizations_controller_spec.rb index 25e9eaf626f..77c98d32a2c 100644 --- a/spec/unit/controllers/runtime/organizations_controller_spec.rb +++ b/spec/unit/controllers/runtime/organizations_controller_spec.rb @@ -175,7 +175,7 @@ module VCAP::CloudController }) expect(last_response.status).to eq(403) - expect(decoded_response['error_code']).to match(/CF-NotAuthorized/) + expect(decoded_response['error_code']).to include('CF-NotAuthorized') end end @@ -276,7 +276,7 @@ module VCAP::CloudController delete "/v2/organizations/#{org.guid}/default_isolation_segment" expect(last_response.status).to eq(403) - expect(decoded_response['error_code']).to match(/CF-NotAuthorized/) + expect(decoded_response['error_code']).to include('CF-NotAuthorized') end end @@ -374,7 +374,7 @@ module VCAP::CloudController post '/v2/organizations', Oj.dump({ name: 'my-org-name' }) expect(last_response.status).to eq(403) - expect(decoded_response['error_code']).to match(/CF-NotAuthorized/) + expect(decoded_response['error_code']).to include('CF-NotAuthorized') end end diff --git a/spec/unit/controllers/runtime/private_domains_controller_spec.rb b/spec/unit/controllers/runtime/private_domains_controller_spec.rb index dd72e462624..7edb8a54e21 100644 --- a/spec/unit/controllers/runtime/private_domains_controller_spec.rb +++ b/spec/unit/controllers/runtime/private_domains_controller_spec.rb @@ -48,8 +48,8 @@ module VCAP::CloudController post '/v2/private_domains', request_body expect(last_response.status).to eq(403) - expect(decoded_response['error_code']).to match(/FeatureDisabled/) - expect(decoded_response['description']).to match(/private_domain_creation/) + expect(decoded_response['error_code']).to include('FeatureDisabled') + expect(decoded_response['description']).to include('private_domain_creation') end end end diff --git a/spec/unit/controllers/runtime/resource_matches_controller_spec.rb b/spec/unit/controllers/runtime/resource_matches_controller_spec.rb index 1a30b2c18e1..8c82d3a8386 100644 --- a/spec/unit/controllers/runtime/resource_matches_controller_spec.rb +++ b/spec/unit/controllers/runtime/resource_matches_controller_spec.rb @@ -48,7 +48,7 @@ def resource_match_request(verb, path, matches, non_matches) put '/v2/resource_match', 'invalid json' expect(last_response.status).to eq(400) - expect(last_response.body).to match(/MessageParseError/) + expect(last_response.body).to include('MessageParseError') end end @@ -59,7 +59,7 @@ def resource_match_request(verb, path, matches, non_matches) put '/v2/resource_match', 'null' expect(last_response.status).to eq(422) - expect(last_response.body).to match(/UnprocessableEntity/) + expect(last_response.body).to include('UnprocessableEntity') expect(last_response.body).to match(/must be an array./) end end @@ -84,8 +84,8 @@ def resource_match_request(verb, path, matches, non_matches) put '/v2/resource_match', '[]' expect(last_response.status).to eq(403) - expect(decoded_response['error_code']).to match(/FeatureDisabled/) - expect(decoded_response['description']).to match(/Feature Disabled/) + expect(decoded_response['error_code']).to include('FeatureDisabled') + expect(decoded_response['description']).to include('Feature Disabled') end end diff --git a/spec/unit/controllers/runtime/restages_controller_spec.rb b/spec/unit/controllers/runtime/restages_controller_spec.rb index fd1df26c613..293dbcf0a88 100644 --- a/spec/unit/controllers/runtime/restages_controller_spec.rb +++ b/spec/unit/controllers/runtime/restages_controller_spec.rb @@ -119,7 +119,7 @@ module VCAP::CloudController expect(last_response.status).to eq(404) parsed_response = Oj.load(last_response.body) expect(parsed_response['code']).to eq(100_004) - expect(parsed_response['description']).to match(/The app could not be found:/) + expect(parsed_response['description']).to include('The app could not be found:') end end diff --git a/spec/unit/controllers/runtime/routes_controller_spec.rb b/spec/unit/controllers/runtime/routes_controller_spec.rb index 0dc31318bd7..978342c5793 100644 --- a/spec/unit/controllers/runtime/routes_controller_spec.rb +++ b/spec/unit/controllers/runtime/routes_controller_spec.rb @@ -1588,7 +1588,7 @@ module VCAP::CloudController put "/v2/routes/#{route.guid}/apps/#{process.app.guid}", nil expect(last_response.status).to eq(400) - expect(decoded_response['description']).to match(/The requested app relation is invalid: the app and route must belong to the same space/) + expect(decoded_response['description']).to include('The requested app relation is invalid: the app and route must belong to the same space') expect(route.reload.apps).to be_empty end diff --git a/spec/unit/controllers/runtime/security_group_running_defaults_controller_spec.rb b/spec/unit/controllers/runtime/security_group_running_defaults_controller_spec.rb index 453f4dad017..07201cd9d8a 100644 --- a/spec/unit/controllers/runtime/security_group_running_defaults_controller_spec.rb +++ b/spec/unit/controllers/runtime/security_group_running_defaults_controller_spec.rb @@ -47,8 +47,8 @@ module VCAP::CloudController it 'returns a 400 when the security group does not exist' do put '/v2/config/running_security_groups/bogus', {} expect(last_response.status).to eq(400) - expect(decoded_response['description']).to match(/security group could not be found/) - expect(decoded_response['error_code']).to match(/SecurityGroupRunningDefaultInvalid/) + expect(decoded_response['description']).to include('security group could not be found') + expect(decoded_response['error_code']).to include('SecurityGroupRunningDefaultInvalid') end end @@ -75,8 +75,8 @@ module VCAP::CloudController it 'returns a 400 when the security group does not exist' do delete '/v2/config/running_security_groups/bogus' expect(last_response.status).to eq(400) - expect(decoded_response['description']).to match(/security group could not be found/) - expect(decoded_response['error_code']).to match(/SecurityGroupRunningDefaultInvalid/) + expect(decoded_response['description']).to include('security group could not be found') + expect(decoded_response['error_code']).to include('SecurityGroupRunningDefaultInvalid') end end end diff --git a/spec/unit/controllers/runtime/security_group_staging_defaults_controller_spec.rb b/spec/unit/controllers/runtime/security_group_staging_defaults_controller_spec.rb index 508d88cc991..6edad74293d 100644 --- a/spec/unit/controllers/runtime/security_group_staging_defaults_controller_spec.rb +++ b/spec/unit/controllers/runtime/security_group_staging_defaults_controller_spec.rb @@ -38,8 +38,8 @@ module VCAP::CloudController put '/v2/config/staging_security_groups/bogus', {} expect(last_response.status).to eq(400) - expect(decoded_response['description']).to match(/security group could not be found/) - expect(decoded_response['error_code']).to match(/SecurityGroupStagingDefaultInvalid/) + expect(decoded_response['description']).to include('security group could not be found') + expect(decoded_response['error_code']).to include('SecurityGroupStagingDefaultInvalid') end end @@ -58,8 +58,8 @@ module VCAP::CloudController it 'returns a 400 when the security group does not exist' do delete '/v2/config/staging_security_groups/bogus' expect(last_response.status).to eq(400) - expect(decoded_response['description']).to match(/security group could not be found/) - expect(decoded_response['error_code']).to match(/SecurityGroupStagingDefaultInvalid/) + expect(decoded_response['description']).to include('security group could not be found') + expect(decoded_response['error_code']).to include('SecurityGroupStagingDefaultInvalid') end end end diff --git a/spec/unit/controllers/runtime/security_groups_controller_spec.rb b/spec/unit/controllers/runtime/security_groups_controller_spec.rb index c6c153eec90..d23e3323254 100644 --- a/spec/unit/controllers/runtime/security_groups_controller_spec.rb +++ b/spec/unit/controllers/runtime/security_groups_controller_spec.rb @@ -48,8 +48,8 @@ module VCAP::CloudController post '/v2/security_groups', '{"name":"one\ntwo"}' expect(last_response.status).to eq(400) - expect(decoded_response['description']).to match(/security group is invalid/) - expect(decoded_response['error_code']).to match(/SecurityGroupInvalid/) + expect(decoded_response['description']).to include('security group is invalid') + expect(decoded_response['error_code']).to include('SecurityGroupInvalid') end it 'returns SecurityGroupNameTaken errors on unique name errors' do @@ -57,8 +57,8 @@ module VCAP::CloudController post '/v2/security_groups', '{"name":"foo"}' expect(last_response.status).to eq(400) - expect(decoded_response['description']).to match(/name is taken/) - expect(decoded_response['error_code']).to match(/SecurityGroupNameTaken/) + expect(decoded_response['description']).to include('name is taken') + expect(decoded_response['error_code']).to include('SecurityGroupNameTaken') end context 'when the max length for security groups is exceeded' do @@ -84,7 +84,7 @@ module VCAP::CloudController expect(last_response.status).to eq(400) expect(decoded_response['description']).to match(/must not exceed #{SecurityGroup::MAX_RULES_CHAR_LENGTH} characters/) - expect(decoded_response['error_code']).to match(/SecurityGroupInvalid/) + expect(decoded_response['error_code']).to include('SecurityGroupInvalid') end end end diff --git a/spec/unit/controllers/runtime/space_quota_definitions_controller_spec.rb b/spec/unit/controllers/runtime/space_quota_definitions_controller_spec.rb index 0bce77a5484..2671cb98379 100644 --- a/spec/unit/controllers/runtime/space_quota_definitions_controller_spec.rb +++ b/spec/unit/controllers/runtime/space_quota_definitions_controller_spec.rb @@ -158,8 +158,8 @@ module VCAP::CloudController post '/v2/space_quota_definitions', Oj.dump(sqd_json) expect(last_response.status).to eq(400) - expect(decoded_response['description']).to match(/Space Quota Definition is invalid/) - expect(decoded_response['error_code']).to match(/SpaceQuotaDefinitionInvalid/) + expect(decoded_response['description']).to include('Space Quota Definition is invalid') + expect(decoded_response['error_code']).to include('SpaceQuotaDefinitionInvalid') end it 'returns SpaceQuotaDefinitionNameTaken errors on unique name errors' do @@ -168,8 +168,8 @@ module VCAP::CloudController post '/v2/space_quota_definitions', Oj.dump(sqd_json) expect(last_response.status).to eq(400) - expect(decoded_response['description']).to match(/name is taken/) - expect(decoded_response['error_code']).to match(/SpaceQuotaDefinitionNameTaken/) + expect(decoded_response['description']).to include('name is taken') + expect(decoded_response['error_code']).to include('SpaceQuotaDefinitionNameTaken') end end diff --git a/spec/unit/controllers/runtime/spaces_controller_spec.rb b/spec/unit/controllers/runtime/spaces_controller_spec.rb index 8e44bea0115..0f457a1497f 100644 --- a/spec/unit/controllers/runtime/spaces_controller_spec.rb +++ b/spec/unit/controllers/runtime/spaces_controller_spec.rb @@ -1594,7 +1594,7 @@ def decoded_guids post '/v2/spaces', request_body expect(last_response).to have_status_code(400) - expect(last_response).to match(/name is taken/) + expect(decoded_response['description']).to include('name is taken') end end end diff --git a/spec/unit/controllers/services/service_bindings_controller_spec.rb b/spec/unit/controllers/services/service_bindings_controller_spec.rb index 5b0a7709e36..ad75788ca71 100644 --- a/spec/unit/controllers/services/service_bindings_controller_spec.rb +++ b/spec/unit/controllers/services/service_bindings_controller_spec.rb @@ -753,7 +753,7 @@ def bind_url_regex(opts={}) it 'passes through the error message' do make_request expect(last_response).to have_status_code 502 - expect(decoded_response['description']).to match(/ERROR MESSAGE HERE/) + expect(decoded_response['description']).to include('ERROR MESSAGE HERE') expect(service_instance.refresh.last_operation).to be_nil end diff --git a/spec/unit/controllers/services/service_brokers_controller_spec.rb b/spec/unit/controllers/services/service_brokers_controller_spec.rb index 005a59d3484..45b77c78ef6 100644 --- a/spec/unit/controllers/services/service_brokers_controller_spec.rb +++ b/spec/unit/controllers/services/service_brokers_controller_spec.rb @@ -641,7 +641,7 @@ def stub_catalog(broker_url: nil, username: nil, password: nil) expect(last_response.status).to eq(400) expect(decoded_response.fetch('code')).to eq(270_010) - expect(decoded_response.fetch('description')).to match(/Can not remove brokers that have associated service instances/) + expect(decoded_response.fetch('description')).to include('Can not remove brokers that have associated service instances') get '/v2/service_brokers' expect(decoded_response).to include('total_results' => 1) @@ -762,7 +762,7 @@ def stub_catalog(broker_url: nil, username: nil, password: nil) expect(last_response).to have_status_code(400) expect(decoded_response.fetch('code')).to eq(270_011) - expect(decoded_response.fetch('description')).to match(/is not a valid URL/) + expect(decoded_response.fetch('description')).to include('is not a valid URL') end end @@ -776,7 +776,7 @@ def stub_catalog(broker_url: nil, username: nil, password: nil) expect(last_response.status).to eq(400) expect(decoded_response.fetch('code')).to eq(270_002) - expect(decoded_response.fetch('description')).to match(/The service broker name is taken/) + expect(decoded_response.fetch('description')).to include('The service broker name is taken') end end end @@ -830,7 +830,7 @@ def stub_catalog(broker_url: nil, username: nil, password: nil) put("/v2/service_brokers/#{broker.guid}", body) warnings = last_response.headers['X-Cf-Warnings'].split(',').map { |w| CGI.unescape(w) } expect(warnings.length).to eq(1) - expect(warnings[0]).to match(/Service plans are missing from the broker/) + expect(warnings[0]).to include('Service plans are missing from the broker') end end diff --git a/spec/unit/controllers/services/service_instances_controller_spec.rb b/spec/unit/controllers/services/service_instances_controller_spec.rb index 16b5c3b94b0..ab2e2ed4351 100644 --- a/spec/unit/controllers/services/service_instances_controller_spec.rb +++ b/spec/unit/controllers/services/service_instances_controller_spec.rb @@ -731,7 +731,7 @@ def stub_delete_and_return(status, body) get "/v2/service_instances/#{service_instance_guid}" expect(last_response).to have_status_code 200 expect(decoded_response['entity']['last_operation']['state']).to eq 'failed' - expect(decoded_response['entity']['last_operation']['description']).to match(/Service Broker failed to provision within the required time/) + expect(decoded_response['entity']['last_operation']['description']).to include('Service Broker failed to provision within the required time') end end @@ -774,7 +774,7 @@ def stub_delete_and_return(status, body) get "/v2/service_instances/#{service_instance_guid}" expect(last_response).to have_status_code 200 expect(decoded_response['entity']['last_operation']['state']).to eq 'failed' - expect(decoded_response['entity']['last_operation']['description']).to match(/Service Broker failed to provision within the required time/) + expect(decoded_response['entity']['last_operation']['description']).to include('Service Broker failed to provision within the required time') end end end @@ -2113,7 +2113,7 @@ def stub_delete_and_return(status, body) put "/v2/service_instances/#{service_instance.guid}", body expect(last_response.status).to eq(400) - expect(last_response.body).to match(/The service does not support changing plans/) + expect(last_response.body).to include('The service does not support changing plans') end it 'does not update the service plan in the database' do @@ -2142,7 +2142,7 @@ def stub_delete_and_return(status, body) it 'returns a useful error to the user' do put "/v2/service_instances/#{service_instance.guid}", body - expect(last_response.body).to match(/The service does not support changing plans/) + expect(last_response.body).to include('The service does not support changing plans') end end end @@ -2169,7 +2169,7 @@ def stub_delete_and_return(status, body) it 'returns a useful error to the user' do put "/v2/service_instances/#{service_instance.guid}", body - expect(last_response.body).to match(/cannot switch to non-bindable plan when service bindings exist/) + expect(last_response.body).to include('cannot switch to non-bindable plan when service bindings exist') end end @@ -2291,7 +2291,7 @@ def stub_delete_and_return(status, body) put "/v2/service_instances/#{instance.guid}", move_req expect(last_response.status).to eq(400) - expect(decoded_response['description']).to match(/Cannot update space for service instance/) + expect(decoded_response['description']).to include('Cannot update space for service instance') end it 'succeeds when the space_guid does not change' do @@ -2577,7 +2577,7 @@ def stub_delete_and_return(status, body) stub_request(:patch, "#{service_broker_url}?accepts_incomplete=true").to_return do |_| put "/v2/service_instances/#{service_instance.guid}?accepts_incomplete=true", body expect(last_response).to have_status_code 409 - expect(last_response.body).to match(/AsyncServiceInstanceOperationInProgress/) + expect(last_response.body).to include('AsyncServiceInstanceOperationInProgress') { status: 202, body: {}.to_json } end.times(1).then.to_return do |_| @@ -2606,7 +2606,7 @@ def stub_delete_and_return(status, body) it 'returns a useful error to the user' do put "/v2/service_instances/#{service_instance.guid}?accepts_incomplete=true", body - expect(last_response.body).to match(/The service does not support changing plans/) + expect(last_response.body).to include('The service does not support changing plans') end end @@ -2681,7 +2681,7 @@ def stub_delete_and_return(status, body) put "/v2/service_instances/#{instance.guid}?accepts_incomplete=true", move_req expect(last_response.status).to eq(400) - expect(decoded_response['description']).to match(/Cannot update space for service instance/) + expect(decoded_response['description']).to include('Cannot update space for service instance') end it 'succeeds when the space_guid does not change' do @@ -2742,7 +2742,7 @@ def stub_delete_and_return(status, body) it 'returns an error' do put "/v2/service_instances/#{service_instance.guid}?accepts_incomplete=true", '{}' expect(last_response.status).to eq(400) - expect(last_response.body).to match(/paid service plans are not allowed/) + expect(last_response.body).to include('paid service plans are not allowed') end end @@ -3246,7 +3246,7 @@ def stub_delete_and_return(status, body) stub_deprovision(service_instance, accepts_incomplete: true) do |_req| delete "/v2/service_instances/#{service_instance.guid}?accepts_incomplete=true" expect(last_response).to have_status_code 409 - expect(last_response.body).to match(/AsyncServiceInstanceOperationInProgress/) + expect(last_response.body).to include('AsyncServiceInstanceOperationInProgress') { status: 202, body: {}.to_json } end.times(1).then.to_return do |_| @@ -4190,7 +4190,7 @@ def verify_forbidden(user) it 'passes through the error message' do make_request expect(last_response).to have_status_code 502 - expect(decoded_response['description']).to match(/ERROR MESSAGE HERE/) + expect(decoded_response['description']).to include('ERROR MESSAGE HERE') expect(service_instance.refresh.last_operation).to be_nil end diff --git a/spec/unit/controllers/services/services_controller_spec.rb b/spec/unit/controllers/services/services_controller_spec.rb index 0669fc3b95c..5e71989feb7 100644 --- a/spec/unit/controllers/services/services_controller_spec.rb +++ b/spec/unit/controllers/services/services_controller_spec.rb @@ -347,7 +347,7 @@ def decoded_long_descriptions delete "/v2/services/#{service.guid}", '{}', admin_headers expect(last_response).to have_status_code 400 - expect(last_response.body).to match(/AssociationNotEmpty/) + expect(last_response.body).to include('AssociationNotEmpty') end end diff --git a/spec/unit/controllers/services/user_provided_service_instances_controller_spec.rb b/spec/unit/controllers/services/user_provided_service_instances_controller_spec.rb index 6accb066832..79da7ecab03 100644 --- a/spec/unit/controllers/services/user_provided_service_instances_controller_spec.rb +++ b/spec/unit/controllers/services/user_provided_service_instances_controller_spec.rb @@ -640,7 +640,7 @@ def self.user_sees_empty_enumerate(user_role, member_a_ivar, member_b_ivar) put "/v2/user_provided_service_instances/#{instance.guid}", move_req expect(last_response.status).to eq(400) - expect(decoded_response['description']).to match(/cannot change space for service instance/) + expect(decoded_response['description']).to include('cannot change space for service instance') end it 'succeeds when the space_guid does not change' do diff --git a/spec/unit/controllers/v3/apps_controller_spec.rb b/spec/unit/controllers/v3/apps_controller_spec.rb index c9c4fe4de35..e1363a5fa10 100644 --- a/spec/unit/controllers/v3/apps_controller_spec.rb +++ b/spec/unit/controllers/v3/apps_controller_spec.rb @@ -70,9 +70,9 @@ expect(response.status).to eq(200), response.body response_names = parsed_body['resources'].pluck('name') expect(response_names).to match_array(%w[abel beale]) - expect(parsed_body['pagination']['next']['href']).to match(/order_by=%2Bname/) - expect(parsed_body['pagination']['next']['href']).to match(/per_page=2/) - expect(parsed_body['pagination']['next']['href']).to match(/page=2/) + expect(parsed_body['pagination']['next']['href']).to include('order_by=%2Bname') + expect(parsed_body['pagination']['next']['href']).to include('per_page=2') + expect(parsed_body['pagination']['next']['href']).to include('page=2') end it 'sorts and paginates the apps by name using the default direction only' do @@ -81,9 +81,9 @@ expect(response.status).to eq(200), response.body response_names = parsed_body['resources'].pluck('name') expect(response_names).to match_array(%w[quartz rocky]) - expect(parsed_body['pagination']['next']['href']).to match(/order_by=-name/) - expect(parsed_body['pagination']['next']['href']).to match(/per_page=2/) - expect(parsed_body['pagination']['next']['href']).to match(/page=2/) + expect(parsed_body['pagination']['next']['href']).to include('order_by=-name') + expect(parsed_body['pagination']['next']['href']).to include('per_page=2') + expect(parsed_body['pagination']['next']['href']).to include('page=2') end it 'can get the first page descending' do @@ -91,9 +91,9 @@ expect(response.status).to eq(200), response.body response_names = parsed_body['resources'].pluck('name') expect(response_names).to match_array(%w[rocky quartz]) - expect(parsed_body['pagination']['next']['href']).to match(/order_by=-name/) - expect(parsed_body['pagination']['next']['href']).to match(/per_page=2/) - expect(parsed_body['pagination']['next']['href']).to match(/page=2/) + expect(parsed_body['pagination']['next']['href']).to include('order_by=-name') + expect(parsed_body['pagination']['next']['href']).to include('per_page=2') + expect(parsed_body['pagination']['next']['href']).to include('page=2') expect(parsed_body['pagination']['previous']).to be_nil end @@ -102,9 +102,9 @@ expect(response.status).to eq(200), response.body response_names = parsed_body['resources'].pluck('name') expect(response_names).to match_array(%w[rocky quartz]) - expect(parsed_body['pagination']['next']['href']).to match(/order_by=-name/) - expect(parsed_body['pagination']['next']['href']).to match(/per_page=2/) - expect(parsed_body['pagination']['next']['href']).to match(/page=2/) + expect(parsed_body['pagination']['next']['href']).to include('order_by=-name') + expect(parsed_body['pagination']['next']['href']).to include('per_page=2') + expect(parsed_body['pagination']['next']['href']).to include('page=2') expect(parsed_body['pagination']['previous']).to be_nil end @@ -113,12 +113,12 @@ expect(response.status).to eq(200), response.body response_names = parsed_body['resources'].pluck('name') expect(response_names).to match_array(%w[clem beale]) - expect(parsed_body['pagination']['next']['href']).to match(/order_by=-name/) - expect(parsed_body['pagination']['next']['href']).to match(/per_page=2/) - expect(parsed_body['pagination']['next']['href']).to match(/page=3/) - expect(parsed_body['pagination']['previous']['href']).to match(/order_by=-name/) - expect(parsed_body['pagination']['previous']['href']).to match(/per_page=2/) - expect(parsed_body['pagination']['previous']['href']).to match(/page=1/) + expect(parsed_body['pagination']['next']['href']).to include('order_by=-name') + expect(parsed_body['pagination']['next']['href']).to include('per_page=2') + expect(parsed_body['pagination']['next']['href']).to include('page=3') + expect(parsed_body['pagination']['previous']['href']).to include('order_by=-name') + expect(parsed_body['pagination']['previous']['href']).to include('per_page=2') + expect(parsed_body['pagination']['previous']['href']).to include('page=1') end it 'can get the final page' do @@ -127,9 +127,9 @@ response_names = parsed_body['resources'].pluck('name') expect(response_names).to match_array(%w[abel]) expect(parsed_body['pagination']['next']).to be_nil - expect(parsed_body['pagination']['previous']['href']).to match(/order_by=-name/) - expect(parsed_body['pagination']['previous']['href']).to match(/per_page=2/) - expect(parsed_body['pagination']['previous']['href']).to match(/page=2/) + expect(parsed_body['pagination']['previous']['href']).to include('order_by=-name') + expect(parsed_body['pagination']['previous']['href']).to include('per_page=2') + expect(parsed_body['pagination']['previous']['href']).to include('page=2') end end @@ -139,7 +139,7 @@ expect(response).to have_http_status(:bad_request) - expect(parsed_body['errors'].first['detail']).to match(/Invalid label_selector value/) + expect(parsed_body['errors'].first['detail']).to include('Invalid label_selector value') end end end @@ -1663,8 +1663,8 @@ expect(parsed_body['pagination']['previous']).to be_nil expect(parsed_body['pagination']['next']['href']).to start_with("#{link_prefix}/v3/apps/#{app_model.guid}/builds") - expect(parsed_body['pagination']['next']['href']).to match(/per_page=1/) - expect(parsed_body['pagination']['next']['href']).to match(/page=2/) + expect(parsed_body['pagination']['next']['href']).to include('per_page=1') + expect(parsed_body['pagination']['next']['href']).to include('page=2') expect(parsed_body['pagination']['next']['href']).to match(/states=#{VCAP::CloudController::BuildModel::STAGED_STATE}/) end diff --git a/spec/unit/controllers/v3/builds_controller_spec.rb b/spec/unit/controllers/v3/builds_controller_spec.rb index 1b84cfb0667..2d0a8f706d8 100644 --- a/spec/unit/controllers/v3/builds_controller_spec.rb +++ b/spec/unit/controllers/v3/builds_controller_spec.rb @@ -142,8 +142,8 @@ get(:index, params:) expect(parsed_body['pagination']['next']['href']).to start_with("#{link_prefix}/v3/builds") - expect(parsed_body['pagination']['next']['href']).to match(/per_page=1/) - expect(parsed_body['pagination']['next']['href']).to match(/page=2/) + expect(parsed_body['pagination']['next']['href']).to include('per_page=1') + expect(parsed_body['pagination']['next']['href']).to include('page=2') expect(parsed_body['pagination']['next']['href']).to match(/states=#{VCAP::CloudController::BuildModel::STAGED_STATE}/) end end diff --git a/spec/unit/controllers/v3/deployments_controller_spec.rb b/spec/unit/controllers/v3/deployments_controller_spec.rb index e3e9e3e3251..fc347a59851 100644 --- a/spec/unit/controllers/v3/deployments_controller_spec.rb +++ b/spec/unit/controllers/v3/deployments_controller_spec.rb @@ -612,8 +612,8 @@ expect(response).to have_http_status(:ok) expect(parsed_body['pagination']['next']['href']).to start_with("#{link_prefix}/v3/deployments") - expect(parsed_body['pagination']['next']['href']).to match(/per_page=1/) - expect(parsed_body['pagination']['next']['href']).to match(/page=2/) + expect(parsed_body['pagination']['next']['href']).to include('per_page=1') + expect(parsed_body['pagination']['next']['href']).to include('page=2') end end @@ -676,7 +676,7 @@ post :cancel, params: { guid: deployment.guid } expect(response).to have_http_status(:unprocessable_content) - expect(response.body).to match(/awry/) + expect(response.body).to include('awry') end end diff --git a/spec/unit/controllers/v3/space_manifests_controller_spec.rb b/spec/unit/controllers/v3/space_manifests_controller_spec.rb index e15831ca1ee..c2519630d94 100644 --- a/spec/unit/controllers/v3/space_manifests_controller_spec.rb +++ b/spec/unit/controllers/v3/space_manifests_controller_spec.rb @@ -202,7 +202,7 @@ def error_message(detail) post :apply_manifest, params: { guid: space.guid }, body: request_body.to_yaml, as: :yaml expect(response).to have_http_status(:unprocessable_content) parsed_response = Oj.load(response.body) - expect(parsed_response['errors'][0]['detail']).to match(/For application at index 0:/) + expect(parsed_response['errors'][0]['detail']).to include('For application at index 0:') end end end diff --git a/spec/unit/jobs/runtime/blobstore_upload_spec.rb b/spec/unit/jobs/runtime/blobstore_upload_spec.rb index 1e4514b2cd5..566fb40e1dd 100644 --- a/spec/unit/jobs/runtime/blobstore_upload_spec.rb +++ b/spec/unit/jobs/runtime/blobstore_upload_spec.rb @@ -84,7 +84,7 @@ def reschedule_at(_, _=nil) end it 'receives an error' do - expect(Delayed::Job.last.last_error).to match(/File not found/) + expect(Delayed::Job.last.last_error).to include('File not found') end it 'does not retry' do diff --git a/spec/unit/jobs/services/service_binding_state_fetch_spec.rb b/spec/unit/jobs/services/service_binding_state_fetch_spec.rb index 8d05d5ab594..384a1a0b43b 100644 --- a/spec/unit/jobs/services/service_binding_state_fetch_spec.rb +++ b/spec/unit/jobs/services/service_binding_state_fetch_spec.rb @@ -625,7 +625,7 @@ def run_job(job) end it 'raises informative error' do - expect(Delayed::Job.first.last_error).to match(/Invalid response from client/) + expect(Delayed::Job.first.last_error).to include('Invalid response from client') end it 'does not enqueue another fetch job in addition to the failed one' do diff --git a/spec/unit/jobs/services/shared/when_exponential_backoff_is_not_set_to_default.rb b/spec/unit/jobs/services/shared/when_exponential_backoff_is_not_set_to_default.rb index 2f4dbfb9495..15796ad6b19 100644 --- a/spec/unit/jobs/services/shared/when_exponential_backoff_is_not_set_to_default.rb +++ b/spec/unit/jobs/services/shared/when_exponential_backoff_is_not_set_to_default.rb @@ -50,7 +50,7 @@ run_job(job) expect(last_operation.state).to eq('failed') - expect(last_operation.description).to match(/Service Broker failed/) + expect(last_operation.description).to include('Service Broker failed') end end end diff --git a/spec/unit/jobs/v3/buildpack_cache_upload_spec.rb b/spec/unit/jobs/v3/buildpack_cache_upload_spec.rb index b4358513fcd..86607f2bc42 100644 --- a/spec/unit/jobs/v3/buildpack_cache_upload_spec.rb +++ b/spec/unit/jobs/v3/buildpack_cache_upload_spec.rb @@ -123,7 +123,7 @@ def reschedule_at(_, _=nil) end it 'records the failure' do - expect(Delayed::Job.last.last_error).to match(/Something Terrible Happened/) + expect(Delayed::Job.last.last_error).to include('Something Terrible Happened') end context 'retrying' do @@ -152,7 +152,7 @@ def reschedule_at(_, _=nil) end it 'receives an error' do - expect(Delayed::Job.last.last_error).to match(/No such file or directory/) + expect(Delayed::Job.last.last_error).to include('No such file or directory') end it 'does not retry' do diff --git a/spec/unit/jobs/v3/droplet_upload_spec.rb b/spec/unit/jobs/v3/droplet_upload_spec.rb index 56fdfc27548..e6d2631db5a 100644 --- a/spec/unit/jobs/v3/droplet_upload_spec.rb +++ b/spec/unit/jobs/v3/droplet_upload_spec.rb @@ -122,7 +122,7 @@ def reschedule_at(_, _=nil) end it 'records the failure' do - expect(Delayed::Job.last.last_error).to match(/Something Terrible Happened/) + expect(Delayed::Job.last.last_error).to include('Something Terrible Happened') end context 'retrying' do @@ -169,7 +169,7 @@ def reschedule_at(_, _=nil) end it 'receives an error' do - expect(Delayed::Job.last.last_error).to match(/No such file or directory/) + expect(Delayed::Job.last.last_error).to include('No such file or directory') end it 'does not retry' do diff --git a/spec/unit/jobs/v3/sub_resource_failures_spec.rb b/spec/unit/jobs/v3/sub_resource_failures_spec.rb index 00ed98ce237..2b4963c4b78 100644 --- a/spec/unit/jobs/v3/sub_resource_failures_spec.rb +++ b/spec/unit/jobs/v3/sub_resource_failures_spec.rb @@ -69,7 +69,7 @@ def build(sub_jobs: [], sub_resource_errors: []) err = build.compound_error([StandardError.new('one broke'), StandardError.new('two broke')]) expect(err.underlying_errors.map(&:name)).to eq(%w[UnprocessableEntity UnprocessableEntity]) - expect(err.underlying_errors.map(&:message)).to include(match(/one broke/), match(/two broke/)) + expect(err.underlying_errors.map(&:message)).to include(include('one broke'), include('two broke')) end it 'prefers durable errors over the raised fallback when both are present' do diff --git a/spec/unit/lib/app_packager_spec.rb b/spec/unit/lib/app_packager_spec.rb index 341f6a0b9cb..123ac81caa4 100644 --- a/spec/unit/lib/app_packager_spec.rb +++ b/spec/unit/lib/app_packager_spec.rb @@ -230,7 +230,7 @@ it 'successfully removes and re-adds them' do app_packager.fix_subdir_permissions(@tmpdir, "#{@tmpdir}/application_contents") - expect(`zipinfo #{input_zip}`).to match %r{special_character_names/&&hello::\?\?/} + expect(`zipinfo #{input_zip}`).to include('special_character_names/&&hello::??/') end end diff --git a/spec/unit/lib/cloud_controller/db_connection/postgres_options_factory_spec.rb b/spec/unit/lib/cloud_controller/db_connection/postgres_options_factory_spec.rb index dbcccd62efc..973994c3a87 100644 --- a/spec/unit/lib/cloud_controller/db_connection/postgres_options_factory_spec.rb +++ b/spec/unit/lib/cloud_controller/db_connection/postgres_options_factory_spec.rb @@ -120,7 +120,7 @@ end it 'does not SET keepalive params via connect_sqls' do - expect(postgres_options[:connect_sqls]).not_to include(match(/SET keepalives/)) + expect(postgres_options[:connect_sqls]).not_to include(include('SET keepalives')) end end @@ -148,7 +148,7 @@ it 'does not mix up the two kinds: SQL params not in options hash, libpq params not SET via SQL' do expect(postgres_options[:statement_timeout]).to be_nil - expect(postgres_options[:connect_sqls]).not_to include(match(/SET keepalives/)) + expect(postgres_options[:connect_sqls]).not_to include(include('SET keepalives')) end end end diff --git a/spec/unit/lib/cloud_controller/diego/docker/staging_completion_handler_spec.rb b/spec/unit/lib/cloud_controller/diego/docker/staging_completion_handler_spec.rb index a5a33a6e8fd..3de7d15b9e4 100644 --- a/spec/unit/lib/cloud_controller/diego/docker/staging_completion_handler_spec.rb +++ b/spec/unit/lib/cloud_controller/diego/docker/staging_completion_handler_spec.rb @@ -82,7 +82,7 @@ module Docker it 'gracefully sets process_types to an empty hash, but mark the build as failed' do handler.staging_complete(payload) expect(build.reload.state).to eq(BuildModel::FAILED_STATE) - expect(build.error_id).to match(/StagingError/) + expect(build.error_id).to include('StagingError') end it 'logs an error for the CF user' do @@ -285,7 +285,7 @@ module Docker end.to raise_error(CloudController::Errors::ApiError) expect(build.reload.state).to eq(BuildModel::FAILED_STATE) - expect(build.error_id).to match(/StagingError/) + expect(build.error_id).to include('StagingError') end it 'logs an error for the CF user' do diff --git a/spec/unit/lib/cloud_controller/diego/lifecycles/app_buildpack_lifecycle_spec.rb b/spec/unit/lib/cloud_controller/diego/lifecycles/app_buildpack_lifecycle_spec.rb index 6a9513935c1..21f83c5ee8a 100644 --- a/spec/unit/lib/cloud_controller/diego/lifecycles/app_buildpack_lifecycle_spec.rb +++ b/spec/unit/lib/cloud_controller/diego/lifecycles/app_buildpack_lifecycle_spec.rb @@ -253,7 +253,7 @@ module VCAP::CloudController it 'is invalid because stored buildpack URL already has userinfo' do lc = AppBuildpackLifecycle.new(message, app) expect(lc.valid?).to be false - expect(lc.errors.full_messages.join).to match(/credentials/) + expect(lc.errors.full_messages.join).to include('credentials') end end diff --git a/spec/unit/lib/cloud_controller/diego/main_lrp_action_builder_spec.rb b/spec/unit/lib/cloud_controller/diego/main_lrp_action_builder_spec.rb index 2bb54b4b278..9dbfdb667e5 100644 --- a/spec/unit/lib/cloud_controller/diego/main_lrp_action_builder_spec.rb +++ b/spec/unit/lib/cloud_controller/diego/main_lrp_action_builder_spec.rb @@ -289,10 +289,10 @@ module Diego actions = MainLRPActionBuilder.build(process, lrp_builder, ssh_key).codependent_action.actions.map(&:run_action) ssh_action = actions.find { |action| action.path == '/tmp/lifecycle/diego-sshd' } - expect(ssh_action.args).not_to include(match(/-allowedCiphers=/)) - expect(ssh_action.args).not_to include(match(/-allowedHostKeyAlgorithms=/)) - expect(ssh_action.args).not_to include(match(/-allowedKeyExchanges=/)) - expect(ssh_action.args).not_to include(match(/-allowedMACs=/)) + expect(ssh_action.args).not_to include(include('-allowedCiphers=')) + expect(ssh_action.args).not_to include(include('-allowedHostKeyAlgorithms=')) + expect(ssh_action.args).not_to include(include('-allowedKeyExchanges=')) + expect(ssh_action.args).not_to include(include('-allowedMACs=')) end end @@ -313,9 +313,9 @@ module Diego ssh_action = actions.find { |action| action.path == '/tmp/lifecycle/diego-sshd' } expect(ssh_action.args).to include('-allowedCiphers=cipher-1') - expect(ssh_action.args).not_to include(match(/-allowedHostKeyAlgorithms=/)) - expect(ssh_action.args).not_to include(match(/-allowedKeyExchanges=/)) - expect(ssh_action.args).not_to include(match(/-allowedMACs=/)) + expect(ssh_action.args).not_to include(include('-allowedHostKeyAlgorithms=')) + expect(ssh_action.args).not_to include(include('-allowedKeyExchanges=')) + expect(ssh_action.args).not_to include(include('-allowedMACs=')) end end @@ -332,10 +332,10 @@ module Diego actions = MainLRPActionBuilder.build(process, lrp_builder, ssh_key).codependent_action.actions.map(&:run_action) ssh_action = actions.find { |action| action.path == '/tmp/lifecycle/diego-sshd' } - expect(ssh_action.args).not_to include(match(/-allowedCiphers=/)) - expect(ssh_action.args).not_to include(match(/-allowedHostKeyAlgorithms=/)) - expect(ssh_action.args).not_to include(match(/-allowedKeyExchanges=/)) - expect(ssh_action.args).not_to include(match(/-allowedMACs=/)) + expect(ssh_action.args).not_to include(include('-allowedCiphers=')) + expect(ssh_action.args).not_to include(include('-allowedHostKeyAlgorithms=')) + expect(ssh_action.args).not_to include(include('-allowedKeyExchanges=')) + expect(ssh_action.args).not_to include(include('-allowedMACs=')) end end end diff --git a/spec/unit/lib/membrane/schemas/dictionary_spec.rb b/spec/unit/lib/membrane/schemas/dictionary_spec.rb index ba337d291d5..f3995677e53 100644 --- a/spec/unit/lib/membrane/schemas/dictionary_spec.rb +++ b/spec/unit/lib/membrane/schemas/dictionary_spec.rb @@ -52,8 +52,8 @@ errors = e.to_s end - expect(errors).to match(/foo/) - expect(errors).to match(/bar/) + expect(errors).to include('foo') + expect(errors).to include('bar') end end end diff --git a/spec/unit/lib/membrane/schemas/list_spec.rb b/spec/unit/lib/membrane/schemas/list_spec.rb index cda0a7351ed..a75feadd396 100644 --- a/spec/unit/lib/membrane/schemas/list_spec.rb +++ b/spec/unit/lib/membrane/schemas/list_spec.rb @@ -35,8 +35,8 @@ errors = e.to_s end - expect(errors).to match(/index 2/) - expect(errors).to match(/index 4/) + expect(errors).to include('index 2') + expect(errors).to include('index 4') end it 'returns nil if all items validate' do diff --git a/spec/unit/lib/membrane/schemas/record_spec.rb b/spec/unit/lib/membrane/schemas/record_spec.rb index 55837c7de99..c18448dd994 100644 --- a/spec/unit/lib/membrane/schemas/record_spec.rb +++ b/spec/unit/lib/membrane/schemas/record_spec.rb @@ -51,8 +51,8 @@ errors = e.to_s end - expect(errors).to match(/foo => Missing key/) - expect(errors).to match(/bar/) + expect(errors).to include('foo => Missing key') + expect(errors).to include('bar') end it 'ignores extra keys that are not in the schema' do diff --git a/spec/unit/lib/sequel/extensions/default_order_by_id_spec.rb b/spec/unit/lib/sequel/extensions/default_order_by_id_spec.rb index 90c15feeb1a..fc2212ae9f9 100644 --- a/spec/unit/lib/sequel/extensions/default_order_by_id_spec.rb +++ b/spec/unit/lib/sequel/extensions/default_order_by_id_spec.rb @@ -64,26 +64,26 @@ def capture_sql(&) describe 'incompatible_with_order?' do it 'skips for GROUP BY' do sql = capture_sql { model_class.dataset.select_group(:status).select_append(Sequel.function(:max, :id).as(:id)).all } - expect(sql).not_to match(/ORDER BY/) + expect(sql).not_to include('ORDER BY') end it 'skips for compound queries (UNION)' do ds1 = model_class.dataset.where(name: 'a') ds2 = model_class.dataset.where(name: 'b') sql = capture_sql { ds1.union(ds2, all: true, from_self: false).all } - expect(sql).not_to match(/ORDER BY/) + expect(sql).not_to include('ORDER BY') end it 'skips for DISTINCT ON' do skip if db.database_type != :postgres sql = capture_sql { model_class.dataset.distinct(:guid).all } - expect(sql).not_to match(/ORDER BY/) + expect(sql).not_to include('ORDER BY') end it 'skips for from_self (subquery)' do sql = capture_sql { model_class.dataset.where(name: 'a').from_self.all } - expect(sql).not_to match(/ORDER BY/) + expect(sql).not_to include('ORDER BY') end it 'does not skip for table alias' do @@ -95,7 +95,7 @@ def capture_sql(&) describe 'not_a_data_query?' do it 'skips for schema introspection (columns!)' do sql = capture_sql { model_class.dataset.columns! } - expect(sql).not_to match(/ORDER BY/) + expect(sql).not_to include('ORDER BY') end end @@ -105,7 +105,7 @@ def capture_sql(&) set_primary_key :guid end sql = capture_sql { guid_pk_model.dataset.all } - expect(sql).not_to match(/ORDER BY/) + expect(sql).not_to include('ORDER BY') end end @@ -149,7 +149,7 @@ def capture_sql(&) context 'without id in select list' do it 'skips ordering' do sql = capture_sql { model_class.dataset.select(:guid, :name).all } - expect(sql).not_to match(/ORDER BY/) + expect(sql).not_to include('ORDER BY') end end end diff --git a/spec/unit/lib/services/service_brokers/v2/http_client_spec.rb b/spec/unit/lib/services/service_brokers/v2/http_client_spec.rb index 4f750a25624..73bd13331d6 100644 --- a/spec/unit/lib/services/service_brokers/v2/http_client_spec.rb +++ b/spec/unit/lib/services/service_brokers/v2/http_client_spec.rb @@ -82,10 +82,10 @@ module VCAP::Services::ServiceBrokers::V2 it 'logs the default headers' do make_request - expect(fake_logger).to have_received(:debug).with(match(%r{Accept" => "application/json})) + expect(fake_logger).to have_received(:debug).with(include('Accept" => "application/json')) expect(fake_logger).to have_received(:debug).with(match(/X-VCAP-Request-ID" => "[[:alnum:]-]+/)) expect(fake_logger).to have_received(:debug).with(match(/X-Broker-API-Request-Identity" => "[[:alnum:]-]+/)) - expect(fake_logger).to have_received(:debug).with(match(/X-Broker-Api-Version" => "2\.15/)) + expect(fake_logger).to have_received(:debug).with(include('X-Broker-Api-Version" => "2.15')) api_info_path = TestConfig.config[:temporary_enable_v2] ? '/v2/info' : '/' expect(fake_logger).to have_received(:debug).with(match(/X-Api-Info-Location" => "api2\.127\.0\.0\.1\.nip\.io#{api_info_path}/)) end @@ -527,7 +527,7 @@ def expect_timeout_to_be(timeout) it 'logs the Content-Type Header' do make_request - expect(fake_logger).to have_received(:debug).with(match(%r{"Content-Type" => "application/json"})) + expect(fake_logger).to have_received(:debug).with(include('"Content-Type" => "application/json"')) end it 'has a content body' do @@ -604,7 +604,7 @@ def expect_timeout_to_be(timeout) it 'logs the Content-Type Header' do make_request - expect(fake_logger).to have_received(:debug).with(match(%r{"Content-Type" => "application/json"})) + expect(fake_logger).to have_received(:debug).with(include('"Content-Type" => "application/json"')) end it 'has a content body' do diff --git a/spec/unit/lib/services/sso/uaa/uaa_client_manager_spec.rb b/spec/unit/lib/services/sso/uaa/uaa_client_manager_spec.rb index e2a89df6499..21e5ba0f0b1 100644 --- a/spec/unit/lib/services/sso/uaa/uaa_client_manager_spec.rb +++ b/spec/unit/lib/services/sso/uaa/uaa_client_manager_spec.rb @@ -87,7 +87,7 @@ module VCAP::Services::SSO::UAA expect(logger).to receive(:info) do |arg| expect(arg).to match(/POST UAA transaction: #{tx_url}/) - expect(arg).not_to match(/client_secret/) + expect(arg).not_to include('client_secret') end client_manager = UaaClientManager.new diff --git a/spec/unit/lib/sinatra/vcap_spec.rb b/spec/unit/lib/sinatra/vcap_spec.rb index 4f5bfe49a51..0a600629984 100644 --- a/spec/unit/lib/sinatra/vcap_spec.rb +++ b/spec/unit/lib/sinatra/vcap_spec.rb @@ -87,7 +87,7 @@ def app it 'returns a 404' do expect(last_response.status).to eq(404) expect(decoded_response['code']).to eq(10_000) - expect(decoded_response['description']).to match(/Unknown request/) + expect(decoded_response['description']).to include('Unknown request') end include_examples 'http header content type' diff --git a/spec/unit/messages/routes_list_message_spec.rb b/spec/unit/messages/routes_list_message_spec.rb index f4864c2f6cf..691acbed683 100644 --- a/spec/unit/messages/routes_list_message_spec.rb +++ b/spec/unit/messages/routes_list_message_spec.rb @@ -104,7 +104,7 @@ module VCAP::CloudController message = RoutesListMessage.from_params 'include' => 'domain,domain' expect(message).not_to be_valid expect(message.errors[:base].length).to eq 1 - expect(message.errors[:base][0]).to match(/Duplicate included resource: 'domain'/) + expect(message.errors[:base][0]).to include("Duplicate included resource: 'domain'") end context 'when app guids param is provided' do diff --git a/spec/unit/models/runtime/security_group_spec.rb b/spec/unit/models/runtime/security_group_spec.rb index 0f62b246587..2669e4d2c7c 100644 --- a/spec/unit/models/runtime/security_group_spec.rb +++ b/spec/unit/models/runtime/security_group_spec.rb @@ -975,7 +975,7 @@ def build_all_rule(attrs={}) sg = create(:security_group, name: 'sec') expect do create(:security_group, name: sg.name) - end.to raise_error(Sequel::ValidationFailed) { |error| expect(error.message).to match(/unique/) } + end.to raise_error(Sequel::ValidationFailed) { |error| expect(error.message).to include('unique') } end it 'raises the original error on other unique constraint violations' do