Add specs for /parks/:code
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "Api::V1::Parks", type: :request do
|
||||
describe "GET /index" do
|
||||
describe "GET /parks" do
|
||||
it "returns parks" do
|
||||
get api_v1_parks_url
|
||||
expect(response).to have_http_status(:success)
|
||||
@@ -34,4 +34,21 @@ RSpec.describe "Api::V1::Parks", type: :request do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /parks/:code" do
|
||||
it "returns :not_found for unknown codes" do
|
||||
get api_v1_park_url("foo")
|
||||
expect(response).to have_http_status(:not_found)
|
||||
end
|
||||
|
||||
it "returns the park" do
|
||||
get api_v1_park_url("crla")
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(response.parsed_body).to match(
|
||||
hash_including(
|
||||
code: "crla", name: "Crater Lake National Park", states: "OR"
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user