From c0c3313fddf8f824f6c2325c2571eacbfd899d05 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 8 Apr 2010 23:32:26 -0700 Subject: [PATCH] More redundant test code removing --- test/test_helper.rb | 5 +---- test/vagrant/actions/collection_test.rb | 13 ++++++++----- test/vagrant/actions/runner_test.rb | 5 ++++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index c163d6133..de72c0c6e 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -91,7 +91,7 @@ class Test::Unit::TestCase [mock_vm, vm, action] end - def stub_default_action_dependecies(mock, klass=MockAction) + def stub_default_action_dependecies(mock) mock.stubs(:precedes).returns([]) mock.stubs(:follows).returns([]) end @@ -105,6 +105,3 @@ class Test::Unit::TestCase end end -class MockAction; end -class MockActionOther; end - diff --git a/test/vagrant/actions/collection_test.rb b/test/vagrant/actions/collection_test.rb index 919804e9e..389765dd1 100644 --- a/test/vagrant/actions/collection_test.rb +++ b/test/vagrant/actions/collection_test.rb @@ -1,6 +1,9 @@ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper') class CollectionTest < Test::Unit::TestCase + class MockAction; end + class MockActionOther; end + context "checking uniqueness" do setup do @actions = Vagrant::Actions::Collection.new([1]) @@ -10,14 +13,14 @@ class CollectionTest < Test::Unit::TestCase @actions << 1 assert @actions.duplicates? end - + should "return false it all the classes are unique" do @actions << 1.0 << "foo" assert !@actions.duplicates? end should "raise an exception when there are duplicates" do - @actions << 1 + @actions << 1 assert_raise Vagrant::Actions::DuplicateActionException do @actions.duplicates! end @@ -42,7 +45,7 @@ class CollectionTest < Test::Unit::TestCase stub_default_action_dependecies(@mock_action) stub_default_action_dependecies(@mock_action2) end - + context "that come before an action" do setup do @mock_action.stubs(:follows).returns([MockActionOther]) @@ -52,7 +55,7 @@ class CollectionTest < Test::Unit::TestCase collection.new([@mock_action]).dependencies! end end - + should "not raise an exception if they are met" do assert_nothing_raised do collection.new([@mock_action2, @mock_action]).dependencies! @@ -97,7 +100,7 @@ class CollectionTest < Test::Unit::TestCase end end end - + context "klasses" do should "return a list of the collection element's classes" do @action = mock('action') diff --git a/test/vagrant/actions/runner_test.rb b/test/vagrant/actions/runner_test.rb index 017c19ca3..21f9adb21 100644 --- a/test/vagrant/actions/runner_test.rb +++ b/test/vagrant/actions/runner_test.rb @@ -1,6 +1,9 @@ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper') class ActionRunnerTest < Test::Unit::TestCase + class MockAction; end + class MockActionOther; end + def mock_fake_action(action_klass = nil, runner = nil) action = action_klass ? action_klass.new(runner) : mock("action") action.stubs(:prepare) @@ -162,7 +165,7 @@ class ActionRunnerTest < Test::Unit::TestCase [MockAction, MockActionOther].each_with_index do |klass, i| action = mock("action#{i}") action.expects(:class).returns(klass) - stub_default_action_dependecies(action, klass) + stub_default_action_dependecies(action) @runner.actions << action actions << action end