Permalink
Browse files

Add spec for resource_proxy_dsl

  • Loading branch information...
1 parent 2a83f5e commit ff46aa2edfaa865422aaa5a516b063c59555df35 Jack C Hong committed May 17, 2012
@@ -12,18 +12,12 @@ def register_proxy(name)
OmfRc::ResourceFactory.register_proxy(name)
end
- def register_bootstrap(&register_block)
- define_method(:bootstrap) do |*args, &block|
+ def register_hook(name, &register_block)
+ define_method(name) do
register_block.call if register_block
end
end
- def register_cleanup(&register_block)
- define_method(:cleanup) do |*args, &block|
- register_block.call(block) if register_block
- end
- end
-
def utility(name)
name = name.to_s
begin
@@ -3,6 +3,9 @@ module OmfRc::Util::Mock
register_utility :mock
+ register_request :nothing
+ register_configure :nothing
+
register_request :resource_proxy_list do |callback|
callback.call(success: OmfRc::ResourceFactory.proxy_list)
end
@@ -11,7 +11,8 @@
it "must be able to create new resource proxy" do
mock = OmfRc::ResourceFactory.new(:mock)
mock.must_be_kind_of OmfRc::ResourceProxy::AbstractResource
- mock.must_respond_to :test
+ mock.must_respond_to :request_nothing
+ mock.must_respond_to :configure_nothing
end
end
end
@@ -0,0 +1,41 @@
+require 'test_helper'
+require 'omf_rc/resource_proxy_dsl'
+
+describe OmfRc::ResourceProxyDSL do
+ before do
+ module OmfRc::Util::MockUtility
+ include OmfRc::ResourceProxyDSL
+ register_utility :mock_utility
+ register_configure :alpha
+ register_request :alpha
+ end
+
+ module OmfRc::ResourceProxy::MockProxy
+ include OmfRc::ResourceProxyDSL
+
+ register_proxy :mock_proxy
+ utility :mock_utility
+
+ register_hook :before_ready
+ register_hook :before_release
+ register_configure :bravo
+ register_request :bravo
+ end
+ end
+
+ describe "when included by modules to define resource proxy functionalities" do
+ it "must be able to register the modules" do
+ OmfRc::ResourceFactory.proxy_list.must_include :mock_proxy
+ OmfRc::ResourceFactory.utility_list.must_include :mock_utility
+ end
+
+ it "must be able to define methods" do
+ OmfRc::Util::MockUtility.method_defined?(:configure_alpha).must_equal true
+ OmfRc::Util::MockUtility.method_defined?(:request_alpha).must_equal true
+ OmfRc::ResourceProxy::MockProxy.method_defined?(:configure_alpha).must_equal true
+ OmfRc::ResourceProxy::MockProxy.method_defined?(:request_alpha).must_equal true
+ OmfRc::ResourceProxy::MockProxy.method_defined?(:before_ready).must_equal true
+ OmfRc::ResourceProxy::MockProxy.method_defined?(:before_release).must_equal true
+ end
+ end
+end

0 comments on commit ff46aa2

Please sign in to comment.