Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Test for directory DSL with fix

  • Loading branch information...
commit 27bfc6312cb705bf616d1a1ed1c6dab60988012c 1 parent b188607
@zimbatm authored
View
3  lib/rake/dsl_definition.rb
@@ -63,13 +63,14 @@ def file_create(*args, &block)
# directory "testdata/doc"
#
def directory(*args, &block)
+ ret = file_create(*args, &block)
dir, _ = *Rake.application.resolve_args(args)
Rake.each_dir_parent(dir) do |d|
file_create d do |t|
mkdir_p t.name if ! File.exist?(t.name)
end
end
- task(args, &block)
+ ret
end
# Declare a task that performs its prerequisites in
View
1  test/helper.rb
@@ -1,4 +1,5 @@
require 'rubygems'
+$:.unshift File.expand_path('../../lib', __FILE__)
begin
gem 'minitest'
View
16 test/test_rake_directory_task.rb
@@ -43,4 +43,20 @@ def test_directory_win32
refute File.exist?('c:/a/b/c')
end
end
+
+ def test_can_use_blocks
+ runlist = []
+
+ t1 = directory("a/b/c" => :t2) { |t| runlist << t.name }
+ t2 = task(:t2) { |t| runlist << t.name }
+
+ verbose(false) {
+ t1.invoke
+ }
+
+ assert_equal Task["a/b/c"], t1
+ assert_equal FileCreationTask, Task["a/b/c"].class
+ assert_equal ["t2", "a/b/c"], runlist
+ assert File.directory?("a/b/c")
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.