spec/downloader_spec.rb in oddb2xml-1.2.6 vs spec/downloader_spec.rb in oddb2xml-1.2.9

- old
+ new

@@ -47,11 +47,11 @@ before(:each) do setup_swiss_index_server_mock end context 'Pharma with DE' do before(:each) do - @downloader = Oddb2xml::SwissIndexDownloader.new(:pharma, 'DE') + @downloader = Oddb2xml::SwissIndexDownloader.new({}, :pharma, 'DE') end it_behaves_like 'any downloader' context 'when download_by is called with DE' do let(:xml) { @downloader.download } it 'should parse response hash to xml' do @@ -65,11 +65,11 @@ end end end context 'NonPharma with FR' do before(:each) do - @downloader = Oddb2xml::SwissIndexDownloader.new(:nonpharma, 'FR') + @downloader = Oddb2xml::SwissIndexDownloader.new({}, :nonpharma, 'FR') end it_behaves_like 'any downloader' context 'when download_by is called with FR' do let(:xml) { @downloader.download } it 'should parse response hash to xml' do @@ -92,34 +92,34 @@ setup_swissmedic_server_mock @downloader = Oddb2xml::SwissmedicDownloader.new(:orphans) end it_behaves_like 'any downloader' context 'download_by for orphans xls' do - let(:io) { @downloader.download } - it 'should return valid IO' do - io.should be_a IO - io.bytes.should_not nil + let(:bin) { @downloader.download } + it 'should return valid Binary-String' do + bin.should be_a String + bin.bytes.should_not nil end it 'should clean up current directory' do - io.should_not raise_error(Timeout::Error) + bin.should_not raise_error(Timeout::Error) File.exist?('oddb_orphans.xls').should be(false) end end end context 'fridges' do before(:each) do setup_swissmedic_server_mock @downloader = Oddb2xml::SwissmedicDownloader.new(:fridges) end context 'download_by for fridges xls' do - let(:io) { @downloader.download } - it 'should return valid IO' do - io.should be_a IO - io.bytes.should_not nil + let(:bin) { @downloader.download } + it 'should return valid Binary-String' do + bin.should be_a String + bin.bytes.should_not nil end it 'should clean up current directory' do - io.should_not raise_error(Timeout::Error) + bin.should_not raise_error(Timeout::Error) File.exist?('oddb_fridges.xls').should be(false) end end end end @@ -131,11 +131,11 @@ @downloader = Oddb2xml::SwissmedicInfoDownloader.new end it_behaves_like 'any downloader' context 'when download is called' do let(:xml) { @downloader.download } - it 'should parse zip to string' do + it 'should parse zip to String' do xml.should be_a String xml.length.should_not == 0 end it 'should return valid xml' do xml.should =~ /xml\sversion="1.0"/ @@ -155,36 +155,76 @@ setup_epha_server_mock @downloader = Oddb2xml::EphaDownloader.new end it_behaves_like 'any downloader' context 'when download is called' do - let(:io) { @downloader.download } - it 'should read csv to IO Object' do - io.should be_a IO - io.bytes.should_not nil + let(:csv) { @downloader.download } + it 'should read csv as String' do + csv.should be_a String + csv.bytes.should_not nil end it 'should clean up current directory' do - io.should_not raise_error(Timeout::Error) + csv.should_not raise_error(Timeout::Error) File.exist?('epha_interactions.csv').should be(false) end end end -describe Oddb2xml::YweseeBMDownloader do +describe Oddb2xml::BMUpdateDownloader do include ServerMockHelper before(:each) do - setup_ywesee_server_mock - @downloader = Oddb2xml::YweseeBMDownloader.new + setup_bm_update_server_mock + @downloader = Oddb2xml::BMUpdateDownloader.new end it_behaves_like 'any downloader' context 'when download is called' do - let(:io) { @downloader.download } - it 'should read txt to IO Object' do - io.should be_a IO - io.bytes.should_not nil + let(:txt) { @downloader.download } + it 'should read txt as String' do + txt.should be_a String + txt.bytes.should_not nil end it 'should clean up current directory' do - io.should_not raise_error(Timeout::Error) - File.exist?('ywesee_bm_update.txt').should be(false) + txt.should_not raise_error(Timeout::Error) + File.exist?('oddb2xml_files_bm_update.txt').should be(false) + end + end +end + +describe Oddb2xml::LppvDownloader do + include ServerMockHelper + before(:each) do + setup_lppv_server_mock + @downloader = Oddb2xml::LppvDownloader.new + end + it_behaves_like 'any downloader' + context 'when download is called' do + let(:txt) { @downloader.download } + it 'should read txt as String' do + txt.should be_a String + txt.bytes.should_not nil + end + it 'should clean up current directory' do + txt.should_not raise_error(Timeout::Error) + File.exist?('oddb2xml_files_lppv.txt').should be(false) + end + end +end + +describe Oddb2xml::MigelDownloader do + include ServerMockHelper + before(:each) do + setup_migel_server_mock + @downloader = Oddb2xml::MigelDownloader.new + end + it_behaves_like 'any downloader' + context 'when download is called' do + let(:bin) { @downloader.download } + it 'should read xls as Binary-String' do + bin.should be_a String + bin.bytes.should_not nil + end + it 'should clean up current directory' do + bin.should_not raise_error(Timeout::Error) + File.exist?('oddb2xml_files_nonpharma.txt').should be(false) end end end