Skip to content

Commit

Permalink
Split CLI specs up into a few separate files.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoglan committed Apr 7, 2014
1 parent 32c95db commit 1e51bad
Show file tree
Hide file tree
Showing 6 changed files with 673 additions and 640 deletions.
4 changes: 3 additions & 1 deletion spec/node.js
Expand Up @@ -4,7 +4,9 @@ JS.ENV.Vault = require('../lib/vault')

require('./vault_spec')
require('./stream_spec')
require('./node/cli_spec')
require('./node/generator_spec')
require('./node/config_file_spec')
require('./node/remote_sources_spec')

JS.Test.autorun()

54 changes: 54 additions & 0 deletions spec/node/cli_helper.js
@@ -0,0 +1,54 @@
var async = require("async"),
path = require("path"),
rmrf = require("rimraf"),
CLI = require("../../node/cli"),
Store = require("../../lib/store"),
FileAdapter = require("../../node/file_adapter")

var CliHelper = new JS.Module()

CliHelper.included = function(suite) {
suite.before(function() { with(this) {
this.configPath = path.join(__dirname, ".vault")
this.exportPath = path.join(__dirname, "export.json")
this.stdout = {write: function() {}}
this.stderr = {write: function() {}}
this.passphrase = "something"
this.confirm = true

this.cli = new CLI({
config: {path: configPath, key: "the key", cache: false},
stdout: this.stdout,
stderr: this.stderr,
tty: false,

confirm: function(message, callback) {
callback(confirm)
},

password: function(callback) {
callback(passphrase)
},

selectKey: function(callback) {
callback(null, "AAAAPUBLICKEY")
},

sign: function(key, message, callback) {
if (key === "AAAAPUBLICKEY")
callback(null, message);
else
callback(new Error("Could not sign the message"))
}
})

this.storage = new Store(new FileAdapter(configPath), "the key", {cache: false})
}})

suite.after(function(resume) { with(this) {
async.forEach([configPath, exportPath], rmrf, resume)
}})
}

module.exports = CliHelper

0 comments on commit 1e51bad

Please sign in to comment.