Skip to content

Commit

Permalink
Test passing additional options
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef Stribny committed Jul 7, 2014
1 parent 7aa9c9a commit 0f594e8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/rubygems/patcher.rb
Expand Up @@ -25,15 +25,15 @@ 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

# Apply all patches
patches.each do |patch|
info 'Applying patch ' + patch
apply_patch(patch, options)
@std << apply_patch(patch, options)
end

build_patched_gem
Expand Down Expand Up @@ -71,6 +71,7 @@ def apply_patch(patch, options)
end
end
end
std
end
end
end
Expand All @@ -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
Expand Down
19 changes: 19 additions & 0 deletions test/rubygems/test_gem_patch.rb
Expand Up @@ -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

Expand Down

0 comments on commit 0f594e8

Please sign in to comment.