sqm-dashboards/spec/services/disaggregation_loader_spec.rb
Nelson Jovel 0a2c5e02c5 feat: add ability to merge disaggregation data with raw survey data to
produce a cleaned csv with merged income disaggregation columns
2023-06-20 12:22:24 -07:00

35 lines
1.3 KiB
Ruby

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