From 63b9ea6eb0e591fd2795c3aeb21cb260eafd8383 Mon Sep 17 00:00:00 2001 From: Dan Peterson Date: Thu, 19 May 2011 22:35:37 -0300 Subject: [PATCH] [mock] fix Fog::Mock.reset --- lib/fog/core/mock.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/fog/core/mock.rb b/lib/fog/core/mock.rb index f50fff997..456584ce6 100644 --- a/lib/fog/core/mock.rb +++ b/lib/fog/core/mock.rb @@ -64,16 +64,18 @@ module Fog end def self.reset - providers = Fog.providers.map{|p| eval("Fog::#{p}")} - services = providers.map{|p| p.constants.map{|s| eval("#{p}::#{s}")}}.flatten - services = services.select {|s| s.constants.include?(:Mock)} + providers = Fog.providers.map {|p| Fog.const_get(p) } + possible_service_constants = providers.map {|p| p.constants.map {|c| p.const_get(c) } }.flatten + # c.to_sym is 1.8.7 / 1.9.2 compat + services = possible_service_constants.select {|s| s.constants.map {|c| c.to_sym }.include?(:Mock) } + service_mocks = services.map {|s| s.const_get(:Mock) } - services.each do |service| - next unless service::Mock.respond_to?(:reset) - service::Mock.reset + service_mocks.each do |service_mock| + next unless service_mock.respond_to?(:reset) + service_mock.reset end end end -end \ No newline at end of file +end