Skip to content

Commit

Permalink
Fixed rspec errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ngiger committed Jan 5, 2015
1 parent 804b303 commit 17dc26f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 33 deletions.
17 changes: 8 additions & 9 deletions Gemfile.lock
Expand Up @@ -20,16 +20,15 @@ GEM
nokogiri
archive-tar-minitar (0.5.2)
builder (3.2.2)
byebug (3.5.1)
columnize (~> 0.8)
debugger-linecache (~> 1.2)
slop (~> 3.6)
coderay (1.1.0)
columnize (0.9.0)
crack (0.4.2)
safe_yaml (~> 1.0.0)
debugger (1.6.8)
columnize (>= 0.3.1)
debugger-linecache (~> 1.2.0)
debugger-ruby_core_source (~> 1.3.5)
debugger-linecache (1.2.0)
debugger-ruby_core_source (1.3.7)
diff-lcs (1.2.5)
domain_name (0.5.23)
unf (>= 0.0.5, < 1.0.0)
Expand Down Expand Up @@ -57,9 +56,9 @@ GEM
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-debugger (0.2.3)
debugger (~> 1.3)
pry (>= 0.9.10, < 0.11.0)
pry-byebug (2.0.0)
byebug (~> 3.4)
pry (~> 0.10)
rack (1.6.0)
rake (10.4.2)
rdoc (4.2.0)
Expand Down Expand Up @@ -113,7 +112,7 @@ PLATFORMS
DEPENDENCIES
bundler
oddb2xml!
pry-debugger
pry-byebug
rake
rdoc
rspec
Expand Down
35 changes: 17 additions & 18 deletions spec/builder_spec.rb
Expand Up @@ -20,7 +20,7 @@ def buildr_capture(stream)

