Question

I was wondering if there is any way to obtain the return value of an outer topic, from within a test of an inner topic. If that was confusing, here's an example:

"build.css" : {
  topic : function(file) {
    fs.readFile(fixtures + "/public/build.css", "utf8", this.callback);
  },
  'exists' : function(err, build) {
    assert.isNull(err); // This is fine..
  },
  {
    'should contain' : {
      topic : function() {
        return "wahoo";
      },
      'some cool css' : function(wahooString, err, build) {
        // Where did build go? Can I still access it from this scope?
      }
    ...
  }
  ...
Était-ce utile?

La solution

Pseudo Code:

'should contain' : {
  topic : function(err, build) {
    this.callback(err, build, "wahoo");
    return undefined;
  },
  'some cool css' : function(err, build, wahooString) {
    // Where did build go? Can I still access it from this scope?
  }
...

Basically you get the previous topics data in any sub topic. You then need to manually pass it to the vows. Yes it is a pain.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top