You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sqm-dashboards/spec/services/disaggregation_loader_spec.rb

36 lines
1.3 KiB

require 'rails_helper'
require 'fileutils'
RSpec.describe DisaggregationLoader do
let(:path) do
Rails.root.join('spec', 'fixtures', 'disaggregation')
end
let(:academic_year) { create(:academic_year, range: '2022-23') }
let(:district) { create(:district, name: 'Maynard Public Schools') }
context '.load' do
it 'loads data from the file into a hash' do
data = DisaggregationLoader.new(path:).load
expect(data.values.first.lasid).to eq('1')
expect(data.values.first.academic_year).to eq('2022-23')
expect(data.values.first.district).to eq('Maynard Public Schools')
expect(data.values.first.income).to eq('Free Lunch')
expect(data.values.last.lasid).to eq('500')
expect(data.values.last.academic_year).to eq('2022-23')
expect(data.values.last.district).to eq('Maynard Public Schools')
expect(data.values.last.income).to eq('Not Eligible')
expect(data[['1', 'Maynard Public Schools', '2022-23']].income).to eq('Free Lunch')
expect(data[['2', 'Maynard Public Schools', '2022-23']].income).to eq('Not Eligible')
expect(data[['3', 'Maynard Public Schools', '2022-23']].income).to eq('Reduced Lunch')
end
end
context 'Creating a new loader' do
it 'creates a directory for the loader file' do
DisaggregationLoader.new(path:)
expect(path).to exist
end
end
end