spec/extractor_spec.rb in oddb2xml-1.8.1 vs spec/extractor_spec.rb in oddb2xml-1.8.2
- old
+ new
@@ -12,11 +12,11 @@
end
describe Oddb2xml::BagXmlExtractor do
context 'should handle articles with and without pharmacode' do
subject do
- dat = File.read(File.expand_path('../data/Preparation.xml', __FILE__))
+ dat = File.read(File.join(Oddb2xml::SpecData, 'Preparations.xml'))
Oddb2xml::BagXmlExtractor.new(dat).to_hash
end
it {
@items = subject.to_hash
with_pharma = @items['1699947']
@@ -61,13 +61,13 @@
describe Oddb2xml::SwissmedicInfoExtractor do
context 'when transfer.dat is empty' do
subject { Oddb2xml::SwissmedicInfoExtractor.new("") }
it { expect(subject.to_hash).to be_empty }
end
- context 'can parse swissmedic_packages.xlsx' do
+ context 'can parse swissmedic_package.xlsx' do
it {
- filename = File.join(File.dirname(__FILE__), 'data/swissmedic_packages.xlsx')
+ filename = File.join(Oddb2xml::SpecData, 'swissmedic_package.xlsx')
@packs = Oddb2xml::SwissmedicExtractor.new(filename, :package).to_hash
expect(@packs.size).to eq(14)
serocytol = nil
@packs.each{|pack|
serocytol = pack[1] if pack[0].to_s == '00274001'
@@ -77,35 +77,35 @@
expect(serocytol[:package_size]).to eq('3')
expect(serocytol[:einheit_swissmedic]).to eq('Suppositorien')
expect(serocytol[:substance_swissmedic]).to eq('globulina equina (immunisé avec coeur, tissu pulmonaire, reins de porcins)')
}
end
- context 'can parse swissmedic_fridges.xlsx' do
+ context 'can parse swissmedic_fridge.xlsx' do
it {
- filename = File.join(File.dirname(__FILE__), 'data/swissmedic_fridges.xlsx')
+ filename = File.join(Oddb2xml::SpecData, 'swissmedic_fridge.xlsx')
@packs = Oddb2xml::SwissmedicExtractor.new(filename, :fridge).to_arry
expect(@packs.size).to eq(17)
expect(@packs[0]).to eq("58618")
expect(@packs[1]).to eq("00696")
}
end
context 'can parse swissmedic_orphans.xls' do
it {
- filename = File.join(File.dirname(__FILE__), 'data/swissmedic_orphan.xlsx')
+ filename = File.join(Oddb2xml::SpecData, 'swissmedic_orphan.xlsx')
expect(File.exists?(filename)).to eq(true), "File #{filename} must exists"
@packs = Oddb2xml::SwissmedicExtractor.new(filename, :orphan).to_arry
- expect(@packs.size).to eq(79)
+ expect(@packs.size).to eq(78)
expect(@packs.first).to eq("62132")
expect(@packs[7]).to eq("00687")
}
end
end
describe Oddb2xml::EphaExtractor do
context 'can parse epha_interactions.csv' do
it {
- filename = File.join(File.dirname(__FILE__), 'data/epha_interactions.csv')
+ filename = File.join(Oddb2xml::SpecData, 'epha_interactions.csv')
string = IO.read(filename)
@actions = Oddb2xml::EphaExtractor.new(string).to_arry
expect(@actions.size).to eq(2)
}
end
@@ -122,28 +122,27 @@
end
context 'when transfer.dat is nil' do
subject { Oddb2xml::ZurroseExtractor.new(nil) }
it { expect(subject.to_hash).to be_empty }
end
- context 'when as line break mark \n is given' do
+ context 'it should work also when \n is the line ending' do
subject do
dat = <<-DAT
1120020244FERRO-GRADUMET Depottabl 30 Stk 000895001090300C060710076803164401152
DAT
Oddb2xml::ZurroseExtractor.new(dat)
end
- it { expect(subject.to_hash).to be_empty }
+ it { subject.to_hash.size.should eq(1) }
end
context 'when expected line is given' do
subject do
dat = <<-DAT
1120020244FERRO-GRADUMET Depottabl 30 Stk 000895001090300C060710076803164401152\r\n
DAT
Oddb2xml::ZurroseExtractor.new(dat)
end
it { expect(subject.to_hash.keys.length).to eq(1) }
it { expect(subject.to_hash.keys.first).to eq("7680316440115") }
- it { expect(subject.to_hash.values.first[:vat]).to eq("2") }
it { expect(subject.to_hash.values.first[:price]).to eq("8.95") }
end
context 'when Estradiol Creme is given' do
subject do
dat = <<-DAT