RSpec: Verify doubled constant names
What does this MR do and why?
OpenStruct
instance_double
and could cause CI failure because of master
before merging
When using instance_double
or class_double
with a string like instance_double('Foo')
or class_double('Foo')
we should make sure that the stubbed constants actually exist.
See https://relishapp.com/rspec/rspec-mocks/v/3-10/docs/verifying-doubles/using-an-instance-double
Otherwise, from now on, we'll see a failure like:
1) Running a DAST Scan behaves like an on-demand scan mutation when user can run an on-demand scan when pipeline creation fails behaves like a mutation that returns errors in the response
Failure/Error: let(:fake_pipeline) { instance_double('Ci::Pipelines', created_successfully?: false, full_error_messages: 'full error messages') }
the Ci::Pipelines class does not implement the instance method: created_successfully?
Shared Example Group: "a mutation that returns errors in the response" called from ./ee/spec/requests/api/graphql/mutations/dast_on_demand_scans/create_spec.rb:77
Shared Example Group: "an on-demand scan mutation when user can run an on-demand scan" called from ./ee/spec/requests/api/graphql/mutations/dast_on_demand_scans/create_spec.rb:28
# ./ee/spec/requests/api/graphql/mutations/dast_on_demand_scans/create_spec.rb:70:in `block (4 levels) in <top (required)>'
# ./ee/spec/requests/api/graphql/mutations/dast_on_demand_scans/create_spec.rb:71:in `block (4 levels) in <top (required)>'
# ./ee/spec/requests/api/graphql/mutations/dast_on_demand_scans/create_spec.rb:74:in `block (4 levels) in <top (required)>'
# ./spec/spec_helper.rb:414:in `block (3 levels) in <top (required)>'
# ./spec/support/sidekiq_middleware.rb:9:in `with_sidekiq_server_middleware'
# ./spec/spec_helper.rb:405:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:401:in `block (3 levels) in <top (required)>'
# ./lib/gitlab/application_context.rb:31:in `with_raw_context'
# ./spec/spec_helper.rb:401:in `block (2 levels) in <top (required)>'
# ./spec/support/database/query_analyzer.rb:9:in `block (3 levels) in <main>'
# ./lib/gitlab/database/query_analyzer.rb:42:in `within'
# ./spec/support/database/query_analyzer.rb:9:in `block (2 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:102:in `block (3 levels) in <main>'
# ./spec/support/database/prevent_cross_joins.rb:56:in `with_cross_joins_prevented'
# ./spec/support/database/prevent_cross_joins.rb:102:in `block (2 levels) in <main>'
Finished in 17.87 seconds (files took 18.06 seconds to load)
1 example, 1 failure
Failed examples:
rspec ./ee/spec/requests/api/graphql/mutations/dast_on_demand_scans/create_spec.rb:77 # Running a DAST Scan behaves like an on-demand scan mutation when user can run an on-demand scan when pipeline creation fails behaves like a mutation that returns errors in the response
This MR was inspired by a Community contribution !74415 (comment 734653130).
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.