add possibility to stub only selected providers

This commit is contained in:
Anton Chuchkalov 2015-07-13 19:55:41 +04:00
parent b01031acba
commit 3c8f5258d0
3 changed files with 13 additions and 4 deletions

View File

@ -39,7 +39,7 @@ module Devops
Devops::Api2.settings.mongo.create_root_user
::Provider::ProviderFactory.init(config)
Stubber.stub_providers! if config[:stub_classes]
Stubber.stub_providers!(config[:stub_providers])
end
def routes

View File

@ -40,4 +40,7 @@ config[:static_ssh_key] = "ssh_key" # or nil
config[:static_certificate] = "/path/to/.ssh/static.pem"
config[:debug] = true
config[:stub_classes] = true
# set it to :all or [:ec2] to stub calls to selected providers
# or to false to disable stubbing
config[:stub_providers] = false

View File

@ -1,5 +1,11 @@
module Stubber
def self.stub_providers!
Dir["tests/stubs/providers/*.rb"].each {|file| require file }
def self.stub_providers!(providers)
return unless providers
providers = [:ec2, :openstack] if providers == :all
providers.each do |provider|
next unless [:ec2, :openstack].include?(provider)
require "tests/stubs/providers/#{provider}.rb"
end
end
end