Ruff Driver Runner
The ruff-app-runner module provides you a facility for Ruff driver developers to run driver on their development machine. You may include this module with require('ruff-driver-runner');var assert = require('assert');
var runner = require('ruff-driver-runner');
var when = require('ruff-mock').when;
export['test should work well'] = function(done) {
runner.run('../', function(error, context) {
var inputs = context.inputs;
var device = context.device;
var gpio = inputs['gpio'];
when(gpio)
.read(Function)
.then(function (callback) {
callback(undefined, 1);
});
gpio.read(function (error, value) {
assert.ifError(error);
assert.equal(value, 1);
});
}
}
require('test').run(exports);
Ruff driver runner creates a virtual runtime built with ruff-mock, which allows developers to:
- Retrive mock interface
The second parameter of run function of driver runner is context. Where the interface could be retrived fromvar gpio = context.inputs['gpio'];
The name of the reference for context.inputs should be same with the name described in driver.json.
Please checkout Ruff Mock for more information.
runner.run(driverPath, runCallback)
driverPathrefer to your driver path which containsdriver.json.runCallbackwill run once the virtual runtime has been created and yourattachfunction has been invoked.