Repository: abuiles/ember-watson (js)

Issue:
ENOENT, no such file or directory 'undefined/
When running `ember watson:convert-ember-data-model-lookups`, I get this:

```
ENOENT, no such file or directory 'undefined/'
Error: ENOENT, no such file or directory 'undefined/'
    at Error (native)
    at Object.fs.readdirSync (fs.js:761:18)
    at walkSync (/Users/Tristan/dev/Ludu/node_modules/ember-watson/node_modules/walk-sync/index.js:14:20)
    at module.exports (/Users/Tristan/dev/Ludu/node_modules/ember-watson/lib/helpers/find-files.js:10:13)
    at EmberWatson.transformEmberDataModelLookups (/Users/Tristan/dev/Ludu/node_modules/ember-watson/lib/watson.js:27:15)
    at Class.module.exports.run (/Users/Tristan/dev/Ludu/node_modules/ember-watson/addon/commands/convert-ember-data-model-lookups.js:16:12)
    at Class.<anonymous> (/Users/Tristan/dev/Ludu/node_modules/ember-cli/lib/models/command.js:136:17)
    at lib$rsvp$$internal$$tryCatch (/Users/Tristan/dev/Ludu/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:489:16)
    at lib$rsvp$$internal$$invokeCallback (/Users/Tristan/dev/Ludu/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:501:17)
    at lib$rsvp$$internal$$publish (/Users/Tristan/dev/Ludu/node_modules/ember-cli/node_modules/rsvp/dist/rsvp.js:472:11)
```

Could it have anything to do with the fact that I'm using a POD structure?

Pull request:
Pass correct path to transformers
Fixes #47

//cc @abuiles 

Patch:
diff --git a/.jshintrc b/.jshintrc
index 39d2407..3363301 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -3,6 +3,7 @@
     "require",
     "describe",
     "beforeEach",
+    "afterEach",
     "it"
   ],
   "node": true
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5f8feb9..4c84b67 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,17 +1,5 @@
 # ember-watson Changelog
 
-### 0.5.4
-
-Add tests and fixes issue [#31](https://github.com/abuiles/ember-watson/issues/31).
-
-### 0.5.3
-
-Fixed issue in bin command where path was not being passed.
-
-### 0.5.2
-
-Fixed typo in bin command.
-
 ### 0.5.1
 
 This release includes a new command to help you add an explicit
diff --git a/addon/commands/convert-ember-data-async-false-relationships.js b/addon/commands/convert-ember-data-async-false-relationships.js
index de4fecf..b950cce 100644
--- a/addon/commands/convert-ember-data-async-false-relationships.js
+++ b/addon/commands/convert-ember-data-async-false-relationships.js
@@ -12,7 +12,6 @@ module.exports = {
   ],
   run: function(commandOptions, rawArgs) {
     var path = rawArgs[0] ||  'app';
-
     watson.transformEmberDataAsyncFalseRelationships(path);
   }
 };
diff --git a/addon/commands/convert-ember-data-model-lookups.js b/addon/commands/convert-ember-data-model-lookups.js
index fc2d1d3..8254f0b 100644
--- a/addon/commands/convert-ember-data-model-lookups.js
+++ b/addon/commands/convert-ember-data-model-lookups.js
@@ -12,7 +12,6 @@ module.exports = {
   ],
   run: function(commandOptions, rawArgs) {
     var path = rawArgs[0] ||  'app';
-
-    watson.transformEmberDataModelLookups(commandOptions.appPath);
+    watson.transformEmberDataModelLookups(path);
   }
 };
diff --git a/lib/formulas/prototype-extension-transforms.js b/lib/formulas/prototype-extension-transforms.js
index e1682bd..e1e1e3b 100644
--- a/lib/formulas/prototype-extension-transforms.js
+++ b/lib/formulas/prototype-extension-transforms.js
@@ -50,24 +50,11 @@ function isObserver(node) {
   return isPrototypeExtension(node, 'observes');
 }
 
