diff --git a/lib/rubygems/patcher.rb b/lib/rubygems/patcher.rb index 301221c..4fba04c 100644 --- a/lib/rubygems/patcher.rb +++ b/lib/rubygems/patcher.rb @@ -25,7 +25,7 @@ def initialize(gemfile, output_dir) # Patch the gem, move the new patched gem to the working directory and return the path def patch_with(patches, options) - @output = [] + @std, @output = [], [] check_patch_command_is_installed extract_gem @@ -33,7 +33,7 @@ def patch_with(patches, options) # Apply all patches patches.each do |patch| info 'Applying patch ' + patch - apply_patch(patch, options) + @std << apply_patch(patch, options) end build_patched_gem @@ -71,6 +71,7 @@ def apply_patch(patch, options) end end end + std end end end @@ -81,11 +82,20 @@ def print_results end end + ## # Return output lines + def output @output end + ## + # Return std from patch command + + def std + @std + end + private def extract_gem diff --git a/test/rubygems/test_gem_patch.rb b/test/rubygems/test_gem_patch.rb index 3c7e592..c724e61 100644 --- a/test/rubygems/test_gem_patch.rb +++ b/test/rubygems/test_gem_patch.rb @@ -81,6 +81,25 @@ def test_use_outfile_for_output assert_equal patched_file, file_contents('foo.rb') end + ## + # Test passing additional options + + def test_use_outfile_for_output + @options[:patch_options] = '--help' + + gemfile = bake_testing_gem + + patches = [] + patches << bake_change_file_patch + + # Creates new patched gem in @gems_dir + patcher = Gem::Patcher.new(gemfile, @gems_dir) + patched_gem = patcher.patch_with(patches, @options) + + assert_equal 0, /.*Usage: patch \[OPTION\].*/ =~ patcher.std.join(' ') + end + + ## # Test changing a file in a gem with -F0 option