# encoding: utf-8 require 'spec_helper' require "rexml/document" require 'webmock/rspec' include REXML RUN_ALL = true describe Oddb2xml::Builder do raise "Cannot rspec in directroy containing a spac" if / /.match(Oddb2xml::SpecData) NrExtendedArticles = 34 NrSubstances = 14 NrLimitations = 5 NrInteractions = 5 NrCodes = 5 NrProdno = 23 NrPackages = 24 NrProducts = 19 RegExpDesitin = /1125819012LEVETIRACETAM DESITIN Mini Filmtab 250 mg 30 Stk/ include ServerMockHelper def check_artikelstamm_xml(key, expected_value) expect(@artikelstamm_name).not_to be nil expect(@inhalt).not_to be nil unless @inhalt.index(expected_value) puts expected_value end # binding.pry unless @inhalt.index(expected_value) expect(@inhalt.index(expected_value)).not_to be nil end def common_run_init(options = {}) @savedDir = Dir.pwd @oddb2xml_xsd = File.expand_path(File.join(File.dirname(__FILE__), '..', 'oddb2xml.xsd')) @oddb_calc_xsd = File.expand_path(File.join(File.dirname(__FILE__), '..', 'oddb_calc.xsd')) @elexis_v5_xsd = File.expand_path(File.join(__FILE__, '..', '..', 'Elexis_Artikelstamm_v5.xsd')) @elexis_v5_csv = File.join(Oddb2xml::WorkDir, 'Elexis_Artikelstamm_v5.csv') expect(File.exist?(@oddb2xml_xsd)).to eq true expect(File.exist?(@oddb_calc_xsd)).to eq true expect(File.exist?(@elexis_v5_xsd)).to eq true cleanup_directories_before_run FileUtils.makedirs(Oddb2xml::WorkDir) Dir.chdir(Oddb2xml::WorkDir) mock_downloads end after(:all) do Dir.chdir @savedDir if @savedDir and File.directory?(@savedDir) end context 'when artikelstamm option is given' do before(:all) do common_run_init options = Oddb2xml::Options.parse(['--artikelstamm']) # , '--log']) # @res = buildr_capture(:stdout){ Oddb2xml::Cli.new(options).run } Oddb2xml::Cli.new(options).run # to debug @artikelstamm_name = File.join(Oddb2xml::WorkDir, "artikelstamm_#{Date.today.strftime('%d%m%Y')}_v5.xml") @doc = Nokogiri::XML(File.open(@artikelstamm_name)) # @rexml = REXML::Document.new File.read(@artikelstamm_name) @inhalt = IO.read(@artikelstamm_name) end it 'should exist' do expect(File.exists?(@artikelstamm_name)).to eq true end it 'should create transfer.ut8' do expect(File.exists?(File.join(Oddb2xml::Downloads, 'transfer.utf8'))).to eq true end it 'should have a comment' do expect(@inhalt).to match /