You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2013/04/25 02:08:31 UTC

git commit: ios resource specs

Updated Branches:
  refs/heads/master 24a9c56f4 -> a1bd0e843


ios resource specs


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

Branch: refs/heads/master
Commit: a1bd0e84363ad767de008633871c05609c6b7d9c
Parents: 24a9c56
Author: Fil Maj <ma...@gmail.com>
Authored: Wed Apr 24 17:08:26 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Wed Apr 24 17:08:26 2013 -0700

----------------------------------------------------------------------
 spec/platforms/ios.spec.js           |   21 +++++++++++++--------
 spec/plugins/FaultyPlugin/plugin.xml |    2 +-
 src/platforms/ios.js                 |    2 +-
 3 files changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a1bd0e84/spec/platforms/ios.spec.js
----------------------------------------------------------------------
diff --git a/spec/platforms/ios.spec.js b/spec/platforms/ios.spec.js
index 083f007..e082ce5 100644
--- a/spec/platforms/ios.spec.js
+++ b/spec/platforms/ios.spec.js
@@ -27,6 +27,7 @@ var dummy_id = plugin_et._root.attrib['id'];
 var valid_source = platformTag.findall('./source-file'),
     assets = plugin_et.findall('./asset'),
     valid_headers = platformTag.findall('./header-file'),
+    valid_resources = platformTag.findall('./resource-file'),
     plist_els = platformTag.findall('./plugins-plist'),
     dummy_configs = platformTag.findall('./config-file');
 
@@ -46,6 +47,7 @@ platformTag = plugin_et.find('./platform[@name="ios"]');
 var faulty_id = plugin_et._root.attrib['id'];
 var invalid_source = platformTag.findall('./source-file');
 var invalid_headers = platformTag.findall('./header-file');
+var invalid_resources = platformTag.findall('./resource-file');
 
 xml_path = path.join(plistplugin, 'plugin.xml');
 xml_test = fs.readFileSync(xml_path, 'utf-8');
@@ -271,19 +273,22 @@ describe('ios project handler', function() {
             });
         });
 
-        xdescribe('of <resource-file> elements', function() {
+        describe('of <resource-file> elements', function() {
+            beforeEach(function() {
+                shell.cp('-rf', ios_config_xml_project, temp);
+            });
             it('should throw if resource-file src cannot be found', function() {
-                var headers = copyArray(invalid_headers);
+                var resources = copyArray(invalid_resources);
                 expect(function() {
-                    ios.install(headers, faulty_id, temp, faultyplugin, {});
-                }).toThrow('cannot find "' + path.resolve(faultyplugin, 'src/ios/FaultyPluginCommand.h') + '" ios <header-file>');
+                    ios.install(resources, faulty_id, temp, faultyplugin, {});
+                }).toThrow('cannot find "' + path.resolve(faultyplugin, 'src/ios/IDontExist.bundle') + '" ios <resource-file>');
             });
-            it('should throw if header-file target already exists', function() {
-                var headers = copyArray(valid_headers);
-                var target = path.join(temp, 'SampleApp', 'Plugins', 'DummyPluginCommand.h');
+            it('should throw if resrouce-file target already exists', function() {
+                var resources = copyArray(valid_resources);
+                var target = path.join(temp, 'SampleApp', 'Resources', 'DummyPlugin.bundle');
                 fs.writeFileSync(target, 'some bs', 'utf-8');
                 expect(function() {
-                    ios.install(headers, dummy_id, temp, dummyplugin, {});
+                    ios.install(resources, dummy_id, temp, dummyplugin, {});
                 }).toThrow('target destination "' + target + '" already exists');
             });
             it('should throw if resource-file src cannot be found');

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a1bd0e84/spec/plugins/FaultyPlugin/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/FaultyPlugin/plugin.xml b/spec/plugins/FaultyPlugin/plugin.xml
index 278c89d..b556e9d 100644
--- a/spec/plugins/FaultyPlugin/plugin.xml
+++ b/spec/plugins/FaultyPlugin/plugin.xml
@@ -69,7 +69,7 @@
         <!-- these files don't exist -->
         <header-file src="src/ios/FaultyPluginCommand.h" />
         <source-file src="src/ios/FaultyPluginCommand.m" />
-
+        <resource-file src="src/ios/IDontExist.bundle" />
     </platform>
     <platform name="blackberry">
         <config-file target="config.xml" parent="/widget">

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/a1bd0e84/src/platforms/ios.js
----------------------------------------------------------------------
diff --git a/src/platforms/ios.js b/src/platforms/ios.js
index 2e294c4..a5db1fd 100644
--- a/src/platforms/ios.js
+++ b/src/platforms/ios.js
@@ -220,7 +220,7 @@ function handlePlugin(action, plugin_id, txs, project_dir, plugin_dir, variables
                         destFile = path.resolve(resourcesDir, path.basename(src));
 
                     if (action == 'install') {
-                        if (!fs.existsSync(srcFile)) throw new Error('cannot find "' + srcFile + '" ios <header-file>');
+                        if (!fs.existsSync(srcFile)) throw new Error('cannot find "' + srcFile + '" ios <resource-file>');
                         if (fs.existsSync(destFile)) throw new Error('target destination "' + destFile + '" already exists');
                         xcodeproj.addResourceFile(path.join('Resources', path.basename(src)));
                         shell.cp('-R', srcFile, resourcesDir);