spec/extractor_spec.rb in oddb2xml-2.1.6 vs spec/extractor_spec.rb in oddb2xml-2.1.7
- old
+ new
@@ -60,14 +60,36 @@
describe Oddb2xml::MigelExtractor do
it "pending"
end
describe Oddb2xml::SwissmedicInfoExtractor do
+ include ServerMockHelper
before(:each) do
- setup_epha_atc_csv_mock
+ setup_swissmedic_info_server_mock
+ @downloader = Oddb2xml::SwissmedicInfoDownloader.new
end
+ context 'builds fachfinfo' do
+ it {
+ xml = @downloader.download
+ @infos = Oddb2xml::SwissmedicInfoExtractor.new(xml).to_hash
+ expect(@infos.size).to eq(1)
+ erbiumcitrat = nil
+ @infos['de'].each{|info|
+ erbiumcitrat = info if /Erbiumcitrat/.match(info[:name])
+ }
+ expect(erbiumcitrat[:owner]).to eq('CBI Medical Products Vertriebs GmbH')
+ expect(erbiumcitrat[:paragraph].to_s).to match(/Packungen/)
+ expect(erbiumcitrat[:paragraph].to_s).to match(/Stand der Information/)
+ expect(erbiumcitrat[:paragraph].to_s).to match(/Zulassungsinhaberin/)
+ }
+ end
+end
+describe Oddb2xml::SwissmedicExtractor do
+ before(:each) do
+ setup_epha_atc_csv_mock
+ end
context 'when transfer.dat is empty' do
subject { Oddb2xml::SwissmedicInfoExtractor.new("") }
it { expect(subject.to_hash).to be_empty }
end
context 'can parse swissmedic_package.xlsx' do
@@ -121,11 +143,10 @@
describe Oddb2xml::MedregbmExtractor do
it "pending"
end
describe Oddb2xml::ZurroseExtractor do
-if false
context 'when transfer.dat is empty' do
subject { Oddb2xml::ZurroseExtractor.new("") }
it { expect(subject.to_hash).to be_empty }
end
context 'when transfer.dat is nil' do
@@ -198,15 +219,14 @@
dat = <<-DAT
1128807890Ethacridin lactat 1\069 100ml 0009290013701000000000000000000000002\r\n
DAT
Oddb2xml::ZurroseExtractor.new(dat, true)
end
- #it { expect(subject.to_hash.keys.first).to eq("7680316950157") }
+ it { expect(subject.to_hash.keys.first).to eq("0000008807890") }
it "should set the correct SALECD cmut code" do expect(subject.to_hash.values.first[:cmut]).to eq("2") end
- it "should set the correct SALECD description" do expect(subject.to_hash.values.first[:description]).to eq("Ethacridin lactat 1 100ml") end
- end if false
-end
+ it "should set the correct SALECD description" do expect(subject.to_hash.values.first[:description]).to match(/Ethacridin lactat 1.+ 100ml/) end
+ end
context 'when parsing examples' do
subject do
filename = File.expand_path(File.join(__FILE__, '..', 'data', 'zurrose_transfer.dat'))
Oddb2xml::ZurroseExtractor.new(filename, true)
end
@@ -225,9 +245,7 @@
expect(item[:description]).to eq(value)
end
}
end
-
-
end