More redundant test code removing
This commit is contained in:
parent
4e54cc77a2
commit
c0c3313fdd
|
@ -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
|
||||
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue