Permalink
Browse files

fixing merge_dir; adding tests

  • Loading branch information...
1 parent ec761e7 commit da14c5171fa29e2b03f40aa90979c6741cc0bcd6 @romand committed Apr 17, 2012
Showing with 24 additions and 2 deletions.
  1. +5 −2 lib/iron_worker_ng/feature/common/merge_dir.rb
  2. +19 −0 test/test_common_features.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
@@ -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

0 comments on commit da14c51

Please sign in to comment.