Slide 9
Slide 9 text
describe '/v3/cities' do
it "returns a list of cities" do
property_of do
state = choose(*states)
limit = range(0, 25)
[state, limit]
end.check do |(state, limit)|
params = { state: space_to_dash(state), limit: limit }
get url, params
# It was a success
expect(last_response.status).to eq(200)
# Has the expected structure
expect(json_body).to be_a(Array)
# Has the expected number of results
expect(json_body.count).to be >= 0
expect(json_body.count).to be <= limit
# Results have the expected fields
json_body.each do |record|
expect(record.keys.sort).to eq(%w(name state url))
end
# Results are sorted properly
if json_body.first and json_body.second
expect(json_body.first['name']).to be <
json_body.second['name']
end
end
end
end