cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fil...@apache.org
Subject [36/50] [abbrv] git commit: install specs done. uninstall still need some work. removed unused requires.
Date Tue, 23 Apr 2013 23:01:04 GMT
install specs done. uninstall still need some work. removed unused requires.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/abc795fa
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/abc795fa
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/abc795fa

Branch: refs/heads/master
Commit: abc795fa09058f9ecf7b0811174b9716280eb760
Parents: 63624ed
Author: Fil Maj <maj.fil@gmail.com>
Authored: Mon Apr 22 16:46:34 2013 -0700
Committer: Fil Maj <maj.fil@gmail.com>
Committed: Mon Apr 22 16:46:34 2013 -0700

----------------------------------------------------------------------
 spec/install.spec.js     |   38 ++++++++++++++++++++++++++++++--------
 spec/uninstall.spec.js   |   13 ++-----------
 src/install.js           |    8 ++++----
 src/platforms/android.js |    6 +-----
 4 files changed, 37 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/abc795fa/spec/install.spec.js
----------------------------------------------------------------------
diff --git a/spec/install.spec.js b/spec/install.spec.js
index 20de7dc..b973b11 100644
--- a/spec/install.spec.js
+++ b/spec/install.spec.js
@@ -23,30 +23,37 @@ describe('install', function() {
     beforeEach(function() {
         shell.mkdir('-p', temp);
         shell.mkdir('-p', plugins_dir);
+        shell.cp('-rf', android_one_project, temp);
     });
     afterEach(function() {
         shell.rm('-rf', temp);
     });
 
     describe('success', function() {
+        var android_installer;
         beforeEach(function() {
             shell.cp('-rf', dummyplugin, plugins_dir);
+            android_installer = spyOn(android, 'install');
+        });
+        it('should call prepare after a successful install', function() {
+            var s = spyOn(plugman, 'prepare');
+            install('android', temp, 'DummyPlugin', plugins_dir, {});
+            android_installer.mostRecentCall.args[5](); // fake the installer calling back
successfully
+            expect(s).toHaveBeenCalled();
         });
 
         it('should call fetch if provided plugin cannot be resolved locally', function()
{
-            shell.cp('-rf', android_one_project, temp);
             var s = spyOn(plugman, 'fetch');
             install('android', temp, 'CLEANYOURSHORTS', plugins_dir, {});
             expect(s).toHaveBeenCalled();
         });
         // TODO: possibly test how diff platform transaction logs are created
         it('should generate an array of transactions required to run an installation and
pass into appropriate platform handler\'s install method', function() {
-        });
-        it('should call prepare after a successful install', function() {
-            shell.cp('-rf', android_one_project, temp);
-            var s = spyOn(plugman, 'prepare');
             install('android', temp, 'DummyPlugin', plugins_dir, {});
-            expect(s).toHaveBeenCalled();
+            var transactions = android_installer.mostRecentCall.args[0];
+
+            expect(transactions.length).toEqual(6);
+            expect(transactions[0].tag).toBe('source-file');
         });
     });
 
@@ -62,7 +69,22 @@ describe('install', function() {
                 install('android', temp, 'VariablePlugin', plugins_dir, {});
             }).toThrow('Variable(s) missing: API_KEY');
         });
