diff options
author | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-16 18:49:26 +0900 |
---|---|---|
committer | Jari Vetoniemi <jari.vetoniemi@indooratlas.com> | 2020-03-30 00:39:06 +0900 |
commit | fcbf63e62c627deae76c1b8cb8c0876c536ed811 (patch) | |
tree | 64cb17de3f41a2b6fef2368028fbd00349946994 /jni/ruby/test/rake/test_rake_top_level_functions.rb |
Fresh start
Diffstat (limited to 'jni/ruby/test/rake/test_rake_top_level_functions.rb')
-rw-r--r-- | jni/ruby/test/rake/test_rake_top_level_functions.rb | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/jni/ruby/test/rake/test_rake_top_level_functions.rb b/jni/ruby/test/rake/test_rake_top_level_functions.rb new file mode 100644 index 0000000..fee702d --- /dev/null +++ b/jni/ruby/test/rake/test_rake_top_level_functions.rb @@ -0,0 +1,71 @@ +require File.expand_path('../helper', __FILE__) + +class TestRakeTopLevelFunctions < Rake::TestCase + + def setup + super + + @app = Object.new + + def @app.called + @called + end + + def @app.method_missing(*a, &b) + @called ||= [] + @called << [a, b] + nil + end + + Rake.application = @app + end + + def test_namespace + block = proc do end + + namespace("xyz", &block) + + expected = [ + [[:in_namespace, 'xyz'], block] + ] + + assert_equal expected, @app.called + end + + def test_import + import('x', 'y', 'z') + + expected = [ + [[:add_import, 'x'], nil], + [[:add_import, 'y'], nil], + [[:add_import, 'z'], nil], + ] + + assert_equal expected, @app.called + 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_other_constant + assert_raises(NameError) do Object.const_missing(:Xyz) end + end +end |