Skip to content

Commit

Permalink
test: removes unused Cucumber world utils
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-zakharchenko committed Jul 11, 2019
1 parent 73b7a95 commit d16d8bf
Showing 1 changed file with 0 additions and 63 deletions.
63 changes: 0 additions & 63 deletions test/cucumber/support/world.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,69 +41,6 @@ class World {
this.componentResults = null;
}

expectBlockEval(block, expectedReturn, callback) {
const realOutput = this.safeEval(block, callback);

// I'm terribly sorry, but curly braces not asigned to any
// variable in evaled string are interpreted as code block
// not an Object literal, so I'm wrapping expected code output
// with brackets.
// see: http://stackoverflow.com/questions/8949274/javascript-calling-eval-on-an-object-literal-with-functions

const expectedOutput = this.safeEval(`(${expectedReturn})`, callback);

const realOutputInspect = util.inspect(realOutput);
const expectedOutputInspect = util.inspect(expectedOutput);

try {
assert.deepEqual(realOutput, expectedOutput);
} catch (error) {
callback(
new Error(
'Output of code buffer does not equal. Expected output:\n' +
expectedOutputInspect +
'\nbut got: \n' +
realOutputInspect +
'\n' +
'Evaled code block:' +
'\n' +
'- - - \n' +
block +
'\n' +
'- - - '
)
);
}
return callback();
}

safeEval(code, callback) {
// I'm terribly sorry, it's no longer possible to manipulate module require/load
// path inside node's process. So I'm prefixing require path by hard
// substitution in code to pretend to 'hit' is packaged module.
//
// further reading on node.js load paths:
// http://nodejs.org/docs/v0.8.23/api/all.html#all_all_together

const formattedCode = code.replace(
`require('gavel`,
`require('../../../lib`
);

try {
return eval(formattedCode);
} catch (error) {
return callback(
new Error(
'Eval failed. Code buffer: \n\n' +
formattedCode +
'\nWith error: ' +
error
)
);
}
}

executeCommands(commands) {
const commandsBuffer = commands.join(';');
const cmd =
Expand Down

0 comments on commit d16d8bf

Please sign in to comment.