-        it('should handle a failed install by passing completed transactions into appropriate
handler\'s uninstall method'); 
-        it('should throw if plugin is already installed into project');
+        it('should handle a failed install by passing completed transactions into appropriate
handler\'s uninstall method', function() {
+            shell.cp('-rf', faultyplugin, plugins_dir);
+            var s = spyOn(android, 'uninstall');
+            install('android', temp, 'FaultyPlugin', plugins_dir, {});
+
+            var executed_txs = s.mostRecentCall.args[0];
+            expect(executed_txs.length).toEqual(0);
+        }); 
+        it('should throw if plugin is already installed into project', function() {
+            shell.cp('-rf', dummyplugin, plugins_dir);
+            expect(function() {
+                install('android', temp, 'DummyPlugin', plugins_dir, {});
+            }).not.toThrow();
+            expect(function() {
+                install('android', temp, 'DummyPlugin', plugins_dir, {});
+            }).toThrow();
+        });
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/abc795fa/spec/uninstall.spec.js
----------------------------------------------------------------------
diff --git a/spec/uninstall.spec.js b/spec/uninstall.spec.js
index d95e89b..c912321 100644
--- a/spec/uninstall.spec.js
+++ b/spec/uninstall.spec.js
@@ -24,29 +24,20 @@ describe('uninstall', function() {
     beforeEach(function() {
         shell.mkdir('-p', temp);
         shell.mkdir('-p', plugins_dir);
+        shell.cp('-rf', android_one_project, temp);
+        shell.cp('-rf', dummyplugin, plugins_dir);
     });
     afterEach(function() {
         shell.rm('-rf', temp);
     });
 
     describe('success', function() {
-        beforeEach(function() {
-            shell.cp('-rf', android_one_project, temp);
-            shell.cp('-rf', dummyplugin, plugins_dir);
-            install('android', temp, 'DummyPlugin', plugins_dir, {});
-        });
-
         // TODO: possibly test how diff platform transaction logs are created
         it('should generate and pass uninstall transaction log to appropriate platform handler\'s
uninstall', function() {
         });
     });
 
     describe('failure', function() {
-        beforeEach(function() {
-            shell.cp('-rf', android_one_project, temp);
-            shell.cp('-rf', dummyplugin, plugins_dir);
-            install('android', temp, 'DummyPlugin', plugins_dir, {});
-        });
         it('should throw if platform is unrecognized', function() {
             expect(function() {
                 uninstall('atari', temp, 'SomePlugin', plugins_dir, {});

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/abc795fa/src/install.js
----------------------------------------------------------------------
diff --git a/src/install.js b/src/install.js
index a3d355e..d9fb939 100644
--- a/src/install.js
+++ b/src/install.js
@@ -35,8 +35,7 @@ function runInstall(platform, project_dir, plugin_dir, plugins_dir, cli_variable
     var xml_path     = path.join(plugin_dir, 'plugin.xml')
       , xml_text     = fs.readFileSync(xml_path, 'utf-8')
       , plugin_et    = new et.ElementTree(et.XML(xml_text))
-      , filtered_variables = {}
-      , info;
+      , filtered_variables = {};
     var name         = plugin_et.findall('name').text;
     var plugin_id    = plugin_et._root.attrib['id'];
     
@@ -104,8 +103,9 @@ function runInstall(platform, project_dir, plugin_dir, plugins_dir, cli_variable
             require('./../plugman').prepare(project_dir, platform, plugins_dir);
 
             // Log out plugin INFO element contents in case additional install steps are
necessary
-            if((info = platformTag.findAll('./info'))) {
-                console.log(info.text);
+            var info = platformTag.findall('./info');
+            if(info.length) {
+                console.log(info[0].text);
             }
             if (callback) callback();
         }

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/abc795fa/src/platforms/android.js
----------------------------------------------------------------------
diff --git a/src/platforms/android.js b/src/platforms/android.js
index b017a9f..6fb912a 100644
--- a/src/platforms/android.js
+++ b/src/platforms/android.js
@@ -19,15 +19,11 @@
 
 var fs = require('fs')  // use existsSync in 0.6.x
    , path = require('path')
-   , util = require('util')
    , shell = require('shelljs')
-   , et = require('elementtree')
    , common = require('./common')
    , getConfigChanges = require(path.join(__dirname, '..', 'util', 'config-changes'))
    , searchAndReplace = require(path.join(__dirname, '..', 'util', 'search-and-replace'))
-   , xml_helpers = require(path.join(__dirname, '..', 'util', 'xml-helpers'))
-   , assetsDir = path.join('assets','www')
-   , sourceDir = 'src';
+   , xml_helpers = require(path.join(__dirname, '..', 'util', 'xml-helpers'));
 
 module.exports = {
     install:function(transactions, plugin_id, project_dir, plugin_dir, variables, callback)
{


Mime
View raw message