Class: GdsApi::TestHelpers::ContentApi::ArtefactStub
- Inherits:
-
Object
- Object
- GdsApi::TestHelpers::ContentApi::ArtefactStub
- Includes:
- GdsApi::TestHelpers::ContentApi, WebMock::API
- Defined in:
- lib/gds_api/test_helpers/content_api/artefact_stub.rb
Constant Summary
Constants included from GdsApi::TestHelpers::ContentApi
Instance Attribute Summary collapse
-
#query_parameters ⇒ Object
Returns the value of attribute query_parameters.
-
#response_body ⇒ Object
Returns the value of attribute response_body.
-
#response_status ⇒ Object
Returns the value of attribute response_status.
-
#slug ⇒ Object
Returns the value of attribute slug.
Instance Method Summary collapse
-
#initialize(slug) ⇒ ArtefactStub
constructor
A new instance of ArtefactStub.
-
#stub ⇒ Object
Nothing is stubbed until this is called.
- #with_query_parameters(hash) ⇒ Object
- #with_response_body(response_body) ⇒ Object
- #with_response_status(response_status) ⇒ Object
Methods included from GdsApi::TestHelpers::ContentApi
#artefact_for_slug, #artefact_for_slug_in_a_section, #artefact_for_slug_in_a_subsection, #artefact_for_slug_with_a_child_tag, #artefact_for_slug_with_a_child_tags, #artefact_for_slug_with_a_tag, #artefact_for_slug_with_related_artefacts, #content_api_does_not_have_an_artefact, #content_api_has_an_archived_artefact, #content_api_has_an_artefact, #content_api_has_an_artefact_with_snac_code, #content_api_has_artefacts_for_need_id, #content_api_has_artefacts_in_a_section, #content_api_has_artefacts_with_a_tag, #content_api_has_business_support_scheme, #content_api_has_child_tags, #content_api_has_default_business_support_schemes, #content_api_has_grouped_artefacts_with_a_tag, #content_api_has_licence, #content_api_has_root_sections, #content_api_has_root_tags, #content_api_has_section, #content_api_has_sorted_artefacts_with_a_tag, #content_api_has_subsections, #content_api_has_tag, #content_api_has_tags, #content_api_has_unpublished_artefact, #content_api_licence_hash, #setup_content_api_business_support_schemes_stubs, #setup_content_api_licences_stubs, #simple_tag_type_pluralizer, #stub_content_api_default_artefact, #tag_for_slug, #tag_hash, #tag_result
Methods included from BusinessSupportHelper
#api_has_business_support, #setup_business_support_stubs
Methods included from GdsApi::TestHelpers::CommonResponses
#acronymize_slug, #plural_response_base, #response_base, #titleize_slug
Constructor Details
#initialize(slug) ⇒ ArtefactStub
Returns a new instance of ArtefactStub.
13 14 15 16 17 18 |
# File 'lib/gds_api/test_helpers/content_api/artefact_stub.rb', line 13 def initialize(slug) @slug = slug @query_parameters = {} @response_body = artefact_for_slug(slug) @response_status = 200 end |
Instance Attribute Details
#query_parameters ⇒ Object
Returns the value of attribute query_parameters.
11 12 13 |
# File 'lib/gds_api/test_helpers/content_api/artefact_stub.rb', line 11 def query_parameters @query_parameters end |
#response_body ⇒ Object
Returns the value of attribute response_body.
11 12 13 |
# File 'lib/gds_api/test_helpers/content_api/artefact_stub.rb', line 11 def response_body @response_body end |
#response_status ⇒ Object
Returns the value of attribute response_status.
11 12 13 |
# File 'lib/gds_api/test_helpers/content_api/artefact_stub.rb', line 11 def response_status @response_status end |
#slug ⇒ Object
Returns the value of attribute slug.
11 12 13 |
# File 'lib/gds_api/test_helpers/content_api/artefact_stub.rb', line 11 def slug @slug end |
Instance Method Details
#stub ⇒ Object
Nothing is stubbed until this is called
36 37 38 39 40 |
# File 'lib/gds_api/test_helpers/content_api/artefact_stub.rb', line 36 def stub stub_request(:get, url_without_query) .with(query: hash_including(comparable_query_params)) .to_return(status: @response_status, body: @response_body.to_json) end |
#with_query_parameters(hash) ⇒ Object
20 21 22 23 |
# File 'lib/gds_api/test_helpers/content_api/artefact_stub.rb', line 20 def with_query_parameters(hash) @query_parameters = hash self end |
#with_response_body(response_body) ⇒ Object
25 26 27 28 |
# File 'lib/gds_api/test_helpers/content_api/artefact_stub.rb', line 25 def with_response_body(response_body) @response_body = response_body self end |
#with_response_status(response_status) ⇒ Object
30 31 32 33 |
# File 'lib/gds_api/test_helpers/content_api/artefact_stub.rb', line 30 def with_response_status(response_status) @response_status = response_status self end |