spec/extractor_spec.rb in oddb2xml-1.8.5 vs spec/extractor_spec.rb in oddb2xml-1.8.6

- old
+ new

@@ -15,28 +15,31 @@ context 'should handle articles with and without pharmacode' do subject do dat = File.read(File.join(Oddb2xml::SpecData, 'Preparations.xml')) Oddb2xml::BagXmlExtractor.new(dat).to_hash end - it { + it "should handle pub_price for 1699947 correctly" do @items = subject.to_hash with_pharma = @items['1699947'] expect(with_pharma).not_to be_nil expect(with_pharma[:atc_code]).not_to be_nil expect(with_pharma[:pharmacodes]).not_to be_nil expect(with_pharma[:packages].size).to eq(1) expect(with_pharma[:packages].first[0]).to eq('1699947') expect(with_pharma[:packages].first[1][:prices][:pub_price][:price]).to eq('205.3') expect(@items.size).to eq(5) + end + it "should handle pub_price for 7680620690084 correctly" do + @items = subject.to_hash no_pharma = @items['7680620690084'] expect(no_pharma).not_to be_nil expect(no_pharma[:atc_code]).not_to be_nil expect(no_pharma[:pharmacodes]).not_to be_nil expect(no_pharma[:packages].size).to eq(1) expect(no_pharma[:packages].first[0]).to eq('7680620690084') expect(no_pharma[:packages].first[1][:prices][:pub_price][:price]).to eq('27.8') - } + end end end describe Oddb2xml::SwissIndexExtractor do it "pending" @@ -170,16 +173,18 @@ it { expect(subject.to_hash.keys.first).to eq("7680172330681") } it { expect(subject.to_hash.values.first[:vat]).to eq("2") } it { expect(subject.to_hash.values.first[:price]).to eq("15.76") } it { expect(subject.to_hash.values.first[:pub_price]).to eq("24.30") } it { expect(subject.to_hash.values.first[:pharmacode]).to eq("0020652") } - + it 'should set the correct SALECD cmut code' do expect(subject.to_hash.values.first[:cmut]).to eq("2") end end - - x =%( - Record-Art 1 Länge 97 - :vat => $2.to_s, - :price => sprintf("%.2f", line[60,6].gsub(/(\d{2})$/, '.\1').to_f), - :pub_price => sprintf("%.2f", line[66,6].gsub(/(\d{2})$/, '.\1').to_f), - = - ) + context 'when SOFRADEX is given' do + subject do + dat = <<-DAT +1130598003SOFRADEX Gtt Auric 8 ml 000718001545300B120130076803169501572\r\n + DAT + Oddb2xml::ZurroseExtractor.new(dat) + end + #it { expect(subject.to_hash.keys.first).to eq("7680316950157") } + it "should set the correct SALECD cmut code" do expect(subject.to_hash.values.first[:cmut]).to eq("3") end + end end