def check_validation_via_xsd
@oddb2xml_xsd = File.expand_path(File.join(File.dirname(__FILE__), '..', 'oddb2xml.xsd'))
File.exists?(@oddb2xml_xsd).should be_true
File.exists?(@oddb2xml_xsd).should eq true
files = Dir.glob('*.xml')
xsd = Nokogiri::XML::Schema(File.read(@oddb2xml_xsd))
files.each{
Expand All @@ -44,7 +44,6 @@ def check_validation_via_xsd
after(:each) do
Dir.chdir @savedDir if @savedDir and File.directory?(@savedDir)
end

context 'XSD-generation: ' do
let(:cli) do
opts = {}
Expand All @@ -56,8 +55,8 @@ def check_validation_via_xsd

it 'should return true when validating xml against oddb2xml.xsd' do
res = buildr_capture(:stdout){ cli.run }
File.exists?(@article_xml).should be_true
File.exists?(@product_xml).should be_true
File.exists?(@article_xml).should eq true
File.exists?(@product_xml).should eq true
check_validation_via_xsd
end
end
Expand Down Expand Up @@ -86,10 +85,10 @@ def check_validation_via_xsd
res = buildr_capture(:stdout){ cli.run }
res.should match(/products/)
@article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
File.exists?(@article_xml).should be_true
File.exists?(@article_xml).should eq true
article_xml = IO.read(@article_xml)
product_filename = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_product.xml'))
File.exists?(product_filename).should be_true
File.exists?(product_filename).should eq true
unless /1\.8\.7/.match(RUBY_VERSION)
product_xml = IO.read(product_filename)
article_xml.should match(/3TC/)
Expand Down Expand Up @@ -131,7 +130,7 @@ def check_validation_via_xsd
res = buildr_capture(:stdout){ cli.run }
res.should match(/products/)
dat_filename = File.join(Oddb2xml::WorkDir, 'oddb.dat')
File.exists?(dat_filename).should be_true
File.exists?(dat_filename).should eq true
oddb_dat = IO.read(dat_filename)
oddb_dat.should match(/^..2/), "should have a record with '2' in CMUT field"
oddb_dat.should match(/^..3/), "should have a record with '3' in CMUT field"
Expand All @@ -153,7 +152,7 @@ def check_validation_via_xsd
res = buildr_capture(:stdout){ cli.run }
res.should match(/products/)
dat_filename = File.join(Oddb2xml::WorkDir, 'oddb_with_migel.dat')
File.exists?(dat_filename).should be_true
File.exists?(dat_filename).should eq true
oddb_dat = IO.read(dat_filename)
oddb_dat.should match(/1115819012LEVETIRACETAM DESITIN Filmtabl 250 mg 30 Stk/), "should have Desitin"
# oddb_dat.should match(/001349002780100B010710076806206900842/), "should match EAN of Desitin"
Expand All @@ -163,12 +162,11 @@ def check_validation_via_xsd
res = buildr_capture(:stdout){ cli.run }
res.should match(/products/)
dat_filename = File.join(Oddb2xml::WorkDir, 'oddb_with_migel.dat')
File.exists?(dat_filename).should be_true
File.exists?(dat_filename).should eq true
oddb_dat = IO.read(dat_filename)
oddb_dat.should match(/76806206900842/), "should match EAN of Desitin"
end
end

context 'when option -e is given' do
let(:cli) do
opts = {
Expand All @@ -194,7 +192,7 @@ def checkItemForRefdata(doc, pharmacode, isRefdata)
it 'should generate the flag non-refdata' do
res = buildr_capture(:stdout){ cli.run }
@article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
File.exists?(@article_xml).should be_true
File.exists?(@article_xml).should eq true
FileUtils.cp(@article_xml, File.join(Oddb2xml::WorkDir, 'tst-non-refdata.xml'))
article_xml = IO.read(@article_xml)
doc = REXML::Document.new File.new(@article_xml)
Expand Down Expand Up @@ -224,7 +222,7 @@ def checkItemForRefdata(doc, pharmacode, isRefdata)
res.should match(/NonPharma/i)
res.should match(/NonPharma products: #{NrPharmaAndNonPharmaArticles}/)
@article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
File.exists?(@article_xml).should be_true
File.exists?(@article_xml).should eq true
article_xml = IO.read(@article_xml)
doc = REXML::Document.new File.new(@article_xml)
dscrds = XPath.match( doc, "//ART" )
Expand All @@ -237,7 +235,7 @@ def checkItemForRefdata(doc, pharmacode, isRefdata)
res.should match(/NonPharma/i)
res.should match(/NonPharma products: #{NrPharmaAndNonPharmaArticles}/)
@article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
File.exists?(@article_xml).should be_true
File.exists?(@article_xml).should eq true
article_xml = IO.read(@article_xml)
doc = REXML::Document.new File.new(@article_xml)
dscrds = XPath.match( doc, "//ART" )
Expand All @@ -252,7 +250,7 @@ def checkItemForRefdata(doc, pharmacode, isRefdata)
res.should match(/NonPharma/i)
res.should match(/NonPharma products: #{NrPharmaAndNonPharmaArticles}/)
@article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
File.exists?(@article_xml).should be_true
File.exists?(@article_xml).should eq true
article_xml = IO.read(@article_xml)
doc = REXML::Document.new File.new(@article_xml)
dscrds = XPath.match( doc, "//ART" )
Expand All @@ -266,7 +264,7 @@ def checkItemForRefdata(doc, pharmacode, isRefdata)
res = buildr_capture(:stdout){ cli.run }
# check limitations
limitation_filename = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_limitation.xml'))
File.exists?(limitation_filename).should be_true
File.exists?(limitation_filename).should eq true
limitation_xml = IO.read(limitation_filename)
limitation_xml.should match(/Die aufgeführten Präparat/)
doc = REXML::Document.new File.new(limitation_filename)
Expand All @@ -281,7 +279,7 @@ def checkItemForRefdata(doc, pharmacode, isRefdata)
it 'should emit a correct oddb_article.xml' do
res = buildr_capture(:stdout){ cli.run }
@article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
File.exists?(@article_xml).should be_true
File.exists?(@article_xml).should eq true
article_xml = IO.read(@article_xml)
doc = REXML::Document.new File.new(@article_xml)
unless /1\.8\.7/.match(RUBY_VERSION)
Expand Down Expand Up @@ -338,7 +336,7 @@ def checkItemForRefdata(doc, pharmacode, isRefdata)
res = buildr_capture(:stdout){ cli.run }
res.should match(/products/)
product_filename = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_product.xml'))
File.exists?(product_filename).should be_true
File.exists?(product_filename).should eq true

unless /1\.8\.7/.match(RUBY_VERSION)
# check articles
Expand Down Expand Up @@ -370,7 +368,7 @@ def checkItemForSALECD(doc, pharmacode, expected)
it 'should generate the flag SALECD' do
res = buildr_capture(:stdout){ cli.run }
@article_xml = File.expand_path(File.join(Oddb2xml::WorkDir, 'oddb_article.xml'))
File.exists?(@article_xml).should be_true
File.exists?(@article_xml).should eq true
FileUtils.cp(@article_xml, File.join(Oddb2xml::WorkDir, 'tst-SALECD.xml'))
article_xml = IO.read(@article_xml)
doc = REXML::Document.new File.new(@article_xml)
Expand All @@ -379,4 +377,5 @@ def checkItemForSALECD(doc, pharmacode, expected)
checkItemForSALECD(doc, "0598003", 'I') # SOFRADEX
end
end

end
12 changes: 6 additions & 6 deletions spec/cli_spec.rb
Expand Up @@ -74,7 +74,7 @@ def cli_capture(stream)
it 'should create tar.gz file' do
cli_capture(:stdout) { cli.run }.should match(/Pharma/)
file = Dir.glob(File.join(Dir.pwd, 'oddb_*.tar.gz')).first
File.exists?(file).should be_true
File.exists?(file).should eq true
end
it 'should not create any xml file' do
cli_capture(:stdout) { cli.run }.should match(/Pharma/)
Expand All @@ -101,7 +101,7 @@ def cli_capture(stream)
it 'should create zip file' do
cli_capture(:stdout) { cli.run }.should match(/Pharma/)
file = Dir.glob(File.join(Dir.pwd, 'oddb_*.zip')).first
File.exists?(file).should be_true
File.exists?(file).should eq true
end
it 'should not create any xml file' do
Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.xml')).each do |file| FileUtil.rm_f(file) end
Expand Down Expand Up @@ -142,7 +142,7 @@ def cli_capture(stream)
'oddb_code.xml'
].length
Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.xml')).each do |file|
File.exists?(file).should be_true
File.exists?(file).should eq true
end.to_a.length.should equal expected
end
end
Expand Down Expand Up @@ -177,7 +177,7 @@ def cli_capture(stream)
'swiss_code.xml'
].length
Dir.glob(File.join(Oddb2xml::WorkDir, 'swiss_*.xml')).each do |file|
File.exists?(file).should be_true
File.exists?(file).should eq true
end.to_a.length.should equal expected
end
end
Expand Down Expand Up @@ -214,7 +214,7 @@ def cli_capture(stream)
'oddb_code.xml'
].length
Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.xml')).each do |file|
File.exists?(file).should be_true
File.exists?(file).should eq true
end.to_a.length.should equal expected
end
end
Expand Down Expand Up @@ -245,7 +245,7 @@ def cli_capture(stream)
'oddb_medizinalperson.xml',
].length
Dir.glob(File.join(Oddb2xml::WorkDir, 'oddb_*.xml')).each do |file|
File.exists?(file).should be_true
File.exists?(file).should eq true
end.to_a.length.should equal expected
end
end
Expand Down

0 comments on commit 17dc26f

Please sign in to comment.