diff --git a/lib/vulcano/backend.rb b/lib/vulcano/backend.rb index 0df4269eb..6e119fc66 100644 --- a/lib/vulcano/backend.rb +++ b/lib/vulcano/backend.rb @@ -15,14 +15,14 @@ module Vulcano def self.target_config( config ) conf = config.dup - return conf if conf[:target].to_s.empty? + return conf if conf['target'].to_s.empty? - uri = URI::parse(conf[:target].to_s) - conf[:backend] = conf[:backend] || uri.scheme - conf[:host] = conf[:host] || uri.host - conf[:port] = conf[:port] || uri.port - conf[:user] = conf[:user] || uri.user - conf[:password] = conf[:password] || uri.password + uri = URI::parse(conf['target'].to_s) + conf['backend'] = conf['backend'] || uri.scheme + conf['host'] = conf['host'] || uri.host + conf['port'] = conf['port'] || uri.port + conf['user'] = conf['user'] || uri.user + conf['password'] = conf['password'] || uri.password # return the updated config conf diff --git a/lib/vulcano/backend/specinfra.rb b/lib/vulcano/backend/specinfra.rb index 2ab65e808..962e2e597 100644 --- a/lib/vulcano/backend/specinfra.rb +++ b/lib/vulcano/backend/specinfra.rb @@ -9,7 +9,7 @@ module Vulcano::Backends def initialize(conf) @conf = conf @files = {} - type = @conf['backend'] + type = @conf['backend'].to_s configure_shared_options diff --git a/test/unit/backend_test.rb b/test/unit/backend_test.rb index e7717afd6..9ab5ba45c 100644 --- a/test/unit/backend_test.rb +++ b/test/unit/backend_test.rb @@ -13,27 +13,27 @@ describe 'Vulcano::Backend' do describe 'target config helper' do it 'configures resolves target' do org = { - target: 'ssh://user:pass@host.com:123' + 'target' => 'ssh://user:pass@host.com:123', } res = Vulcano::Backend.target_config(org) - res[:backend].must_equal 'ssh' - res[:host].must_equal 'host.com' - res[:user].must_equal 'user' - res[:password].must_equal 'pass' - res[:port].must_equal 123 - res[:target].must_equal org[:target] - org.keys.must_equal [:target] + res['backend'].must_equal 'ssh' + res['host'].must_equal 'host.com' + res['user'].must_equal 'user' + res['password'].must_equal 'pass' + res['port'].must_equal 123 + res['target'].must_equal org['target'] + org.keys.must_equal ['target'] end it 'resolves a target while keeping existing fields' do org = { - target: 'ssh://user:pass@host.com:123', - backend: rand, - host: rand, - user: rand, - password: rand, - port: rand, - target: rand, + 'target' => 'ssh://user:pass@host.com:123', + 'backend' => rand, + 'host' => rand, + 'user' => rand, + 'password' => rand, + 'port' => rand, + 'target' => rand, } res = Vulcano::Backend.target_config(org) res.must_equal org @@ -41,15 +41,15 @@ describe 'Vulcano::Backend' do it 'keeps the configuration when incorrect target is supplied' do org = { - target: 'wrong', + 'target' => 'wrong', } res = Vulcano::Backend.target_config(org) - res[:backend].must_be_nil - res[:host].must_be_nil - res[:user].must_be_nil - res[:password].must_be_nil - res[:port].must_be_nil - res[:target].must_equal org[:target] + res['backend'].must_be_nil + res['host'].must_be_nil + res['user'].must_be_nil + res['password'].must_be_nil + res['port'].must_be_nil + res['target'].must_equal org['target'] end end