lib/koine/test_runner/builder.rb in koine-test_runner-0.1.1 vs lib/koine/test_runner/builder.rb in koine-test_runner-0.2.0
- old
+ new
@@ -20,21 +20,26 @@
build_adapter(adapter_config.last)
end
end
def build_adapter(config)
- adapter = config.delete('adapter')
+ adapter_name = config.delete('adapter')
+ adapter_class = adapter_name
- if adapter.downcase == adapter.to_s
- adapter_class = "Koine::TestRunner::Adapters::#{adapter.capitalize}"
+ if adapter_class.downcase == adapter_class.to_s
+ adapter_class = "Koine::TestRunner::Adapters::#{classify(adapter_class)}"
end
unless Object.const_defined?(adapter_class)
- raise ArgumentError, "Cannot locate adapter #{adapter} => #{adapter_class}"
+ raise ArgumentError, "Cannot locate adapter #{adapter_name} => #{adapter_class}"
end
klass = Object.const_get(adapter_class)
klass.new(symbolize_keys(config))
+ end
+
+ def classify(klass)
+ klass.to_s.split('_').map(&:capitalize).join('')
end
def symbolize_keys(hash)
{}.tap do |new_hash|
hash.each do |key, value|