Permalink
Browse files

Skip MiniTest specs when minitest is not available

  • Loading branch information...
1 parent cb87ca0 commit e53170b2bad97c370dbb63083e1106b5b65d97fa @nicksieger nicksieger committed Jan 28, 2012
Showing with 33 additions and 28 deletions.
  1. +33 −28 acceptance/verification_spec.rb
@@ -43,39 +43,44 @@
end
end
-describe "MiniTest::Unit acceptance" do
- it "should generate two XML files" do
- File.exist?(File.join(REPORTS_DIR, 'TEST-MiniTestExampleTestOne.xml')).should == true
- File.exist?(File.join(REPORTS_DIR, 'TEST-MiniTestExampleTestTwo.xml')).should == true
- end
+begin # Ensure Minitest is available otherwise tests are irrelevant
+ require 'minitest/unit'
+ describe "MiniTest::Unit acceptance" do
+ it "should generate two XML files" do
+ File.exist?(File.join(REPORTS_DIR, 'TEST-MiniTestExampleTestOne.xml')).should == true
+ File.exist?(File.join(REPORTS_DIR, 'TEST-MiniTestExampleTestTwo.xml')).should == true
+ end
- it "should have one error and one failure for MiniTestExampleTestOne" do
- doc = File.open(File.join(REPORTS_DIR, 'TEST-MiniTestExampleTestOne.xml')) do |f|
- REXML::Document.new(f)
+ it "should have one error and one failure for MiniTestExampleTestOne" do
+ doc = File.open(File.join(REPORTS_DIR, 'TEST-MiniTestExampleTestOne.xml')) do |f|
+ REXML::Document.new(f)
+ end
+ doc.root.attributes["errors"].should == "1"
+ doc.root.attributes["failures"].should == "1"
+ doc.root.attributes["assertions"].should == "1"
+ doc.root.attributes["tests"].should == "1"
+ doc.root.elements.to_a("/testsuite/testcase").size.should == 1
+ doc.root.elements.to_a("/testsuite/testcase/error").size.should == 1
+ doc.root.elements.to_a("/testsuite/testcase/failure").size.should == 1
+ doc.root.elements.to_a("/testsuite/system-out").first.texts.inject("") do |c,e|
+ c << e.value; c
+ end.strip.should == "Some <![CDATA[on stdout]]>"
end
- doc.root.attributes["errors"].should == "1"
- doc.root.attributes["failures"].should == "1"
- doc.root.attributes["assertions"].should == "1"
- doc.root.attributes["tests"].should == "1"
- doc.root.elements.to_a("/testsuite/testcase").size.should == 1
- doc.root.elements.to_a("/testsuite/testcase/error").size.should == 1
- doc.root.elements.to_a("/testsuite/testcase/failure").size.should == 1
- doc.root.elements.to_a("/testsuite/system-out").first.texts.inject("") do |c,e|
- c << e.value; c
- end.strip.should == "Some <![CDATA[on stdout]]>"
- end
- it "should have no errors or failures for MiniTestExampleTestTwo" do
- doc = File.open(File.join(REPORTS_DIR, 'TEST-MiniTestExampleTestTwo.xml')) do |f|
- REXML::Document.new(f)
+ it "should have no errors or failures for MiniTestExampleTestTwo" do
+ doc = File.open(File.join(REPORTS_DIR, 'TEST-MiniTestExampleTestTwo.xml')) do |f|
+ REXML::Document.new(f)
+ end
+ doc.root.attributes["errors"].should == "0"
+ doc.root.attributes["failures"].should == "0"
+ doc.root.attributes["assertions"].should == "1"
+ doc.root.attributes["tests"].should == "1"
+ doc.root.elements.to_a("/testsuite/testcase").size.should == 1
+ doc.root.elements.to_a("/testsuite/testcase/failure").size.should == 0
end
- doc.root.attributes["errors"].should == "0"
- doc.root.attributes["failures"].should == "0"
- doc.root.attributes["assertions"].should == "1"
- doc.root.attributes["tests"].should == "1"
- doc.root.elements.to_a("/testsuite/testcase").size.should == 1
- doc.root.elements.to_a("/testsuite/testcase/failure").size.should == 0
end
+rescue LoadError
+ warn "Skipping MiniTest as it is unavailable"
end
describe "RSpec acceptance" do

0 comments on commit e53170b

Please sign in to comment.