Commit 0b607a38 authored by sergey's avatar sergey

add setVariable

parent 6c570ae0
......@@ -105,6 +105,10 @@ Context.prototype.getVariable = function (name, cb) {
this.send('GET VARIABLE ' + name + '\n', cb || function() { });
};
Context.prototype.setVariable = function (name, value, cb) {
this.send('SET VARIABLE ' + name + ' ' + value + '\n', cb || function() { });
};
Context.prototype.answer = function (cb) {
this.send('ANSWER' + '\n', cb || function() { });
};
......
......@@ -3,8 +3,8 @@ var Context = require('./context');
var agi = {
state: require('./state'),
Context: Context,
createServer: function(handler) {
return require('net').createServer(function(stream) {
createServer: function (handler) {
return require('net').createServer(function (stream) {
var context = new Context(stream);
handler(context);
});
......
......@@ -146,6 +146,13 @@ describe('Context', function() {
});
});
describe('setVariable', function() {
it('sends correct command', function() {
this.context.setVariable('test', 'test');
expect(this.context.sent.join('')).to.eql('SET VARIABLE test test\n');
});
});
describe('getVariable', function() {
it('sends correct command', function() {
this.context.getVariable('test');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment