spec/downloader_spec.rb in oddb2xml-1.0.6 vs spec/downloader_spec.rb in oddb2xml-1.0.7
- old
+ new
@@ -2,11 +2,11 @@
require 'spec_helper'
shared_examples_for 'any downloader' do
# this takes 5 sec. by call for sleep
- it 'should count retry times as retrievable or not' do
+ it 'should count retry times as retrievable or not', :slow => true do
expect {
Array.new(3).map do
Thread.new do
@downloader.send(:retrievable?).should be(true)
end
@@ -33,32 +33,55 @@
it 'should return valid xml' do
xml.should =~ /xml\sversion="1.0"/
xml.should =~ /Preparations/
xml.should =~ /DescriptionDe/
end
- it 'should cleanup current directory' do
+ it 'should clean up current directory' do
xml.should_not raise_error(Timeout::Error)
File.exist?('XMLPublications.zip').should be(false)
end
end
end
describe Oddb2xml::SwissIndexDownloader do
include ServerMockHelper
before(:each) do
setup_swiss_index_server_mock
- @downloader = Oddb2xml::SwissIndexDownloader.new()
end
- it_behaves_like 'any downloader'
- context 'when download_by is called with DE' do
- let(:xml) { @downloader.download_by('DE') }
- it 'should parse hash to xml' do
- xml.should be_a String
- xml.length.should_not == 0
+ context 'Pharma' do
+ before(:each) do
+ @downloader = Oddb2xml::SwissIndexDownloader.new(:pharma)
end
- it 'should return valid xml' do
- xml.should =~ /xml\sversion="1.0"/
- xml.should =~ /ITEM/
- xml.should =~ /PHAR/
+ it_behaves_like 'any downloader'
+ context 'when download_by is called with DE' do
+ let(:xml) { @downloader.download_by('DE') }
+ it 'should parse response hash to xml' do
+ xml.should be_a String
+ xml.length.should_not == 0
+ xml.should =~ /xml\sversion="1.0"/
+ end
+ it 'should return valid xml' do
+ xml.should =~ /PHAR/
+ xml.should =~ /ITEM/
+ end
end
end
+ context 'NonPharma' do
+ before(:each) do
+ @downloader = Oddb2xml::SwissIndexDownloader.new(:nonpharma)
+ end
+ it_behaves_like 'any downloader'
+ context 'when download_by is called with DE' do
+ let(:xml) { @downloader.download_by('DE') }
+ it 'should parse response hash to xml' do
+ xml.should be_a String
+ xml.length.should_not == 0
+ xml.should =~ /xml\sversion="1.0"/
+ end
+ it 'should return valid xml' do
+ xml.should =~ /NONPHAR/
+ xml.should =~ /ITEM/
+ end
+ end
+ end
+
end