-function calledFromFunctionExpression(node) {
-  if (types.FunctionExpression.check(node)) {
-    return true;
-  }
-  if (types.CallExpression.check(node)) {
-    return calledFromFunctionExpression(node.callee);
-  }
-  if (types.MemberExpression.check(node)) {
-    return calledFromFunctionExpression(node.object);
-  }
-  return false;
-}
-
 function isEventObserver(node) {
   return types.MemberExpression.check(node.callee) &&
     types.Identifier.check(node.callee.property) &&
     node.callee.property.name === 'on' &&
-    calledFromFunctionExpression(node);
+    (types.FunctionExpression.check(node.callee.object) || types.CallExpression.check(node.callee.object));
 }
 
 module.exports = function transform(source) {
diff --git a/package.json b/package.json
index 09c3d59..be12d00 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "ember-watson",
-  "version": "0.5.4",
+  "version": "0.5.3",
   "description": "A young Ember Doctor to help you fix your code.",
   "main": "index.js",
   "scripts": {


Test patch:
diff --git a/addon/commands/upgrade-qunit-tests.js b/addon/commands/upgrade-qunit-tests.js
index 081fe5b..07bc36b 100644
--- a/addon/commands/upgrade-qunit-tests.js
+++ b/addon/commands/upgrade-qunit-tests.js
@@ -12,7 +12,6 @@ module.exports = {
   ],
   run: function(commandOptions, rawArgs) {
     var path = rawArgs[0] ||  'tests';
-
     watson.transformQUnitTest(path);
   }
 };
diff --git a/tests/commands-test.js b/tests/commands-test.js
new file mode 100644
index 0000000..c8a8d32
--- /dev/null
+++ b/tests/commands-test.js
@@ -0,0 +1,93 @@
+'use strict';
+
+var assert = require('assert');
+var proxyquire = require('proxyquire');
+
+var transformEmberDataModelLookupsCalledWith;
+var transformEmberDataAsyncFalseRelationshipsCalledWith;
+var transformPrototypeExtensionsCalledWith;
+var transformQUnitTestCalledWith;
+
+proxyquire('../addon/commands/convert-ember-data-model-lookups', {
+  '../../index': Mock
+});
+
+proxyquire('../addon/commands/convert-ember-data-async-false-relationships', {
+  '../../index': Mock
+});
+
+proxyquire('../addon/commands/convert-prototype-extensions', {
+  '../../index': Mock
+});
+
+proxyquire('../addon/commands/upgrade-qunit-tests', {
+  '../../index': Mock
+});
+
+function Mock() {}
+
+Mock.prototype.transformEmberDataModelLookups = function() {
+  transformEmberDataModelLookupsCalledWith = Array.prototype.slice.apply(arguments);
+};
+
+Mock.prototype.transformEmberDataAsyncFalseRelationships = function () {
+  transformEmberDataAsyncFalseRelationshipsCalledWith = Array.prototype.slice.apply(arguments);
+};
+
+Mock.prototype.transformPrototypeExtensions = function () {
+  transformPrototypeExtensionsCalledWith = Array.prototype.slice.apply(arguments);
+};
+
+Mock.prototype.transformQUnitTest = function () {
+  transformQUnitTestCalledWith = Array.prototype.slice.apply(arguments);
+};
+
+describe('Commands:', function () {
+
+  afterEach(function () {
+    transformEmberDataModelLookupsCalledWith = null;
+    transformEmberDataAsyncFalseRelationshipsCalledWith = null;
+    transformPrototypeExtensionsCalledWith = null;
+    transformQUnitTestCalledWith = null;
+  });
+
+  it('convert-ember-data-model-lookups calls the correct transform', function () {
+    var Command = require('../addon/commands/convert-ember-data-model-lookups');
+
+    Command.run({}, []);
+    assert.deepEqual(transformEmberDataModelLookupsCalledWith, ['app']);
+
+    Command.run({}, ['some-app']);
+    assert.deepEqual(transformEmberDataModelLookupsCalledWith, ['some-app']);
+  });
+
+  it('convert-ember-data-async-false-relationships calls the correct transform', function () {
+    var Command = require('../addon/commands/convert-ember-data-async-false-relationships');
+
+    Command.run({}, []);
+    assert.deepEqual(transformEmberDataAsyncFalseRelationshipsCalledWith, ['app']);
+
+    Command.run({}, ['some-app']);
+    assert.deepEqual(transformEmberDataAsyncFalseRelationshipsCalledWith, ['some-app']);
+  });
+
+  it('convert-prototype-extensions calls the correct transform', function () {
+    var Command = require('../addon/commands/convert-prototype-extensions');
+
+    Command.run({}, []);
+    assert.deepEqual(transformPrototypeExtensionsCalledWith, ['app']);
+
+    Command.run({}, ['some-app']);
+    assert.deepEqual(transformPrototypeExtensionsCalledWith, ['some-app']);
+  });
+
+  it('upgrade-qunit-tests calls the correct transform', function () {
+    var Command = require('../addon/commands/upgrade-qunit-tests');
+
+    Command.run({}, []);
+    assert.deepEqual(transformQUnitTestCalledWith , ['tests']);
+
+    Command.run({}, ['other-dir']);
+    assert.deepEqual(transformQUnitTestCalledWith , ['other-dir']);
+  });
+});
diff --git a/tests/fixtures/prototype-extension-files/new.js b/tests/fixtures/prototype-extension-files/new.js
index 7cdfa1d..12954bc 100644
--- a/tests/fixtures/prototype-extension-files/new.js
+++ b/tests/fixtures/prototype-extension-files/new.js
@@ -31,15 +31,5 @@ export default Ember.Controller.extend({
 
   onInit: Ember.on('init', function() {
     this.set('foobar', true);
-  }),
-
-  similarMethods: Ember.on('init', Ember.observer('name', function() {
-    $(document).on('click', function() {
-      console.log('someone clicked');
-    });
-    users.map(property('name'));
-    user.observes('name', function() {
-      console.log('Name changed');
-    });
-  }))
+  })
 });
diff --git a/tests/fixtures/prototype-extension-files/old.js b/tests/fixtures/prototype-extension-files/old.js
index 956f43b..f11b11b 100644
--- a/tests/fixtures/prototype-extension-files/old.js
+++ b/tests/fixtures/prototype-extension-files/old.js
@@ -31,15 +31,5 @@ export default Ember.Controller.extend({
 
   onInit: function() {
     this.set('foobar', true);
-  }.on('init'),
-
-  similarMethods: function() {
-    $(document).on('click', function() {
-      console.log('someone clicked');
-    });
-    users.map(property('name'));
-    user.observes('name', function() {
-      console.log('Name changed');
-    });
-  }.observes('name').on('init')
+  }.on('init')
 });
diff --git a/tests/helpers/ast-equality.js b/tests/helpers/ast-equality.js
index 024ff08..371bafc 100644
--- a/tests/helpers/ast-equality.js
+++ b/tests/helpers/ast-equality.js
@@ -25,8 +25,8 @@ module.exports = function(actual, expected, message) {
 
   if (!seemEqual) {
     throw new EqualityError(message || "AST equality failed",
-      recast.print(parsedActual).code,
-      recast.print(parsedExpected).code
+      parsedActual,
+      parsedExpected
     );
   }
 };