When util is included, extend the class as well [closes GH-83]

This commit is contained in:
Mitchell Hashimoto 2010-05-25 13:19:38 -07:00
parent a5648abe92
commit cce82305ee
2 changed files with 34 additions and 0 deletions

7
lib/vagrant/util.rb Normal file
View File

@ -0,0 +1,7 @@
module Vagrant
module Util
def self.included(base)
base.extend(self)
end
end
end

27
test/vagrant/util_test.rb Normal file
View File

@ -0,0 +1,27 @@
require File.join(File.dirname(__FILE__), '..', 'test_helper')
class UtilTest < Test::Unit::TestCase
class UtilIncludeTest
include Vagrant::Util
end
setup do
@klass = UtilIncludeTest
end
context "with a class" do
should "have the util methods" do
assert @klass.respond_to?(:error_and_exit)
end
end
context "with an instance" do
setup do
@instance = @klass.new
end
should "have the util methods" do
assert @instance.respond_to?(:error_and_exit)
end
end
end