Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

change execution order so exceptions in run_code block stop building

  • Loading branch information...
commit ffd6bd7a5b054ce3be50564a1d1235475e3b526b 1 parent ad5ee08
Konstantin Haase authored June 14, 2010
3  lib/gem_tools.rb
@@ -54,8 +54,9 @@ module GemTools
54 54
   CODE = <<-RUBY.gsub /^\s+/, ''
55 55
     require 'rubygems'
56 56
     require 'gem_tools'
57  
-    File.open('Makefile', 'w') { |f| f.puts 'all:', 'install:' }
58 57
     Gem::Specification.load("../%s").run_code!
  58
+    # If code raises an error, we don't get here!
  59
+    File.open('Makefile', 'w') { |f| f.puts 'all:', 'install:' }
59 60
   RUBY
60 61
 
61 62
   module ClassMethods
1  spec/gem-tools-example-run-code.gemspec
... ...
@@ -1,7 +1,6 @@
1 1
 require 'gem_tools'
2 2
 
3 3
 Gem::Specification.new do |s|
4  
-  s.name = 'gem-tools-example-run-code'
5 4
   s.version = '1.0'
6 5
   s.summary = 'foo'
7 6
   s.run_code { puts 'w00t' }
5  spec/gem_tools_spec.rb
@@ -83,5 +83,10 @@ def load_spec(name)
83 83
     it 'should trigger code on gem install' do
84 84
       install('run-code').should include('w00t')
85 85
     end
  86
+
  87
+    it 'should abort installation on errors' do
  88
+      install 'bogus'
  89
+      gems.list.should_not include('bogus')
  90
+    end
86 91
   end
87 92
 end

0 notes on commit ffd6bd7

Please sign in to comment.
Something went wrong with that request. Please try again.