mobile_template 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (211) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +22 -0
  4. data/README.md +28 -0
  5. data/Rakefile +3 -0
  6. data/bin/mobile_template +71 -0
  7. data/lib/mobile_template/version.rb +4 -0
  8. data/lib/mobile_template.rb +5 -0
  9. data/mobile_template.gemspec +21 -0
  10. data/templates/assets/Gemfile +4 -0
  11. data/templates/assets/config.rb +96 -0
  12. data/templates/assets/config.ru +4 -0
  13. data/templates/assets/source/images/vendor/ajax-loader.gif +0 -0
  14. data/templates/assets/source/images/vendor/ajax-loader.png +0 -0
  15. data/templates/assets/source/images/vendor/icons-18-black.png +0 -0
  16. data/templates/assets/source/images/vendor/icons-18-white.png +0 -0
  17. data/templates/assets/source/images/vendor/icons-36-black.png +0 -0
  18. data/templates/assets/source/images/vendor/icons-36-white.png +0 -0
  19. data/templates/assets/source/index.html.erb +2 -0
  20. data/templates/assets/source/javascripts/app/index.js.coffee +2 -0
  21. data/templates/assets/source/javascripts/application.js.coffee +5 -0
  22. data/templates/assets/source/javascripts/vendor/cordova.js +4841 -0
  23. data/templates/assets/source/javascripts/vendor/jquery.js +9267 -0
  24. data/templates/assets/source/javascripts/vendor/jquery.mobile.js +7410 -0
  25. data/templates/assets/source/layout.erb +24 -0
  26. data/templates/assets/source/stylesheets/application.css.scss +2 -0
  27. data/templates/assets/source/stylesheets/vendor/jquery.mobile.css.scss +1872 -0
  28. data/templates/cordova_android/.gitignore +18 -0
  29. data/templates/cordova_android/LICENSE +202 -0
  30. data/templates/cordova_android/NOTICE +5 -0
  31. data/templates/cordova_android/README.md +95 -0
  32. data/templates/cordova_android/VERSION +1 -0
  33. data/templates/cordova_android/bin/BOOM +4 -0
  34. data/templates/cordova_android/bin/autotest +2 -0
  35. data/templates/cordova_android/bin/bench +29 -0
  36. data/templates/cordova_android/bin/create +46 -0
  37. data/templates/cordova_android/bin/create.bat +1 -0
  38. data/templates/cordova_android/bin/create.js +88 -0
  39. data/templates/cordova_android/bin/create.xml +79 -0
  40. data/templates/cordova_android/bin/node_modules/.bin/cake +7 -0
  41. data/templates/cordova_android/bin/node_modules/.bin/coffee +7 -0
  42. data/templates/cordova_android/bin/node_modules/.bin/nodeunit +120 -0
  43. data/templates/cordova_android/bin/node_modules/coffee-script/.npmignore +11 -0
  44. data/templates/cordova_android/bin/node_modules/coffee-script/LICENSE +22 -0
  45. data/templates/cordova_android/bin/node_modules/coffee-script/README +48 -0
  46. data/templates/cordova_android/bin/node_modules/coffee-script/Rakefile +78 -0
  47. data/templates/cordova_android/bin/node_modules/coffee-script/bin/cake +7 -0
  48. data/templates/cordova_android/bin/node_modules/coffee-script/bin/coffee +7 -0
  49. data/templates/cordova_android/bin/node_modules/coffee-script/extras/jsl.conf +44 -0
  50. data/templates/cordova_android/bin/node_modules/coffee-script/lib/browser.js +75 -0
  51. data/templates/cordova_android/bin/node_modules/coffee-script/lib/cake.js +76 -0
  52. data/templates/cordova_android/bin/node_modules/coffee-script/lib/coffee-script.js +135 -0
  53. data/templates/cordova_android/bin/node_modules/coffee-script/lib/command.js +301 -0
  54. data/templates/cordova_android/bin/node_modules/coffee-script/lib/grammar.js +591 -0
  55. data/templates/cordova_android/bin/node_modules/coffee-script/lib/helpers.js +66 -0
  56. data/templates/cordova_android/bin/node_modules/coffee-script/lib/index.js +8 -0
  57. data/templates/cordova_android/bin/node_modules/coffee-script/lib/lexer.js +656 -0
  58. data/templates/cordova_android/bin/node_modules/coffee-script/lib/nodes.js +2289 -0
  59. data/templates/cordova_android/bin/node_modules/coffee-script/lib/optparse.js +111 -0
  60. data/templates/cordova_android/bin/node_modules/coffee-script/lib/parser.js +676 -0
  61. data/templates/cordova_android/bin/node_modules/coffee-script/lib/repl.js +123 -0
  62. data/templates/cordova_android/bin/node_modules/coffee-script/lib/rewriter.js +363 -0
  63. data/templates/cordova_android/bin/node_modules/coffee-script/lib/scope.js +120 -0
  64. data/templates/cordova_android/bin/node_modules/coffee-script/package.json +27 -0
  65. data/templates/cordova_android/bin/node_modules/nodeunit/.gitignore +5 -0
  66. data/templates/cordova_android/bin/node_modules/nodeunit/.npmignore +3 -0
  67. data/templates/cordova_android/bin/node_modules/nodeunit/CONTRIBUTORS.md +60 -0
  68. data/templates/cordova_android/bin/node_modules/nodeunit/LICENSE +19 -0
  69. data/templates/cordova_android/bin/node_modules/nodeunit/Makefile +126 -0
  70. data/templates/cordova_android/bin/node_modules/nodeunit/README.md +432 -0
  71. data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit +120 -0
  72. data/templates/cordova_android/bin/node_modules/nodeunit/bin/nodeunit.json +10 -0
  73. data/templates/cordova_android/bin/node_modules/nodeunit/deps/async.js +623 -0
  74. data/templates/cordova_android/bin/node_modules/nodeunit/deps/console.log.js +55 -0
  75. data/templates/cordova_android/bin/node_modules/nodeunit/deps/ejs.js +125 -0
  76. data/templates/cordova_android/bin/node_modules/nodeunit/deps/json2.js +483 -0
  77. data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/nodeunit.js +1757 -0
  78. data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite1.js +12 -0
  79. data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/suite2.js +13 -0
  80. data/templates/cordova_android/bin/node_modules/nodeunit/examples/browser/test.html +16 -0
  81. data/templates/cordova_android/bin/node_modules/nodeunit/img/example_fail.png +0 -0
  82. data/templates/cordova_android/bin/node_modules/nodeunit/img/example_pass.png +0 -0
  83. data/templates/cordova_android/bin/node_modules/nodeunit/index.js +3 -0
  84. data/templates/cordova_android/bin/node_modules/nodeunit/lib/assert.js +316 -0
  85. data/templates/cordova_android/bin/node_modules/nodeunit/lib/core.js +260 -0
  86. data/templates/cordova_android/bin/node_modules/nodeunit/lib/nodeunit.js +82 -0
  87. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/browser.js +119 -0
  88. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/default.js +123 -0
  89. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/html.js +107 -0
  90. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/index.js +9 -0
  91. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/junit.js +183 -0
  92. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/minimal.js +112 -0
  93. data/templates/cordova_android/bin/node_modules/nodeunit/lib/reporters/skip_passed.js +105 -0
  94. data/templates/cordova_android/bin/node_modules/nodeunit/lib/track.js +48 -0
  95. data/templates/cordova_android/bin/node_modules/nodeunit/lib/types.js +187 -0
  96. data/templates/cordova_android/bin/node_modules/nodeunit/lib/utils.js +209 -0
  97. data/templates/cordova_android/bin/node_modules/nodeunit/man1/nodeunit.1 +95 -0
  98. data/templates/cordova_android/bin/node_modules/nodeunit/nodelint.cfg +4 -0
  99. data/templates/cordova_android/bin/node_modules/nodeunit/package.json +56 -0
  100. data/templates/cordova_android/bin/node_modules/nodeunit/share/junit.xml.ejs +19 -0
  101. data/templates/cordova_android/bin/node_modules/nodeunit/share/license.js +11 -0
  102. data/templates/cordova_android/bin/node_modules/nodeunit/share/nodeunit.css +70 -0
  103. data/templates/cordova_android/bin/templates/project/.cordova/android/readme.md +1 -0
  104. data/templates/cordova_android/bin/templates/project/.cordova/readme.md +3 -0
  105. data/templates/cordova_android/bin/templates/project/cordova/create +36 -0
  106. data/templates/cordova_android/bin/templates/project/cordova/debug +9 -0
  107. data/templates/cordova_android/bin/templates/project/cordova/emulate +12 -0
  108. data/templates/cordova_android/bin/templates/project/cordova/log +3 -0
  109. data/templates/cordova_android/bin/templates/project/cordova/templates/Activity.java +16 -0
  110. data/templates/cordova_android/bin/templates/project/cordova/templates/project/AndroidManifest.xml +50 -0
  111. data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/index.html +42 -0
  112. data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/main.js +146 -0
  113. data/templates/cordova_android/bin/templates/project/cordova/templates/project/assets/www/master.css +96 -0
  114. data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/drawable/icon.png +0 -0
  115. data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/cordova.xml +5 -0
  116. data/templates/cordova_android/bin/templates/project/cordova/templates/project/res/xml/plugins.xml +19 -0
  117. data/templates/cordova_android/bin/test +26 -0
  118. data/templates/cordova_android/bin/tests/autotest.coffee +4 -0
  119. data/templates/cordova_android/bin/tests/create.coffee +21 -0
  120. data/templates/cordova_android/bin/tests/debug.coffee +0 -0
  121. data/templates/cordova_android/bin/tests/test.coffee +0 -0
  122. data/templates/cordova_android/framework/.classpath +8 -0
  123. data/templates/cordova_android/framework/.project +33 -0
  124. data/templates/cordova_android/framework/AndroidManifest.xml +68 -0
  125. data/templates/cordova_android/framework/ant.properties +34 -0
  126. data/templates/cordova_android/framework/assets/js/accelerometer.js +137 -0
  127. data/templates/cordova_android/framework/assets/js/app.js +89 -0
  128. data/templates/cordova_android/framework/assets/js/battery.js +134 -0
  129. data/templates/cordova_android/framework/assets/js/camera.js +168 -0
  130. data/templates/cordova_android/framework/assets/js/capture.js +203 -0
  131. data/templates/cordova_android/framework/assets/js/compass.js +168 -0
  132. data/templates/cordova_android/framework/assets/js/contact.js +310 -0
  133. data/templates/cordova_android/framework/assets/js/cordova.android.js +4841 -0
  134. data/templates/cordova_android/framework/assets/js/cordova.js.base +924 -0
  135. data/templates/cordova_android/framework/assets/js/crypto.js +54 -0
  136. data/templates/cordova_android/framework/assets/js/device.js +83 -0
  137. data/templates/cordova_android/framework/assets/js/file.js +1082 -0
  138. data/templates/cordova_android/framework/assets/js/filetransfer.js +125 -0
  139. data/templates/cordova_android/framework/assets/js/geolocation.js +209 -0
  140. data/templates/cordova_android/framework/assets/js/header.txt +19 -0
  141. data/templates/cordova_android/framework/assets/js/media.js +233 -0
  142. data/templates/cordova_android/framework/assets/js/network.js +100 -0
  143. data/templates/cordova_android/framework/assets/js/notification.js +133 -0
  144. data/templates/cordova_android/framework/assets/js/position.js +100 -0
  145. data/templates/cordova_android/framework/assets/js/storage.js +439 -0
  146. data/templates/cordova_android/framework/assets/www/index.html +27 -0
  147. data/templates/cordova_android/framework/build.xml +216 -0
  148. data/templates/cordova_android/framework/libs/commons-codec-1.3.jar +0 -0
  149. data/templates/cordova_android/framework/proguard-project.txt +20 -0
  150. data/templates/cordova_android/framework/project.properties +14 -0
  151. data/templates/cordova_android/framework/res/drawable/icon.png +0 -0
  152. data/templates/cordova_android/framework/res/drawable/splash.png +0 -0
  153. data/templates/cordova_android/framework/res/layout/main.xml +29 -0
  154. data/templates/cordova_android/framework/res/values/strings.xml +23 -0
  155. data/templates/cordova_android/framework/res/xml/cordova.xml +37 -0
  156. data/templates/cordova_android/framework/res/xml/plugins.xml +37 -0
  157. data/templates/cordova_android/framework/src/com/phonegap/api/IPlugin.java +27 -0
  158. data/templates/cordova_android/framework/src/com/phonegap/api/LOG.java +28 -0
  159. data/templates/cordova_android/framework/src/com/phonegap/api/PhonegapActivity.java +28 -0
  160. data/templates/cordova_android/framework/src/com/phonegap/api/Plugin.java +27 -0
  161. data/templates/cordova_android/framework/src/com/phonegap/api/PluginManager.java +35 -0
  162. data/templates/cordova_android/framework/src/com/phonegap/api/PluginResult.java +53 -0
  163. data/templates/cordova_android/framework/src/org/apache/cordova/AccelListener.java +311 -0
  164. data/templates/cordova_android/framework/src/org/apache/cordova/App.java +198 -0
  165. data/templates/cordova_android/framework/src/org/apache/cordova/AudioHandler.java +364 -0
  166. data/templates/cordova_android/framework/src/org/apache/cordova/AudioPlayer.java +450 -0
  167. data/templates/cordova_android/framework/src/org/apache/cordova/AuthenticationToken.java +69 -0
  168. data/templates/cordova_android/framework/src/org/apache/cordova/BatteryListener.java +156 -0
  169. data/templates/cordova_android/framework/src/org/apache/cordova/CallbackServer.java +431 -0
  170. data/templates/cordova_android/framework/src/org/apache/cordova/CameraLauncher.java +500 -0
  171. data/templates/cordova_android/framework/src/org/apache/cordova/Capture.java +400 -0
  172. data/templates/cordova_android/framework/src/org/apache/cordova/CompassListener.java +308 -0
  173. data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessor.java +198 -0
  174. data/templates/cordova_android/framework/src/org/apache/cordova/ContactAccessorSdk5.java +1934 -0
  175. data/templates/cordova_android/framework/src/org/apache/cordova/ContactManager.java +113 -0
  176. data/templates/cordova_android/framework/src/org/apache/cordova/CordovaChromeClient.java +314 -0
  177. data/templates/cordova_android/framework/src/org/apache/cordova/CordovaWebViewClient.java +306 -0
  178. data/templates/cordova_android/framework/src/org/apache/cordova/Device.java +219 -0
  179. data/templates/cordova_android/framework/src/org/apache/cordova/DirectoryManager.java +161 -0
  180. data/templates/cordova_android/framework/src/org/apache/cordova/DroidGap.java +1417 -0
  181. data/templates/cordova_android/framework/src/org/apache/cordova/ExifHelper.java +165 -0
  182. data/templates/cordova_android/framework/src/org/apache/cordova/FileTransfer.java +458 -0
  183. data/templates/cordova_android/framework/src/org/apache/cordova/FileUploadResult.java +63 -0
  184. data/templates/cordova_android/framework/src/org/apache/cordova/FileUtils.java +1048 -0
  185. data/templates/cordova_android/framework/src/org/apache/cordova/GeoBroker.java +165 -0
  186. data/templates/cordova_android/framework/src/org/apache/cordova/GeoListener.java +133 -0
  187. data/templates/cordova_android/framework/src/org/apache/cordova/GpsListener.java +163 -0
  188. data/templates/cordova_android/framework/src/org/apache/cordova/HttpHandler.java +80 -0
  189. data/templates/cordova_android/framework/src/org/apache/cordova/LinearLayoutSoftKeyboardDetect.java +104 -0
  190. data/templates/cordova_android/framework/src/org/apache/cordova/NetworkListener.java +153 -0
  191. data/templates/cordova_android/framework/src/org/apache/cordova/NetworkManager.java +248 -0
  192. data/templates/cordova_android/framework/src/org/apache/cordova/Notification.java +366 -0
  193. data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceNode.java +34 -0
  194. data/templates/cordova_android/framework/src/org/apache/cordova/PreferenceSet.java +62 -0
  195. data/templates/cordova_android/framework/src/org/apache/cordova/StandAlone.java +35 -0
  196. data/templates/cordova_android/framework/src/org/apache/cordova/Storage.java +239 -0
  197. data/templates/cordova_android/framework/src/org/apache/cordova/TempListener.java +112 -0
  198. data/templates/cordova_android/framework/src/org/apache/cordova/api/CordovaInterface.java +145 -0
  199. data/templates/cordova_android/framework/src/org/apache/cordova/api/IPlugin.java +116 -0
  200. data/templates/cordova_android/framework/src/org/apache/cordova/api/LOG.java +234 -0
  201. data/templates/cordova_android/framework/src/org/apache/cordova/api/Plugin.java +210 -0
  202. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginManager.java +359 -0
  203. data/templates/cordova_android/framework/src/org/apache/cordova/api/PluginResult.java +119 -0
  204. data/templates/cordova_android/framework/src/org/apache/cordova/file/EncodingException.java +28 -0
  205. data/templates/cordova_android/framework/src/org/apache/cordova/file/FileExistsException.java +28 -0
  206. data/templates/cordova_android/framework/src/org/apache/cordova/file/InvalidModificationException.java +29 -0
  207. data/templates/cordova_android/framework/src/org/apache/cordova/file/NoModificationAllowedException.java +28 -0
  208. data/templates/cordova_android/framework/src/org/apache/cordova/file/TypeMismatchException.java +29 -0
  209. data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceNodeTest.java +53 -0
  210. data/templates/cordova_android/framework/test/org/apache/cordova/PreferenceSetTest.java +73 -0
  211. metadata +279 -0
