mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
parent
8a53fd3659
commit
c3f91950f9
1 changed files with 15 additions and 8 deletions
|
@ -64,15 +64,22 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.reset
|
def self.reset
|
||||||
providers = Fog.providers.map {|p| Fog.const_get(p) }
|
mocked_services = []
|
||||||
possible_service_constants = providers.map {|p| p.constants.map {|c| p.const_get(c) } }.flatten
|
Fog.constants.map do |x|
|
||||||
# c.to_sym is 1.8.7 / 1.9.2 compat
|
x_const = Fog.const_get(x)
|
||||||
services = possible_service_constants.select {|s| s.constants.map {|c| c.to_sym }.include?(:Mock) }
|
x_const.respond_to?(:constants) && x_const.constants.map do |y|
|
||||||
service_mocks = services.map {|s| s.const_get(:Mock) }
|
y_const = x_const.const_get(y)
|
||||||
|
y_const.respond_to?(:constants) && y_const.constants.map do |z|
|
||||||
|
if z.to_sym == :Mock
|
||||||
|
mocked_services << y_const.const_get(z)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
service_mocks.each do |service_mock|
|
for mocked_service in mocked_services
|
||||||
next unless service_mock.respond_to?(:reset)
|
next unless mocked_service.respond_to?(:reset)
|
||||||
service_mock.reset
|
mocked_service.reset
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue