Sha256: 5e3fdde2adfe108da1cc26c4860b154e617a17e163cee7a8ec6cbafcd4ea2fa1
Contents?: true
Size: 1.27 KB
Versions: 14
Compression:
Stored size: 1.27 KB
Contents
require 'spec_helper' describe UsdaNutrientDatabase::Import::Downloader do let(:downloader) { described_class.new('tmp/usda') } let(:extraction_path) { "#{directory}/#{version}" } let(:directory) { 'tmp/usda' } let(:version) { 'sr25' } let(:filenames) do [ 'DATA_SRC.txt', 'DATSRCLN.txt', 'DERIV_CD.txt', 'FD_GROUP.txt', 'FOOD_DES.txt', 'FOOTNOTE.txt', 'LANGDESC.txt', 'LANGUAL.txt', 'NUTR_DEF.txt', 'NUT_DATA.txt', 'SRC_CD.txt', 'WEIGHT.txt', 'sr25_doc.pdf' ] end describe '#download_and_unzip' do before do stub_request(:get, /.*/). to_return(body: File.read('spec/support/sr25.zip')) downloader.download_and_unzip end after { downloader.cleanup } it 'should download and extract all files' do filenames.each do |filename| expect(File.exist?("#{extraction_path}/#{filename}")).to eql(true) end end end describe '#cleanup' do before do stub_request(:get, /.*/). to_return(body: File.read('spec/support/sr25.zip')) downloader.download_and_unzip downloader.cleanup end it 'should remove all of the extracted files' do filenames.each do |filename| expect(File.exist?("#{extraction_path}/#{filename}")).to eql(false) end end end end
Version data entries
14 entries across 14 versions & 1 rubygems