Skip to content

Commit

Permalink
Make the open schools request spec dynamic
Browse files Browse the repository at this point in the history
This test started failing because the number of open schools seems to
have changed from 81 to 80. Here, it's not the number that's important
but that the number matches the quantity in the test set.
  • Loading branch information
peteryates committed Sep 2, 2023
1 parent dd93466 commit ee94923
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion spec/requests/get_open_schools_spec.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
require 'spec_helper'
require 'json'
require 'csv'

RSpec.describe 'GET /open_schools' do
let(:open_school_count) do
CSV
.read(Dir.glob('tmp/*test-set*').pop, headers: true)
.map { |r| r['EstablishmentStatus (name)'] }
.count('Open')
end

it 'returns a list of open schools' do
get '/api/open_schools'
expect(last_response.status).to eq(200)

resp = JSON.parse(last_response.body)
expect(resp['data'].length).to eq(81)
expect(resp['data'].length).to eq(open_school_count)

expect(resp).to be_valid_against_openapi_schema('SchoolList')
end
Expand Down

0 comments on commit ee94923

Please sign in to comment.