summaryrefslogtreecommitdiff
path: root/test/rake/test_rake_top_level_functions.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/rake/test_rake_top_level_functions.rb')
-rw-r--r--test/rake/test_rake_top_level_functions.rb69
1 files changed, 52 insertions, 17 deletions
diff --git a/test/rake/test_rake_top_level_functions.rb b/test/rake/test_rake_top_level_functions.rb
index 69ef8691fb..1ed1af02e3 100644
--- a/test/rake/test_rake_top_level_functions.rb
+++ b/test/rake/test_rake_top_level_functions.rb
@@ -5,28 +5,43 @@ 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
+ @app = Object.new
- def teardown
- Rake.application = @app
+ def @app.called
+ @called
+ end
- super
+ def @app.method_missing(*a, &b)
+ @called ||= []
+ @called << [a, b]
+ nil
+ end
+
+ Rake.application = @app
end
def test_namespace
- Rake.application.should_receive(:in_namespace).with("xyz", any).once
- namespace "xyz" do end
+ block = proc do end
+
+ namespace("xyz", &block)
+
+ expected = [
+ [[:in_namespace, 'xyz'], block]
+ ]
+
+ assert_equal expected, @app.called
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')
+
+ expected = [
+ [[:add_import, 'x'], nil],
+ [[:add_import, 'y'], nil],
+ [[:add_import, 'z'], nil],
+ ]
+
+ assert_equal expected, @app.called
end
def test_when_writing
@@ -51,23 +66,43 @@ class TestRakeTopLevelFunctions < Rake::TestCase
end
def test_missing_constants_task
- Rake.application.should_receive(:const_warning).with(:Task).once
Object.const_missing(:Task)
+
+ expected = [
+ [[:const_warning, :Task], nil]
+ ]
+
+ assert_equal expected, @app.called
end
def test_missing_constants_file_task
- Rake.application.should_receive(:const_warning).with(:FileTask).once
Object.const_missing(:FileTask)
+
+ expected = [
+ [[:const_warning, :FileTask], nil]
+ ]
+
+ assert_equal expected, @app.called
end
def test_missing_constants_file_creation_task
- Rake.application.should_receive(:const_warning).with(:FileCreationTask).once
Object.const_missing(:FileCreationTask)
+
+ expected = [
+ [[:const_warning, :FileCreationTask], nil]
+ ]
+
+ assert_equal expected, @app.called
end
def test_missing_constants_rake_app
- Rake.application.should_receive(:const_warning).with(:RakeApp).once
Object.const_missing(:RakeApp)
+
+ expected = [
+ [[:const_warning, :RakeApp], nil]
+ ]
+
+ assert_equal expected, @app.called
end
def test_missing_other_constant