cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bra...@apache.org
Subject git commit: Fix util/plugins tests
Date Wed, 29 May 2013 15:34:52 GMT
Updated Branches:
  refs/heads/master b3f21f377 -> 06bd1aab7


Fix util/plugins tests

These were failing due to making git clone synchronous.


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

Branch: refs/heads/master
Commit: 06bd1aab796a54987a10d4e30fed4ffffa806db1
Parents: b3f21f3
Author: Braden Shepherdson <braden.shepherdson@gmail.com>
Authored: Wed May 29 11:34:01 2013 -0400
Committer: Braden Shepherdson <braden.shepherdson@gmail.com>
Committed: Wed May 29 11:34:01 2013 -0400

----------------------------------------------------------------------
 spec/util/plugins.spec.js |   33 +++++++++++++++++++++++++--------
 1 files changed, 25 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/06bd1aab/spec/util/plugins.spec.js
----------------------------------------------------------------------
diff --git a/spec/util/plugins.spec.js b/spec/util/plugins.spec.js
index d2af311..8f217cf 100644
--- a/spec/util/plugins.spec.js
+++ b/spec/util/plugins.spec.js
@@ -29,17 +29,35 @@ var http   = require('http'),
 describe('plugins utility module', function(){
     describe('clonePluginGitRepo', function(){
         it('should shell out to git clone with correct arguments', function(){
-            var mySpy = spyOn(shell, 'exec');
+            var execSpy = spyOn(shell, 'exec').andReturn({
+                code: 0,
+                output: 'git output'
+            });
+            var fake_id = 'fake.plugin.id';
+            var xml = {
+                getroot: function() {
+                    return { attrib: { id: fake_id } };
+                }
+            };
+
+            spyOn(xml_helpers, 'parseElementtreeSync').andReturn(xml);
+            spyOn(shell, 'cp');
             var plugin_git_url = 'https://github.com/imhotep/ChildBrowser'
-            
-            plugins.clonePluginGitRepo(plugin_git_url, temp, '.');
-            
-            expect(mySpy).toHaveBeenCalled();
+
+            var callback = jasmine.createSpy();
+
+            plugins.clonePluginGitRepo(plugin_git_url, temp, '.', undefined, callback);
+
+            expect(execSpy).toHaveBeenCalled();
             var git_clone_regex = new RegExp('^git clone "' + plugin_git_url + '" ".*"$',
'gi');
-            expect(mySpy.mostRecentCall.args[0]).toMatch(git_clone_regex);
+            expect(execSpy.mostRecentCall.args[0]).toMatch(git_clone_regex);
+
+            expect(callback).toHaveBeenCalled();
+            expect(callback.mostRecentCall.args[0]).toBe(null);
+            expect(callback.mostRecentCall.args[1]).toMatch(new RegExp('/' + fake_id + '$'));
         });
         it('should take into account subdirectory argument when copying over final repository
into plugins+plugin_id directory', function() {
-            var exec_spy = spyOn(shell, 'exec');
+            var exec_spy = spyOn(shell, 'exec').andReturn({ code: 0, output: 'git clone output'
});
             var cp_spy = spyOn(shell, 'cp');
             var fake_id = 'VillageDrunkard';
             var xml_spy = spyOn(xml_helpers, 'parseElementtreeSync').andReturn({
@@ -53,7 +71,6 @@ describe('plugins utility module', function(){
             
             var fake_subdir = 'TheBrainRecoilsInHorror';
             plugins.clonePluginGitRepo(plugin_git_url, temp, fake_subdir);
-            exec_spy.mostRecentCall.args[2](0); // fake out shell.exec finishing appropriately
(so we dont ACTUALLY shell out to git-clone, assume it worked fine)
             var expected_subdir_cp_path = new RegExp(fake_subdir + '[\\\\\\/]\\*$', 'gi');
             expect(cp_spy.mostRecentCall.args[1]).toMatch(expected_subdir_cp_path);
             expect(cp_spy.mostRecentCall.args[2]).toEqual(path.join(temp, fake_id));


Mime
View raw message