summaryrefslogtreecommitdiff
path: root/test/rake/test_rake_top_level_functions.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-23 22:11:55 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-23 22:11:55 +0000
commitd001539a0538cba0e48be2ebdafe29e67b006a4e (patch)
treeabf1591ca3b56f04f46cc2cce9918700620a3ab1 /test/rake/test_rake_top_level_functions.rb
parent3fbc9440feb66cf762834b6d66e6f3a893bab5b7 (diff)
* lib/rake: Import Rake 0.9.2
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rake/test_rake_top_level_functions.rb')
-rw-r--r--test/rake/test_rake_top_level_functions.rb76
1 files changed, 76 insertions, 0 deletions
diff --git a/test/rake/test_rake_top_level_functions.rb b/test/rake/test_rake_top_level_functions.rb
new file mode 100644
index 0000000000..69ef8691fb
--- /dev/null
+++ b/test/rake/test_rake_top_level_functions.rb
@@ -0,0 +1,76 @@
+require File.expand_path('../helper', __FILE__)
+
+class TestRakeTopLevelFunctions < Rake::TestCase
+
+ def setup
+ super
+
+ @app = Rake.application
+ Rake.application = flexmock("app")
+ Rake.application.should_receive(:deprecate).
+ and_return { |old, new, call| @app.deprecate(old, new, call) }
+ end
+
+ def teardown
+ Rake.application = @app
+
+ super
+ end
+
+ def test_namespace
+ Rake.application.should_receive(:in_namespace).with("xyz", any).once
+ namespace "xyz" do end
+ end
+
+ def test_import
+ Rake.application.should_receive(:add_import).with("x").once.ordered
+ Rake.application.should_receive(:add_import).with("y").once.ordered
+ Rake.application.should_receive(:add_import).with("z").once.ordered
+ import('x', 'y', 'z')
+ end
+
+ def test_when_writing
+ out, = capture_io do
+ when_writing("NOTWRITING") do
+ puts "WRITING"
+ end
+ end
+ assert_equal "WRITING\n", out
+ end
+
+ def test_when_not_writing
+ Rake::FileUtilsExt.nowrite_flag = true
+ _, err = capture_io do
+ when_writing("NOTWRITING") do
+ puts "WRITING"
+ end
+ end
+ assert_equal "DRYRUN: NOTWRITING\n", err
+ ensure
+ Rake::FileUtilsExt.nowrite_flag = false
+ end
+
+ def test_missing_constants_task
+ Rake.application.should_receive(:const_warning).with(:Task).once
+ Object.const_missing(:Task)
+ end
+
+ def test_missing_constants_file_task
+ Rake.application.should_receive(:const_warning).with(:FileTask).once
+ Object.const_missing(:FileTask)
+ end
+
+ def test_missing_constants_file_creation_task
+ Rake.application.should_receive(:const_warning).with(:FileCreationTask).once
+ Object.const_missing(:FileCreationTask)
+ end
+
+ def test_missing_constants_rake_app
+ Rake.application.should_receive(:const_warning).with(:RakeApp).once
+ Object.const_missing(:RakeApp)
+ end
+
+ def test_missing_other_constant
+ assert_raises(NameError) do Object.const_missing(:Xyz) end
+ end
+end