Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixing merge_dir; adding tests

  • Loading branch information...
commit da14c5171fa29e2b03f40aa90979c6741cc0bcd6 1 parent ec761e7
@romand authored
View
7 lib/iron_worker_ng/feature/common/merge_dir.rb
@@ -1,3 +1,5 @@
+require 'pathname'
+
module IronWorkerNG
module Feature
module Common
@@ -7,8 +9,9 @@ class Feature < IronWorkerNG::Feature::Base
attr_reader :dest
def initialize(path, dest)
+ raise 'No such directory - ' + path unless Dir.exist? path
@path = File.expand_path(path)
- @dest = dest
+ @dest = Pathname.new(dest).cleanpath.to_s
end
def hash_string
@@ -25,7 +28,7 @@ def bundle(zip)
IronWorkerNG::Logger.debug "Bundling dir with path='#{@path}' and dest='#{@dest}'"
Dir.glob(@path + '/**/**') do |path|
- zip.add(@dest + File.basename(@path) + path[@path.length .. -1], path)
+ zip.add(@dest + '/' + File.basename(@path) + path[@path.length .. -1], path)
end
end
end
View
19 test/test_common_features.rb
@@ -14,4 +14,23 @@ def test_merge_file
end
end
+ def test_merge_dir_check
+ assert_raise RuntimeError, "should check if merged dir exists" do
+ code_bundle('test') do
+ merge_dir('dir2', 'test/data')
+ end
+ end
+ end
+
+ def test_merge_dir
+ code = code_bundle('test') do
+ merge_dir('test/data/dir2', 'test/data')
+ merge_worker('test/hello.rb')
+ end
+
+ Zip::ZipFile.open(code.create_zip) do |zip|
+ assert zip.find_entry('test/data/dir2/test')
+ end
+ end
+
end
Please sign in to comment.
Something went wrong with that request. Please try again.