@@ -0,0 +1,60 @@
1
+ Nodeunit contributors (sorted alphabeticaly)
2
+ ============================================
3
+
4
+ * **[Alex Gorbatchev](https://github.com/alexgorbatchev)**
5
+
6
+ * Deeper default object inspection
7
+ * Timeout to ensure flushing of console output (default reporter)
8
+
9
+ * **[Alex Wolfe](https://github.com/alexkwolfe)**
10
+
11
+ * HTML test reporter
12
+
13
+ * **[Caolan McMahon](https://github.com/caolan)**
14
+
15
+ * Author and maintainer
16
+ * Most features develpopment
17
+
18
+ * **[Carl Fürstenberg](https://github.com/azatoth)**
19
+
20
+ * Debian-friendly Makefile, supports both 'node' and 'nodejs' executables
21
+ * Sandbox utility
22
+ * Minimal test reporter
23
+
24
+ * **[Gerad Suyderhoud](https://github.com/gerad)**
25
+
26
+ * First comand-line tool
27
+
28
+ * **[Kadir Pekel](https://github.com/coffeemate)**
29
+
30
+ * Improvements to default test reporter
31
+ * HTTP test utility
32
+
33
+ * **[Matthias Lübken](https://github.com/luebken)**
34
+
35
+ * Utility functions for tracking incomplete tests on exit
36
+
37
+ * **[Oleg Efimov](https://github.com/Sannis)**
38
+
39
+ * Adding 'make lint' and fixing nodelint errors
40
+ * Option parsing, --help text and config file support
41
+ * Reporters option for command-line tool
42
+
43
+ * **[Orlando Vazquez](https://github.com/orlandov)**
44
+
45
+ * Added jUnit XML reporter
46
+
47
+ * **[Ryan Dahl](https://github.com/ry)**
48
+
49
+ * Add package.json
50
+
51
+ * **[Sam Stephenson](https://github.com/sstephenson)**
52
+
53
+ * Coffee-script support
54
+
55
+ * **[Thomas Mayfield](https://github.com/thegreatape)**
56
+
57
+ * Async setUp and tearDown support for testCase
58
+
59
+ **[Full contributors list](https://github.com/caolan/nodeunit/contributors).**
60
+
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2010 Caolan McMahon
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,126 @@
1
+ PACKAGE = nodeunit
2
+ NODEJS = $(if $(shell test -f /usr/bin/nodejs && echo "true"),nodejs,node)
3
+
4
+ PREFIX ?= /usr/local
5
+ BINDIR ?= $(PREFIX)/bin
6
+ DATADIR ?= $(PREFIX)/share
7
+ MANDIR ?= $(PREFIX)/share/man
8
+ LIBDIR ?= $(PREFIX)/lib
9
+ NODEJSLIBDIR ?= $(LIBDIR)/$(NODEJS)
10
+
11
+ BUILDDIR = dist
12
+
13
+ DOCS = $(shell find doc -name '*.md' \
14
+ |sed 's|.md|.1|g' \
15
+ |sed 's|doc/|man1/|g' \
16
+ )
17
+
18
+
19
+ $(shell if [ ! -d $(BUILDDIR) ]; then mkdir $(BUILDDIR); fi)
20
+
21
+ all: build doc
22
+
23
+ browser:
24
+ # super hacky build script for browser version!
25
+ mkdir -p $(BUILDDIR)/browser
26
+ rm -rf $(BUILDDIR)/browser/*
27
+ # build browser version of nodeunit.js
28
+ cat share/license.js >> $(BUILDDIR)/browser/nodeunit.js
29
+ echo "nodeunit = (function(){" >> $(BUILDDIR)/browser/nodeunit.js
30
+ cat deps/json2.js >> $(BUILDDIR)/browser/nodeunit.js
31
+ # make assert global
32
+ echo "var assert = this.assert = {};" >> $(BUILDDIR)/browser/nodeunit.js
33
+ echo "var types = {};" >> $(BUILDDIR)/browser/nodeunit.js
34
+ echo "var core = {};" >> $(BUILDDIR)/browser/nodeunit.js
35
+ echo "var nodeunit = {};" >> $(BUILDDIR)/browser/nodeunit.js
36
+ echo "var reporter = {};" >> $(BUILDDIR)/browser/nodeunit.js
37
+ cat deps/async.js >> $(BUILDDIR)/browser/nodeunit.js
38
+ echo "(function(exports){" >> $(BUILDDIR)/browser/nodeunit.js
39
+ cat lib/assert.js >> $(BUILDDIR)/browser/nodeunit.js
40
+ echo "})(assert);" >> $(BUILDDIR)/browser/nodeunit.js
41
+ echo "(function(exports){" >> $(BUILDDIR)/browser/nodeunit.js
42
+ cat lib/types.js >> $(BUILDDIR)/browser/nodeunit.js
43
+ echo "})(types);" >> $(BUILDDIR)/browser/nodeunit.js
44
+ echo "(function(exports){" >> $(BUILDDIR)/browser/nodeunit.js
45
+ cat lib/core.js >> $(BUILDDIR)/browser/nodeunit.js
46
+ echo "})(core);" >> $(BUILDDIR)/browser/nodeunit.js
47
+ echo "(function(exports){" >> $(BUILDDIR)/browser/nodeunit.js
48
+ cat lib/reporters/browser.js >> $(BUILDDIR)/browser/nodeunit.js
49
+ echo "})(reporter);" >> $(BUILDDIR)/browser/nodeunit.js
50
+ echo "nodeunit = core;" >> $(BUILDDIR)/browser/nodeunit.js
51
+ echo "nodeunit.assert = assert;" >> $(BUILDDIR)/browser/nodeunit.js
52
+ echo "nodeunit.reporter = reporter;" >> $(BUILDDIR)/browser/nodeunit.js
53
+ echo "nodeunit.run = reporter.run;" >> $(BUILDDIR)/browser/nodeunit.js
54
+ echo "return nodeunit; })();" >> $(BUILDDIR)/browser/nodeunit.js
55
+ sed -i "/\@REMOVE_LINE_FOR_BROWSER/d" $(BUILDDIR)/browser/nodeunit.js
56
+ # copy nodeunit.css
57
+ cp share/nodeunit.css $(BUILDDIR)/browser/nodeunit.css
58
+ # create nodeunit.min.js
59
+ uglifyjs $(BUILDDIR)/browser/nodeunit.js > $(BUILDDIR)/browser/nodeunit.min.js
60
+ # create test scripts
61
+ mkdir -p $(BUILDDIR)/browser/test
62
+ cp test/test.html $(BUILDDIR)/browser/test/test.html
63
+ # test-base.js
64
+ echo "(function (exports) {" > $(BUILDDIR)/browser/test/test-base.js
65
+ cat test/test-base.js >> $(BUILDDIR)/browser/test/test-base.js
66
+ echo "})(this.test_base = {});" >> $(BUILDDIR)/browser/test/test-base.js
67
+ sed -i "/\@REMOVE_LINE_FOR_BROWSER/d" $(BUILDDIR)/browser/test/test-base.js
68
+ # test-runmodule.js
69
+ echo "(function (exports) {" > $(BUILDDIR)/browser/test/test-runmodule.js
70
+ cat test/test-runmodule.js >> $(BUILDDIR)/browser/test/test-runmodule.js
71
+ echo "})(this.test_runmodule = {});" >> $(BUILDDIR)/browser/test/test-runmodule.js
72
+ sed -i "/\@REMOVE_LINE_FOR_BROWSER/d" $(BUILDDIR)/browser/test/test-runmodule.js
73
+ # test-runtest.js
74
+ echo "(function (exports) {" > $(BUILDDIR)/browser/test/test-runtest.js
75
+ cat test/test-runtest.js >> $(BUILDDIR)/browser/test/test-runtest.js
76
+ echo "})(this.test_runtest = {});" >> $(BUILDDIR)/browser/test/test-runtest.js
77
+ sed -i "/\@REMOVE_LINE_FOR_BROWSER/d" $(BUILDDIR)/browser/test/test-runtest.js
78
+ # test-testcase.js
79
+ echo "(function (exports) {" > $(BUILDDIR)/browser/test/test-testcase.js
80
+ cat test/test-testcase.js >> $(BUILDDIR)/browser/test/test-testcase.js
81
+ echo "})(this.test_testcase = {});" >> $(BUILDDIR)/browser/test/test-testcase.js
82
+ sed -i "/\@REMOVE_LINE_FOR_BROWSER/d" $(BUILDDIR)/browser/test/test-testcase.js
83
+ # copy nodeunit.js to dist/browser/test to make it easier for me to host and
84
+ # run on windows VMs with IE
85
+ cp $(BUILDDIR)/browser/nodeunit.js $(BUILDDIR)/browser/test/nodeunit.js
86
+ cp $(BUILDDIR)/browser/nodeunit.css $(BUILDDIR)/browser/test/nodeunit.css
87
+
88
+ build: stamp-build
89
+
90
+ stamp-build: $(wildcard deps/* lib/*.js)
91
+ touch $@;
92
+ mkdir -p $(BUILDDIR)/nodeunit
93
+ cp -R bin deps index.js lib package.json $(BUILDDIR)/nodeunit
94
+ printf '#!/bin/sh\n$(NODEJS) $(NODEJSLIBDIR)/$(PACKAGE)/bin/nodeunit $$@' > $(BUILDDIR)/nodeunit.sh
95
+
96
+ test:
97
+ $(NODEJS) ./bin/nodeunit test
98
+
99
+ install: build
100
+ install -d $(NODEJSLIBDIR)
101
+ cp -a $(BUILDDIR)/nodeunit $(NODEJSLIBDIR)
102
+ install -m 0755 $(BUILDDIR)/nodeunit.sh $(BINDIR)/nodeunit
103
+ install -d $(MANDIR)/man1/
104
+ cp -a man1/nodeunit.1 $(MANDIR)/man1/
105
+
106
+ uninstall:
107
+ rm -rf $(NODEJSLIBDIR)/nodeunit $(NODEJSLIBDIR)/nodeunit.js $(BINDIR)/nodeunit
108
+ rm -rf $(MANDIR)/man1/nodeunit.1
109
+
110
+ clean:
111
+ rm -rf $(BUILDDIR) stamp-build
112
+
113
+ lint:
114
+ nodelint --config nodelint.cfg ./index.js ./bin/nodeunit ./bin/nodeunit.json ./lib/*.js ./lib/reporters/*.js ./test/*.js
115
+
116
+ doc: man1 $(DOCS)
117
+ @true
118
+
119
+ man1:
120
+ @if ! test -d man1 ; then mkdir -p man1 ; fi
121
+
122
+ # use `npm install ronn` for this to work.
123
+ man1/%.1: doc/%.md
124
+ ronn --roff $< > $@
125
+
126
+ .PHONY: browser test install uninstall build all
@@ -0,0 +1,432 @@
1
+ Nodeunit
2
+ ========
3
+
4
+ Simple syntax, powerful tools. Nodeunit provides easy async unit testing for
5
+ node.js and the browser.
6
+
7
+ * Simple to use
8
+ * Just export the tests from a module
9
+ * Works with node.js and in the browser.
10
+ * Helps you avoid common pitfalls when testing asynchronous code
11
+ * Easy to add test cases with setUp and tearDown functions if you wish
12
+ * Flexible reporters for custom output, built-in support for HTML and jUnit XML
13
+ * Allows the use of mocks and stubs
14
+
15
+ __Contributors__
16
+
17
+ * [alexgorbatchev](https://github.com/alexgorbatchev)
18
+ * [alexkwolfe](https://github.com/alexkwolfe)
19
+ * [azatoth](https://github.com/azatoth)
20
+ * [coffeemate](https://github.com/coffeemate)
21
+ * [luebken](https://github.com/luebken)
22
+ * [orlandov](https://github.com/orlandov)
23
+ * [Sannis](https://github.com/Sannis)
24
+ * [sstephenson](https://github.com/sstephenson)
25
+ * [thegreatape](https://github.com/thegreatape)
26
+ * and thanks to [cjohansen](https://github.com/cjohansen) for input and advice
27
+ on implementing setUp and tearDown functions. See
28
+ [cjohansen's fork](https://github.com/cjohansen/nodeunit).
29
+
30
+ Also, check out gerad's [nodeunit-dsl](https://github.com/gerad/nodeunit-dsl)
31
+ project, which implements a 'pretty dsl on top of nodeunit'.
32
+
33
+ More contributor information can be found in the
34
+ [CONTRIBUTORS.md](https://github.com/caolan/nodeunit/blob/master/CONTRIBUTORS.md)
35
+ file.
36
+
37
+ Usage
38
+ -----
39
+
40
+ Here is an example unit test module:
41
+
42
+ exports.testSomething = function(test){
43
+ test.expect(1);
44
+ test.ok(true, "this assertion should pass");
45
+ test.done();
46
+ };
47
+
48
+ exports.testSomethingElse = function(test){
49
+ test.ok(false, "this assertion should fail");
50
+ test.done();
51
+ };
52
+
53
+ When run using the included test runner, this will output the following:
54
+
55
+ <img src="https://github.com/caolan/nodeunit/raw/master/img/example_fail.png" />
56
+
57
+ Installation
58
+ ------------
59
+
60
+ There are two options for installing nodeunit:
61
+
62
+ 1. Clone / download nodeunit from [github](https://github.com/caolan/nodeunit),
63
+ then:
64
+
65
+ make && sudo make install
66
+
67
+ 2. Install via npm:
68
+
69
+ npm install nodeunit
70
+
71
+ API Documentation
72
+ -----------------
73
+
74
+ Nodeunit uses the functions available in the node.js
75
+ [assert module](http://nodejs.org/docs/v0.4.2/api/assert.html):
76
+
77
+ * __ok(value, [message])__ - Tests if value is a true value.
78
+ * __equal(actual, expected, [message])__ - Tests shallow, coercive equality
79
+ with the equal comparison operator ( == ).
80
+ * __notEqual(actual, expected, [message])__ - Tests shallow, coercive
81
+ non-equality with the not equal comparison operator ( != ).
82
+ * __deepEqual(actual, expected, [message])__ - Tests for deep equality.
83
+ * __notDeepEqual(actual, expected, [message])__ - Tests for any deep
84
+ inequality.
85
+ * __strictEqual(actual, expected, [message])__ - Tests strict equality, as
86
+ determined by the strict equality operator ( === )
87
+ * __notStrictEqual(actual, expected, [message])__ - Tests strict non-equality,
88
+ as determined by the strict not equal operator ( !== )
89
+ * __throws(block, [error], [message])__ - Expects block to throw an error.
90
+ * __doesNotThrow(block, [error], [message])__ - Expects block not to throw an
91
+ error.
92
+ * __ifError(value)__ - Tests if value is not a false value, throws if it is a
93
+ true value. Useful when testing the first argument, error in callbacks.
94
+
95
+ Nodeunit also provides the following functions within tests:
96
+
97
+ * __expect(amount)__ - Specify how many assertions are expected to run within a
98
+ test. Very useful for ensuring that all your callbacks and assertions are
99
+ run.
100
+ * __done()__ - Finish the current test function, and move on to the next. ALL
101
+ tests should call this!
102
+
103
+ Nodeunit aims to be simple and easy to learn. This is achieved through using
104
+ existing structures (such as node.js modules) to maximum effect, and reducing
105
+ the API where possible, to make it easier to digest.
106
+
107
+ Tests are simply exported from a module, but they are still run in the order
108
+ they are defined.
109
+
110
+ __Note:__ Users of old nodeunit versions may remember using ok, equals and same
111
+ in the style of qunit, instead of the assert functions above. These functions
112
+ still exist for backwards compatibility, and are simply aliases to their assert
113
+ module counterparts.
114
+
115
+
116
+ Asynchronous Testing
117
+ --------------------
118
+
119
+ When testing asynchronous code, there are a number of sharp edges to watch out
120
+ for. Thankfully, nodeunit is designed to help you avoid as many of these
121
+ pitfalls as possible. For the most part, testing asynchronous code in nodeunit
122
+ _just works_.
123
+
124
+
125
+ ### Tests run in series
126
+
127
+ While running tests in parallel seems like a good idea for speeding up your
128
+ test suite, in practice I've found it means writing much more complicated
129
+ tests. Because of node's module cache, running tests in parallel means mocking
130
+ and stubbing is pretty much impossible. One of the nicest things about testing
131
+ in javascript is the ease of doing stubs:
132
+
133
+ var _readFile = fs.readFile;
134
+ fs.readFile = function(path, callback){
135
+ // its a stub!
136
+ };
137
+ // test function that uses fs.readFile
138
+
139
+ // we're done
140
+ fs.readFile = _readFile;
141
+
142
+ You cannot do this when running tests in parallel. In order to keep testing as
143
+ simple as possible, nodeunit avoids it. Thankfully, most unit-test suites run
144
+ fast anyway.
145
+
146
+
147
+ ### Explicit ending of tests
148
+
149
+ When testing async code its important that tests end at the correct point, not
150
+ just after a given number of assertions. Otherwise your tests can run short,
151
+ ending before all assertions have completed. Its important to detect too
152
+ many assertions as well as too few. Combining explicit ending of tests with
153
+ an expected number of assertions helps to avoid false test passes, so be sure
154
+ to use the test.expect() method at the start of your test functions, and
155
+ test.done() when finished.
156
+
157
+
158
+ Groups, setUp and tearDown
159
+ --------------------------
160
+
161
+ Nodeunit allows the nesting of test functions:
162
+
163
+ exports.test1 = function (test) {
164
+ ...
165
+ }
166
+
167
+ exports.group = {
168
+ test2: function (test) {
169
+ ...
170
+ },
171
+ test3: function (test) {
172
+ ...
173
+ }
174
+ }
175
+
176
+ This would be run as:
177
+
178
+ test1
179
+ group - test2
180
+ group - test3
181
+
182
+ Using these groups its possible to add setUp and tearDown functions to your
183
+ tests. Nodeunit has a utility function called testCase which allows you to
184
+ define a setUp function, which is run before each test, and a tearDown
185
+ function, which is run after each test calls test.done():
186
+
187
+ var testCase = require('nodeunit').testCase;
188
+
189
+ module.exports = testCase({
190
+ setUp: function (callback) {
191
+ this.foo = 'bar';
192
+ callback();
193
+ },
194
+ tearDown: function (callback) {
195
+ // clean up
196
+ callback();
197
+ },
198
+ test1: function (test) {
199
+ test.equals(this.foo, 'bar');
200
+ test.done();
201
+ }
202
+ });
203
+
204
+ In this way, its possible to have multiple groups of tests in a module, each
205
+ group with its own setUp and tearDown functions.
206
+
207
+
208
+ Running Tests
209
+ -------------
210
+
211
+ Nodeunit comes with a basic command-line test runner, which can be installed
212
+ using 'sudo make install'. Example usage:
213
+
214
+ nodeunit testmodule1.js testfolder [...]
215
+
216
+ The default test reporter uses color output, because I think that's more fun :) I
217
+ intend to add a no-color option in future. To give you a feeling of the fun you'll
218
+ be having writing tests, lets fix the example at the start of the README:
219
+
220
+ <img src="https://github.com/caolan/nodeunit/raw/master/img/example_pass.png" />
221
+
222
+ Ahhh, Doesn't that feel better?
223
+
224
+ When using the included test runner, it will exit using the failed number of
225
+ assertions as the exit code. Exiting with 0 when all tests pass.
226
+
227
+
228
+ ### Command-line Options
229
+
230
+ * __--reporter FILE__ - you can set the test reporter to a custom module or
231
+ on of the modules in nodeunit/lib/reporters, when omitted, the default test runner
232
+ is used.
233
+ * __--list-reporters__ - list available build-in reporters.
234
+ * __--config FILE__ - load config options from a JSON file, allows
235
+ the customisation of color schemes for the default test reporter etc. See
236
+ bin/nodeunit.json for current available options.
237
+ * __--version__ or __-v__ - report nodeunit version
238
+ * __--help__ - show nodeunit help
239
+
240
+
241
+ Running tests in the browser
242
+ ----------------------------
243
+
244
+ Nodeunit tests can also be run inside the browser. For example usage, see
245
+ the examples/browser folder. The basic syntax is as follows:
246
+
247
+ __test.html__
248
+
249
+ <html>
250
+ <head>
251
+ <title>Example Test Suite</title>
252
+ <link rel="stylesheet" href="nodeunit.css" type="text/css" />
253
+ <script src="nodeunit.js"></script>
254
+ <script src="suite1.js"></script>
255
+ <script src="suite2.js"></script>
256
+ </head>
257
+ <body>
258
+ <h1 id="nodeunit-header>Example Test Suite</h1>
259
+ <script>
260
+ nodeunit.run({
261
+ 'Suite One': suite1,
262
+ 'Suite Two': suite2
263
+ });
264
+ </script>
265
+ </body>
266
+ </html>
267
+
268
+ Here, suite1 and suite2 are just object literals containing test functions or
269
+ groups, as would be returned if you did require('test-suite') in node.js:
270
+
271
+ __suite1.js__
272
+
273
+ this.suite1 = {
274
+ 'example test': function (test) {
275
+ test.ok(true, 'everything is ok');
276
+ test.done();
277
+ }
278
+ };
279
+
280
+ If you wish to use a commonjs format for your test suites (using exports), it is
281
+ up to you to define the commonjs tools for the browser. There are a number of
282
+ alternatives and its important it fits with your existing code, which is
283
+ why nodeunit does not currently provide this out of the box.
284
+
285
+ In the example above, the tests will run when the page is loaded.
286
+
287
+ The browser-version of nodeunit.js is created in dist/browser when you do, 'make
288
+ browser'. You'll need [UglifyJS](https://github.com/mishoo/UglifyJS) installed in
289
+ order for it to automatically create nodeunit.min.js.
290
+
291
+
292
+ Adding nodeunit to Your Projects
293
+ --------------------------------
294
+
295
+ If you don't want people to have to install the nodeunit command-line tool,
296
+ you'll want to create a script that runs the tests for your project with the
297
+ correct require paths set up. Here's an example test script, with a deps
298
+ directory containing the projects dependencies:
299
+
300
+ #!/usr/bin/env node
301
+ require.paths.unshift(__dirname + '/deps');
302
+
303
+ var reporter = require('nodeunit').reporters.default;
304
+ reporter.run(['test']);
305
+
306
+ If you're using git, you might find it useful to include nodeunit as a
307
+ submodule. Using submodules makes it easy for developers to download nodeunit
308
+ and run your test suite, without cluttering up your repository with
309
+ the source code. To add nodeunit as a git submodule do the following:
310
+
311
+ git submodule add git://github.com/caolan/nodeunit.git deps/nodeunit
312
+
313
+ This will add nodeunit to the deps folder of your project. Now, when cloning
314
+ the repository, nodeunit can be downloaded by doing the following:
315
+
316
+ git submodule init
317
+ git submodule update
318
+
319
+ Let's update the test script above with a helpful hint on how to get nodeunit,
320
+ if its missing:
321
+
322
+ #!/usr/bin/env node
323
+
324
+ require.paths.unshift(__dirname + '/deps');
325
+
326
+ try {
327
+ var reporter = require('nodeunit').reporters.default;
328
+ }
329
+ catch(e) {
330
+ console.log("Cannot find nodeunit module.");
331
+ console.log("You can download submodules for this project by doing:");
332
+ console.log("");
333
+ console.log(" git submodule init");
334
+ console.log(" git submodule update");
335
+ console.log("");
336
+ process.exit();
337
+ }
338
+
339
+ process.chdir(__dirname);
340
+ reporter.run(['test']);
341
+
342
+ Now if someone attempts to run your test suite without nodeunit installed they
343
+ will be prompted to download the submodules for your project.
344
+
345
+
346
+ Built-in Test Reporters
347
+ -----------------------
348
+
349
+ * __default__ - The standard reporter seen in the nodeunit screenshots
350
+ * __minimal__ - Pretty, minimal output, shows errors and progress only
351
+ * __html__ - Outputs a HTML report to stdout
352
+ * __junit__ - Creates jUnit compatible XML reports, which can be used with
353
+ continuous integration tools such as [Hudson](http://hudson-ci.org/).
354
+
355
+
356
+ Writing a Test Reporter
357
+ ---------------------
358
+
359
+ Nodeunit exports runTest(fn, options), runModule(mod, options) and
360
+ runFiles(paths, options). You'll most likely want to run test suites from
361
+ files, which can be done using the latter function. The _options_ argument can
362
+ contain callbacks which run during testing. Nodeunit provides the following
363
+ callbacks:
364
+
365
+ * __moduleStart(name)__ - called before a module is tested
366
+ * __moduleDone(name, assertions)__ - called once all test functions within the
367
+ module have completed (see assertions object reference below)
368
+ ALL tests within the module
369
+ * __testStart(name)__ - called before a test function is run
370
+ * __testDone(name, assertions)__ - called once a test function has completed
371
+ (by calling test.done())
372
+ * __log(assertion)__ - called whenever an assertion is made (see assertion
373
+ object reference below)
374
+ * __done(assertions)__ - called after all tests/modules are complete
375
+
376
+ The __assertion__ object:
377
+
378
+ * __passed()__ - did the assertion pass?
379
+ * __failed()__ - did the assertion fail?
380
+ * __error__ - the AssertionError if the assertion failed
381
+ * __method__ - the nodeunit assertion method used (ok, same, equals...)
382
+ * __message__ - the message the assertion method was called with (optional)
383
+
384
+ The __assertionList__ object:
385
+
386
+ * An array-like object with the following new attributes:
387
+ * __failures()__ - the number of assertions which failed
388
+ * __duration__ - the time taken for the test to complete in msecs
389
+
390
+ For a reference implementation of a test reporter, see lib/reporters/default.js in
391
+ the nodeunit project directory.
392
+
393
+
394
+ Sandbox utility
395
+ ---------------
396
+
397
+ This is a function which evaluates JavaScript files in a sandbox and returns the
398
+ context. The sandbox function can be used for testing client-side code or private
399
+ un-exported functions within a module.
400
+
401
+ var sandbox = require('nodeunit').utils.sandbox;
402
+ var example = sandbox('example.js');
403
+
404
+ __sandbox(files, sandbox)__ - Evaluates JavaScript files in a sandbox, returning
405
+ the context. The first argument can either be a single filename or an array of
406
+ filenames. If multiple filenames are given their contents are concatenated before
407
+ evalution. The second argument is an optional context to use for the sandbox.
408
+
409
+
410
+ Running the nodeunit Tests
411
+ --------------------------
412
+
413
+ The tests for nodeunit are written using nodeunit itself as the test framework.
414
+ However, the module test-base.js first does some basic tests using the assert
415
+ module to ensure that test functions are actually run, and a basic level of
416
+ nodeunit functionality is available.
417
+
418
+ To run the nodeunit tests do:
419
+
420
+ make test
421
+
422
+ __Note:__ There was a bug in node v0.2.0 causing the tests to hang, upgrading
423
+ to v0.2.1 fixes this.
424
+
425
+
426
+ Contributing
427
+ ------------
428
+
429
+ Contributions to the project are most welcome, so feel free to fork and improve.
430
+ When submitting a pull request, please run 'make lint' first to ensure
431
+ we're following a consistent coding style.
432
+