buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From boisv...@apache.org
Subject svn commit: r917108 - /buildr/trunk/spec/spec_helpers.rb
Date Sun, 28 Feb 2010 03:24:18 GMT
Author: boisvert
Date: Sun Feb 28 03:24:17 2010
New Revision: 917108

URL: http://svn.apache.org/viewvc?rev=917108&view=rev
Log:
Missing spec helper part of BUILDR-386

Modified:
    buildr/trunk/spec/spec_helpers.rb

Modified: buildr/trunk/spec/spec_helpers.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/spec_helpers.rb?rev=917108&r1=917107&r2=917108&view=diff
==============================================================================
--- buildr/trunk/spec/spec_helpers.rb (original)
+++ buildr/trunk/spec/spec_helpers.rb Sun Feb 28 03:24:17 2010
@@ -121,6 +121,23 @@
     def show(message)
       MessageWithSeverityMatcher.new :puts, message
     end
+    
+    # Yields a block that should try exiting the application.
+    # Accepts 
+    #
+    # For example:
+    #   test_exit(1) {  puts "Hello" ; exit(1) }.should show("Hello")
+    #     
+    def test_exit(status = nil)
+      return lambda {
+        begin
+          yield
+          raise "Exit was not called!"
+        rescue SystemExit => e
+          raise "Exit status incorrect! Expected: #{status}, got #{e.status}" if status &&
(e.status != status) 
+        end
+      }
+    end
 
     class ::Rake::Task
       alias :execute_without_a_record :execute



Mime
View raw message