Skip to content

Commit

Permalink
Make publishing_app optional in unreserve stub
Browse files Browse the repository at this point in the history
This reduces the amount of boilerplate we need to write when testing
against this feature.
  • Loading branch information
Ben Thorner committed Mar 20, 2019
1 parent b3e48d8 commit bc4eaa7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/gds_api/test_helpers/publishing_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ module PublishingApi

PUBLISHING_API_ENDPOINT = Plek.current.find('publishing-api')

def stub_publishing_api_unreserve_path(base_path, publishing_app)
def stub_publishing_api_unreserve_path(base_path, publishing_app = /.*/)
stub_publishing_api_unreserve_path_with_code(base_path, publishing_app, 200)
end

def stub_publishing_api_unreserve_path_not_found(base_path, publishing_app)
def stub_publishing_api_unreserve_path_not_found(base_path, publishing_app = /.*/)
stub_publishing_api_unreserve_path_with_code(base_path, publishing_app, 404)
end

def stub_publishing_api_unreserve_path_invalid(base_path, publishing_app)
def stub_publishing_api_unreserve_path_invalid(base_path, publishing_app = /.*/)
stub_publishing_api_unreserve_path_with_code(base_path, publishing_app, 422)
end

Expand Down
22 changes: 22 additions & 0 deletions test/test_helpers/publishing_api_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
api_response = publishing_api.unreserve_path("/foo", "myapp")
assert_equal(api_response.code, 200)
end

it "stubs for any app if not specified" do
stub_publishing_api_unreserve_path("/foo")
api_response = publishing_api.unreserve_path("/foo", "myapp")
assert_equal(api_response.code, 200)
end
end

describe "#stub_publishing_api_unreserve_path_not_found" do
Expand All @@ -23,6 +29,14 @@
publishing_api.unreserve_path("/foo", "myapp")
end
end

it "stubs for any app if not specified" do
stub_publishing_api_unreserve_path_not_found("/foo")

assert_raises GdsApi::HTTPNotFound do
publishing_api.unreserve_path("/foo", "myapp")
end
end
end

describe "#stub_publishing_api_unreserve_path_invalid" do
Expand All @@ -33,6 +47,14 @@
publishing_api.unreserve_path("/foo", "myapp")
end
end

it "stubs for any app if not specified" do
stub_publishing_api_unreserve_path_invalid("/foo")

assert_raises GdsApi::HTTPUnprocessableEntity do
publishing_api.unreserve_path("/foo", "myapp")
end
end
end

describe '#request_json_matching predicate' do
Expand Down

0 comments on commit bc4eaa7

Please sign in to comment.