| Module | Uttk::Loaders |
| In: |
lib/uttk/generators/templates/loader.rb
lib/uttk/loaders/Ruby.rb lib/uttk/loaders/Yaml.rb lib/uttk/loaders/Loader.rb lib/uttk.rb |
Uttk::Loaders are design to help you to make tests.
The `testify’ method is here to provide a usefull way to convert anything to a test.
For example Hash#testify instanciate a test from a hash:
doc = {
:strategy => Cmd,
:command => 'echo -n foo',
:output => 'foo',
:symtbl => SYMTBL
}
test = doc.testify
test.run
You can also load a test from a string, an io or a file. In this case the format can change (YAML, XML…). To manage this you can use Uttk::Loaders to add new loader easily.
To implement a loader you just need to subclass the abstract loader (Uttk::Loaders::Loader), and implement the `load’ method.
The `load’ method take an IO as argument and return something which can be testified.
# File lib/uttk/loaders/Loader.rb, line 38 def self.get_class ( aClassName ) return aClassName if aClassName.is_a? Class aClassName = "Uttk::Strategies::#{aClassName}" unless aClassName =~ /::/ return eval(aClassName) if aClassName =~ /[\w:]+/ raise NameError, "not a valid class name #{aClassName}" end