Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .rubocop_cc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -192,6 +212,8 @@ Lint/AmbiguousOperatorPrecedence:
Enabled: true
Lint/AmbiguousRange:
Enabled: true
Lint/ArgumentMismatch:
Enabled: true
Lint/ArrayLiteralInRegexp:
Enabled: true
Lint/ConstantDefinitionInBlock:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -260,6 +290,8 @@ Lint/RequireRelativeSelfPath:
Enabled: true
Lint/SharedMutableDefault:
Enabled: true
Lint/SuperArgumentMismatch:
Enabled: true
Lint/SuppressedException:
Enabled: true
Lint/SuppressedExceptionInNumberConversion:
Expand All @@ -278,6 +310,8 @@ Lint/UnifiedInteger:
Enabled: true
Lint/UnmodifiedReduceAccumulator:
Enabled: true
Lint/UnreachablePatternBranch:
Enabled: true
Lint/UnusedMethodArgument:
Enabled: true
Lint/UselessConstantScoping:
Expand Down Expand Up @@ -468,6 +502,8 @@ RSpec/DescribeClass:
Enabled: true
RSpec/DescribedClass:
Enabled: true
RSpec/DiscardedMatcher:
Enabled: true
RSpec/DuplicatedMetadata:
Enabled: true
RSpec/EmptyExampleGroup:
Expand Down Expand Up @@ -504,6 +540,8 @@ RSpec/LetSetup:
Enabled: true
RSpec/MatchArray:
Enabled: true
RSpec/MatchWithSimpleRegex:
Enabled: true
RSpec/MessageChain:
Enabled: true
RSpec/MessageSpies:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -738,6 +782,8 @@ Style/RedundantInterpolationUnfreeze:
Enabled: true
Style/RedundantLineContinuation:
Enabled: true
Style/RedundantMinMaxBy:
Enabled: true
Style/RedundantRegexpArgument:
Enabled: true
Style/RedundantRegexpConstructor:
Expand All @@ -754,6 +800,8 @@ Style/SafeNavigation:
Enabled: true
Style/SafeNavigationChainLength:
Enabled: true
Style/SelectByRange:
Enabled: true
Style/SelectByRegexp:
Enabled: true
Style/SendWithLiteralMethodName:
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spec/acceptance/managed_service_instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/api/documentation/job_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/isolated_specs/steno/codec_rfc3339_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/isolated_specs/steno/unit/json_codec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/isolated_specs/steno/unit/logger_io_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/isolated_specs/steno/unit/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions spec/request/internal/metrics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spec/request/organizations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/request/service_plan_visibility_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/request/service_plans_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/request/v2/apps_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/request/v2/auth_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/unit/actions/space_delete_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/controllers/base/base_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading
Loading