magic_carpet 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +202 -0
  3. data/README.md +232 -0
  4. data/Rakefile +15 -0
  5. data/app/assets/javascripts/magic_carpet/application.js +13 -0
  6. data/app/assets/javascripts/magic_carpet/magic_carpet.js +80 -0
  7. data/app/assets/stylesheets/magic_carpet/application.css +13 -0
  8. data/app/controllers/magic_carpet/application_controller.rb +4 -0
  9. data/app/controllers/magic_carpet/js_fixtures_controller.rb +110 -0
  10. data/app/helpers/magic_carpet/application_helper.rb +4 -0
  11. data/app/helpers/magic_carpet/js_fixtures_helper.rb +139 -0
  12. data/config/routes.rb +3 -0
  13. data/lib/magic_carpet/engine.rb +12 -0
  14. data/lib/magic_carpet/version.rb +3 -0
  15. data/lib/magic_carpet.rb +4 -0
  16. data/lib/tasks/magic_carpet_tasks.rake +4 -0
  17. data/spec/controllers/magic_carpet/js_fixtures_controller_spec.rb +275 -0
  18. data/spec/dummy/README.rdoc +28 -0
  19. data/spec/dummy/Rakefile +6 -0
  20. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  21. data/spec/dummy/app/assets/javascripts/jquery-2.1.0.js +9111 -0
  22. data/spec/dummy/app/assets/javascripts/users.js +2 -0
  23. data/spec/dummy/app/assets/javascripts/wishes.js +2 -0
  24. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  25. data/spec/dummy/app/assets/stylesheets/scaffold.css +56 -0
  26. data/spec/dummy/app/assets/stylesheets/users.css +4 -0
  27. data/spec/dummy/app/assets/stylesheets/wishes.css +4 -0
  28. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  29. data/spec/dummy/app/controllers/users_controller.rb +58 -0
  30. data/spec/dummy/app/controllers/wishes_controller.rb +70 -0
  31. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  32. data/spec/dummy/app/helpers/users_helper.rb +2 -0
  33. data/spec/dummy/app/helpers/wishes_helper.rb +2 -0
  34. data/spec/dummy/app/models/user.rb +3 -0
  35. data/spec/dummy/app/models/wish.rb +4 -0
  36. data/spec/dummy/app/views/layouts/application.html.erb +19 -0
  37. data/spec/dummy/app/views/layouts/other_layout.html.erb +15 -0
  38. data/spec/dummy/app/views/shared/_id_able.html.erb +5 -0
  39. data/spec/dummy/app/views/users/_form.html.erb +29 -0
  40. data/spec/dummy/app/views/users/edit.html.erb +6 -0
  41. data/spec/dummy/app/views/users/index.html.erb +31 -0
  42. data/spec/dummy/app/views/users/new.html.erb +5 -0
  43. data/spec/dummy/app/views/users/show.html.erb +19 -0
  44. data/spec/dummy/app/views/wishes/_form.html.erb +21 -0
  45. data/spec/dummy/app/views/wishes/_some_partial.html.erb +1 -0
  46. data/spec/dummy/app/views/wishes/_wish.html.erb +6 -0
  47. data/spec/dummy/app/views/wishes/_wish_list_item.html.erb +3 -0
  48. data/spec/dummy/app/views/wishes/edit.html.erb +6 -0
  49. data/spec/dummy/app/views/wishes/index.html.erb +22 -0
  50. data/spec/dummy/app/views/wishes/local_models.html.erb +3 -0
  51. data/spec/dummy/app/views/wishes/locals.html.erb +6 -0
  52. data/spec/dummy/app/views/wishes/new.html.erb +5 -0
  53. data/spec/dummy/app/views/wishes/numbers.html.erb +4 -0
  54. data/spec/dummy/app/views/wishes/plain.html.erb +1 -0
  55. data/spec/dummy/app/views/wishes/show.html.erb +9 -0
  56. data/spec/dummy/bin/bundle +3 -0
  57. data/spec/dummy/bin/rails +4 -0
  58. data/spec/dummy/bin/rake +4 -0
  59. data/spec/dummy/config/application.rb +28 -0
  60. data/spec/dummy/config/boot.rb +5 -0
  61. data/spec/dummy/config/database.yml +25 -0
  62. data/spec/dummy/config/environment.rb +5 -0
  63. data/spec/dummy/config/environments/development.rb +29 -0
  64. data/spec/dummy/config/environments/production.rb +80 -0
  65. data/spec/dummy/config/environments/test.rb +36 -0
  66. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  67. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  68. data/spec/dummy/config/initializers/inflections.rb +16 -0
  69. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  70. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  71. data/spec/dummy/config/initializers/session_store.rb +3 -0
  72. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  73. data/spec/dummy/config/locales/en.yml +23 -0
  74. data/spec/dummy/config/routes.rb +9 -0
  75. data/spec/dummy/config.ru +4 -0
  76. data/spec/dummy/db/development.sqlite3 +0 -0
  77. data/spec/dummy/db/migrate/20140201230228_create_wishes.rb +9 -0
  78. data/spec/dummy/db/migrate/20140201230247_create_users.rb +11 -0
  79. data/spec/dummy/db/migrate/20140208042514_associate_users_and_wishes.rb +5 -0
  80. data/spec/dummy/db/schema.rb +31 -0
  81. data/spec/dummy/db/test.sqlite3 +0 -0
  82. data/spec/dummy/log/development.log +21112 -0
  83. data/spec/dummy/log/test.log +33634 -0
  84. data/spec/dummy/public/404.html +58 -0
  85. data/spec/dummy/public/422.html +58 -0
  86. data/spec/dummy/public/500.html +57 -0
  87. data/spec/dummy/public/favicon.ico +0 -0
  88. data/spec/dummy/spec/javascripts/helpers/spec_helper.js +367 -0
  89. data/spec/dummy/spec/javascripts/magic_carpet_spec.js +314 -0
  90. data/spec/dummy/spec/javascripts/support/jasmine.yml +29 -0
  91. data/spec/dummy/tmp/cache/assets/development/sprockets/0743af5c3f490550c6a448f45e6889b4 +0 -0
  92. data/spec/dummy/tmp/cache/assets/development/sprockets/0800f54ee19cf3cee10b956fa9786799 +0 -0
  93. data/spec/dummy/tmp/cache/assets/development/sprockets/082245bc7cce1345893a81643f76284a +0 -0
  94. data/spec/dummy/tmp/cache/assets/development/sprockets/08b0d9573e11dc361c93563cec2a0106 +0 -0
  95. data/spec/dummy/tmp/cache/assets/development/sprockets/09f277e17472af932cda6f7dd86ff943 +0 -0
  96. data/spec/dummy/tmp/cache/assets/development/sprockets/0e3142f2ae2a0b8902383f65b86a5299 +0 -0
  97. data/spec/dummy/tmp/cache/assets/development/sprockets/0f87038bb320b83592e071bff83e4195 +0 -0
  98. data/spec/dummy/tmp/cache/assets/development/sprockets/10925724a66880466e7f3b4e158196cb +0 -0
  99. data/spec/dummy/tmp/cache/assets/development/sprockets/10fb651bf6e564ad505e391670c11a8d +0 -0
  100. data/spec/dummy/tmp/cache/assets/development/sprockets/12090b2e7e2e9ac2632e486d02ee346a +0 -0
  101. data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  102. data/spec/dummy/tmp/cache/assets/development/sprockets/142047722c23a8e9a96c6355d224b67e +0 -0
  103. data/spec/dummy/tmp/cache/assets/development/sprockets/1b4c56479f40fe3f7fc8daf684f4f71c +0 -0
  104. data/spec/dummy/tmp/cache/assets/development/sprockets/1c3579416ea74586464f5969c6949d5d +0 -0
  105. data/spec/dummy/tmp/cache/assets/development/sprockets/1e259f0863fa6da47ded59eef77ac351 +0 -0
  106. data/spec/dummy/tmp/cache/assets/development/sprockets/21d2c592e1570709ecd1208a030cfc66 +0 -0
  107. data/spec/dummy/tmp/cache/assets/development/sprockets/220ab8240fd9e0712b64dd9ff515f5df +0 -0
  108. data/spec/dummy/tmp/cache/assets/development/sprockets/277a51802284d997817fcaca55211243 +0 -0
  109. data/spec/dummy/tmp/cache/assets/development/sprockets/28c409c3bba590030a8074120aa781db +0 -0
  110. data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  111. data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  112. data/spec/dummy/tmp/cache/assets/development/sprockets/35906b4cd565b14db8ba786fc66c7eb3 +0 -0
  113. data/spec/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
  114. data/spec/dummy/tmp/cache/assets/development/sprockets/388a1d725ffd01cc06a34d720ea97775 +0 -0
  115. data/spec/dummy/tmp/cache/assets/development/sprockets/4050a4e5062ab95c9f32e9b6940821ea +0 -0
  116. data/spec/dummy/tmp/cache/assets/development/sprockets/442917e5b534e0e7ac0a3bac0c5299e7 +0 -0
  117. data/spec/dummy/tmp/cache/assets/development/sprockets/45ccf991e042a7cf7abe52d1125eeae3 +0 -0
  118. data/spec/dummy/tmp/cache/assets/development/sprockets/469198efe71fedae413489ff2fad66e4 +0 -0
  119. data/spec/dummy/tmp/cache/assets/development/sprockets/4817f65b5fc5c2042e04af7eb83a4c99 +0 -0
  120. data/spec/dummy/tmp/cache/assets/development/sprockets/497ff8927ce695e3febb3cdfd3e4a74e +0 -0
  121. data/spec/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
  122. data/spec/dummy/tmp/cache/assets/development/sprockets/51202fde1d49c04c5d5588ca203b7b1e +0 -0
  123. data/spec/dummy/tmp/cache/assets/development/sprockets/55ea602f40a0ad2185e22964a16b4d42 +0 -0
  124. data/spec/dummy/tmp/cache/assets/development/sprockets/596788b2d37e650dd4cf582b185f9d37 +0 -0
  125. data/spec/dummy/tmp/cache/assets/development/sprockets/5c09faba4e454de97f078861e82db15c +0 -0
  126. data/spec/dummy/tmp/cache/assets/development/sprockets/5f1a0d05e77ca8b9a1fc2a47e17a8174 +0 -0
  127. data/spec/dummy/tmp/cache/assets/development/sprockets/64de9e1fa2dd01768d6e85552dcdb18a +0 -0
  128. data/spec/dummy/tmp/cache/assets/development/sprockets/68c5fa1f98ca79274b1f6750d8611af5 +0 -0
  129. data/spec/dummy/tmp/cache/assets/development/sprockets/6bcea01ea8389e9a2ee296904803a01c +0 -0
  130. data/spec/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
  131. data/spec/dummy/tmp/cache/assets/development/sprockets/7406b6e2ecfc7b024db7822fb753c796 +0 -0
  132. data/spec/dummy/tmp/cache/assets/development/sprockets/744bda5bad4a3b9b9b244a4583fb6e29 +0 -0
  133. data/spec/dummy/tmp/cache/assets/development/sprockets/786804147f5da16b37ef8932e422797c +0 -0
  134. data/spec/dummy/tmp/cache/assets/development/sprockets/793dc2ede21315a9eabfe2b0a0ff13d4 +0 -0
  135. data/spec/dummy/tmp/cache/assets/development/sprockets/7b1c8fbfabc405ee6e5c8887095e6b43 +0 -0
  136. data/spec/dummy/tmp/cache/assets/development/sprockets/7c2edc3a2733a7bc22c572af66983a2e +0 -0
  137. data/spec/dummy/tmp/cache/assets/development/sprockets/7cd1032c2c1fa8a02016ac207cd9c76f +0 -0
  138. data/spec/dummy/tmp/cache/assets/development/sprockets/7d4bf0f7a6d67ade27f05b9bbdfaa13f +0 -0
  139. data/spec/dummy/tmp/cache/assets/development/sprockets/809136388a8f6d7a862b20361fad205c +0 -0
  140. data/spec/dummy/tmp/cache/assets/development/sprockets/80ba335c5610df2a1defeab247d03cc9 +0 -0
  141. data/spec/dummy/tmp/cache/assets/development/sprockets/817b43e6477d4059b9006261356b7147 +0 -0
  142. data/spec/dummy/tmp/cache/assets/development/sprockets/81b537f4760199f4030b928268605909 +0 -0
  143. data/spec/dummy/tmp/cache/assets/development/sprockets/83521bb0fd5da34426e16d8825eb314e +0 -0
  144. data/spec/dummy/tmp/cache/assets/development/sprockets/85b590662faa5956a7cb3a38390f16ca +0 -0
  145. data/spec/dummy/tmp/cache/assets/development/sprockets/8733ef9be8fb368ac9aa5b1ccbfce14c +0 -0
  146. data/spec/dummy/tmp/cache/assets/development/sprockets/87b209c0c9da28094a8d5581a21262c6 +0 -0
  147. data/spec/dummy/tmp/cache/assets/development/sprockets/8931ae3296ab13e8eed90f434208887f +0 -0
  148. data/spec/dummy/tmp/cache/assets/development/sprockets/8cb4c1afbd9a270155d8cdd697a8b20d +0 -0
  149. data/spec/dummy/tmp/cache/assets/development/sprockets/8d1f1fbd708160b30af96a108fef6c0d +0 -0
  150. data/spec/dummy/tmp/cache/assets/development/sprockets/91ef1ca0ef363be62f4a38fb3fbc2291 +0 -0
  151. data/spec/dummy/tmp/cache/assets/development/sprockets/9a25637a28779d7c49c40044188bd0e5 +0 -0
  152. data/spec/dummy/tmp/cache/assets/development/sprockets/a0d10779d647db6ab1328734733a0e4d +0 -0
  153. data/spec/dummy/tmp/cache/assets/development/sprockets/a0e04aab47dc3631152c26632687f898 +0 -0
  154. data/spec/dummy/tmp/cache/assets/development/sprockets/a74883b193a8e72f27cba5703a696a89 +0 -0
  155. data/spec/dummy/tmp/cache/assets/development/sprockets/a839288628913e4533ef8cba740de1eb +0 -0
  156. data/spec/dummy/tmp/cache/assets/development/sprockets/a95ead461bd72142ffb3040f8cd7cfa0 +0 -0
  157. data/spec/dummy/tmp/cache/assets/development/sprockets/ac47afc414ae67e366a330dc003edf1a +0 -0
  158. data/spec/dummy/tmp/cache/assets/development/sprockets/b1d1383958868d6f0e9e05c848682d70 +0 -0
  159. data/spec/dummy/tmp/cache/assets/development/sprockets/b4ff5ac95c02b56ca97786b337f8b845 +0 -0
  160. data/spec/dummy/tmp/cache/assets/development/sprockets/b718bc4e8c8146520d982e086897fe24 +0 -0
  161. data/spec/dummy/tmp/cache/assets/development/sprockets/b848029d2fa6db3db28ccbce818b399b +0 -0
  162. data/spec/dummy/tmp/cache/assets/development/sprockets/ba05f15307eb6d2c7e31e50768867139 +0 -0
  163. data/spec/dummy/tmp/cache/assets/development/sprockets/c1a8bdfcb2dca842a48acc85d3ff658a +0 -0
  164. data/spec/dummy/tmp/cache/assets/development/sprockets/c2eb6c5cabed0e6b333c035ac8400bbc +0 -0
  165. data/spec/dummy/tmp/cache/assets/development/sprockets/c3dbe303660d299b488648fc157fd32b +0 -0
  166. data/spec/dummy/tmp/cache/assets/development/sprockets/c45af704cb234484a8e1d0852f8fe0bc +0 -0
  167. data/spec/dummy/tmp/cache/assets/development/sprockets/c4868ba5188e0672b480e24d979224d0 +0 -0
  168. data/spec/dummy/tmp/cache/assets/development/sprockets/caa2f86bb055636b69e292f2ae993914 +0 -0
  169. data/spec/dummy/tmp/cache/assets/development/sprockets/ce4b669883cb8df0ccd1c6aca12e0434 +0 -0
  170. data/spec/dummy/tmp/cache/assets/development/sprockets/cebc6db0bbb8120f430da3970b173d2f +0 -0
  171. data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  172. data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  173. data/spec/dummy/tmp/cache/assets/development/sprockets/d8a7bed1e7150777f59a9e107c1acaa8 +0 -0
  174. data/spec/dummy/tmp/cache/assets/development/sprockets/db4f843f0e597f7ba079bec345a91d58 +0 -0
  175. data/spec/dummy/tmp/cache/assets/development/sprockets/dd5a838f402c1f78ff0f6e43b3ce6624 +0 -0
  176. data/spec/dummy/tmp/cache/assets/development/sprockets/dfd7187ca1d53815395570d20d933e13 +0 -0
  177. data/spec/dummy/tmp/cache/assets/development/sprockets/e4092eb95487a855cb730373c97b8756 +0 -0
  178. data/spec/dummy/tmp/cache/assets/development/sprockets/e41b3d9532b5ef87c246ef6eb88417ed +0 -0
  179. data/spec/dummy/tmp/cache/assets/development/sprockets/e8266bddb6510ce3a2bc5ae1469ab3f6 +0 -0
  180. data/spec/dummy/tmp/cache/assets/development/sprockets/e86f67e739e4d85d5b8b1830b327ee67 +0 -0
  181. data/spec/dummy/tmp/cache/assets/development/sprockets/efc1c13c84f6f8686ade375b47913c8d +0 -0
  182. data/spec/dummy/tmp/cache/assets/development/sprockets/f1e3cae1b4d4c1085b32f88d26fd1f89 +0 -0
  183. data/spec/dummy/tmp/cache/assets/development/sprockets/f21b1a83f2c41f61ba73c424b057ee19 +0 -0
  184. data/spec/dummy/tmp/cache/assets/development/sprockets/f25cc7f3223a9259336cb2dd38df220e +0 -0
  185. data/spec/dummy/tmp/cache/assets/development/sprockets/f56253b5f374fff1a33fbbc9881c9124 +0 -0
  186. data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  187. data/spec/dummy/tmp/cache/assets/test/sprockets/10fb651bf6e564ad505e391670c11a8d +0 -0
  188. data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  189. data/spec/dummy/tmp/cache/assets/test/sprockets/142047722c23a8e9a96c6355d224b67e +0 -0
  190. data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  191. data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  192. data/spec/dummy/tmp/cache/assets/test/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
  193. data/spec/dummy/tmp/cache/assets/test/sprockets/4050a4e5062ab95c9f32e9b6940821ea +0 -0
  194. data/spec/dummy/tmp/cache/assets/test/sprockets/51202fde1d49c04c5d5588ca203b7b1e +0 -0
  195. data/spec/dummy/tmp/cache/assets/test/sprockets/596788b2d37e650dd4cf582b185f9d37 +0 -0
  196. data/spec/dummy/tmp/cache/assets/test/sprockets/5f1a0d05e77ca8b9a1fc2a47e17a8174 +0 -0
  197. data/spec/dummy/tmp/cache/assets/test/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
  198. data/spec/dummy/tmp/cache/assets/test/sprockets/81b537f4760199f4030b928268605909 +0 -0
  199. data/spec/dummy/tmp/cache/assets/test/sprockets/87b209c0c9da28094a8d5581a21262c6 +0 -0
  200. data/spec/dummy/tmp/cache/assets/test/sprockets/8cb4c1afbd9a270155d8cdd697a8b20d +0 -0
  201. data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  202. data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  203. data/spec/dummy/tmp/cache/assets/test/sprockets/f56253b5f374fff1a33fbbc9881c9124 +0 -0
  204. data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  205. data/spec/dummy/tmp/jasmine/assets/application.js +9132 -0
  206. data/spec/dummy/tmp/jasmine/assets/boot.js +204 -0
  207. data/spec/dummy/tmp/jasmine/assets/helpers/spec_helper.js +462 -0
  208. data/spec/dummy/tmp/jasmine/assets/jasmine-console-reporter.js +125 -0
  209. data/spec/dummy/tmp/jasmine/assets/jasmine-console-shims.js +31 -0
  210. data/spec/dummy/tmp/jasmine/assets/jasmine-html.js +360 -0
  211. data/spec/dummy/tmp/jasmine/assets/jasmine-specs.js +0 -0
  212. data/spec/dummy/tmp/jasmine/assets/jasmine.css +55 -0
  213. data/spec/dummy/tmp/jasmine/assets/jasmine.js +2403 -0
  214. data/spec/dummy/tmp/jasmine/assets/jquery-2.1.0.js +9112 -0
  215. data/spec/dummy/tmp/jasmine/assets/json2.js +479 -0
  216. data/spec/dummy/tmp/jasmine/assets/magic_carpet/application.js +95 -0
  217. data/spec/dummy/tmp/jasmine/assets/magic_carpet/magic_carpet.js +81 -0
  218. data/spec/dummy/tmp/jasmine/assets/magic_carpet_spec.js +317 -0
  219. data/spec/dummy/tmp/jasmine/assets/users.js +3 -0
  220. data/spec/dummy/tmp/jasmine/assets/wishes.js +3 -0
  221. data/spec/dummy/tmp/jasmine/runner.html +28 -0
  222. data/spec/dummy/tmp/pids/server.pid +1 -0
  223. data/spec/helpers/magic_carpet/js_fixtures_helper_spec.rb +249 -0
  224. data/spec/spec_helper.rb +14 -0
  225. metadata +590 -0
@@ -0,0 +1,2403 @@
1
+ /*
2
+ Copyright (c) 2008-2013 Pivotal Labs
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ */
23
+
24
+ function getJasmineRequireObj() {
25
+ if (typeof module !== "undefined" && module.exports) {
26
+ return exports;
27
+ } else {
28
+ window.jasmineRequire = window.jasmineRequire || {};
29
+ return window.jasmineRequire;
30
+ }
31
+ }
32
+
33
+ getJasmineRequireObj().core = function(jRequire) {
34
+ var j$ = {};
35
+
36
+ jRequire.base(j$);
37
+ j$.util = jRequire.util();
38
+ j$.Any = jRequire.Any();
39
+ j$.CallTracker = jRequire.CallTracker();
40
+ j$.Clock = jRequire.Clock();
41
+ j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler();
42
+ j$.Env = jRequire.Env(j$);
43
+ j$.ExceptionFormatter = jRequire.ExceptionFormatter();
44
+ j$.Expectation = jRequire.Expectation();
45
+ j$.buildExpectationResult = jRequire.buildExpectationResult();
46
+ j$.JsApiReporter = jRequire.JsApiReporter();
47
+ j$.matchersUtil = jRequire.matchersUtil(j$);
48
+ j$.ObjectContaining = jRequire.ObjectContaining(j$);
49
+ j$.pp = jRequire.pp(j$);
50
+ j$.QueueRunner = jRequire.QueueRunner();
51
+ j$.ReportDispatcher = jRequire.ReportDispatcher();
52
+ j$.Spec = jRequire.Spec(j$);
53
+ j$.SpyStrategy = jRequire.SpyStrategy();
54
+ j$.Suite = jRequire.Suite();
55
+ j$.Timer = jRequire.Timer();
56
+ j$.version = jRequire.version();
57
+
58
+ j$.matchers = jRequire.requireMatchers(jRequire, j$);
59
+
60
+ return j$;
61
+ };
62
+
63
+ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
64
+ var availableMatchers = [
65
+ "toBe",
66
+ "toBeCloseTo",
67
+ "toBeDefined",
68
+ "toBeFalsy",
69
+ "toBeGreaterThan",
70
+ "toBeLessThan",
71
+ "toBeNaN",
72
+ "toBeNull",
73
+ "toBeTruthy",
74
+ "toBeUndefined",
75
+ "toContain",
76
+ "toEqual",
77
+ "toHaveBeenCalled",
78
+ "toHaveBeenCalledWith",
79
+ "toMatch",
80
+ "toThrow",
81
+ "toThrowError"
82
+ ],
83
+ matchers = {};
84
+
85
+ for (var i = 0; i < availableMatchers.length; i++) {
86
+ var name = availableMatchers[i];
87
+ matchers[name] = jRequire[name](j$);
88
+ }
89
+
90
+ return matchers;
91
+ };
92
+
93
+ getJasmineRequireObj().base = function(j$) {
94
+ j$.unimplementedMethod_ = function() {
95
+ throw new Error("unimplemented method");
96
+ };
97
+
98
+ j$.MAX_PRETTY_PRINT_DEPTH = 40;
99
+ j$.DEFAULT_TIMEOUT_INTERVAL = 5000;
100
+
101
+ j$.getGlobal = (function() {
102
+ var jasmineGlobal = eval.call(null, "this");
103
+ return function() {
104
+ return jasmineGlobal;
105
+ };
106
+ })();
107
+
108
+ j$.getEnv = function(options) {
109
+ var env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options);
110
+ //jasmine. singletons in here (setTimeout blah blah).
111
+ return env;
112
+ };
113
+
114
+ j$.isArray_ = function(value) {
115
+ return j$.isA_("Array", value);
116
+ };
117
+
118
+ j$.isString_ = function(value) {
119
+ return j$.isA_("String", value);
120
+ };
121
+
122
+ j$.isNumber_ = function(value) {
123
+ return j$.isA_("Number", value);
124
+ };
125
+
126
+ j$.isA_ = function(typeName, value) {
127
+ return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
128
+ };
129
+
130
+ j$.isDomNode = function(obj) {
131
+ return obj.nodeType > 0;
132
+ };
133
+
134
+ j$.any = function(clazz) {
135
+ return new j$.Any(clazz);
136
+ };
137
+
138
+ j$.objectContaining = function(sample) {
139
+ return new j$.ObjectContaining(sample);
140
+ };
141
+
142
+ j$.createSpy = function(name, originalFn) {
143
+
144
+ var spyStrategy = new j$.SpyStrategy({
145
+ name: name,
146
+ fn: originalFn,
147
+ getSpy: function() { return spy; }
148
+ }),
149
+ callTracker = new j$.CallTracker(),
150
+ spy = function() {
151
+ callTracker.track({
152
+ object: this,
153
+ args: Array.prototype.slice.apply(arguments)
154
+ });
155
+ return spyStrategy.exec.apply(this, arguments);
156
+ };
157
+
158
+ for (var prop in originalFn) {
159
+ if (prop === 'and' || prop === 'calls') {
160
+ throw new Error("Jasmine spies would overwrite the 'and' and 'calls' properties on the object being spied upon");
161
+ }
162
+
163
+ spy[prop] = originalFn[prop];
164
+ }
165
+
166
+ spy.and = spyStrategy;
167
+ spy.calls = callTracker;
168
+
169
+ return spy;
170
+ };
171
+
172
+ j$.isSpy = function(putativeSpy) {
173
+ if (!putativeSpy) {
174
+ return false;
175
+ }
176
+ return putativeSpy.and instanceof j$.SpyStrategy &&
177
+ putativeSpy.calls instanceof j$.CallTracker;
178
+ };
179
+
180
+ j$.createSpyObj = function(baseName, methodNames) {
181
+ if (!j$.isArray_(methodNames) || methodNames.length === 0) {
182
+ throw "createSpyObj requires a non-empty array of method names to create spies for";
183
+ }
184
+ var obj = {};
185
+ for (var i = 0; i < methodNames.length; i++) {
186
+ obj[methodNames[i]] = j$.createSpy(baseName + '.' + methodNames[i]);
187
+ }
188
+ return obj;
189
+ };
190
+ };
191
+
192
+ getJasmineRequireObj().util = function() {
193
+
194
+ var util = {};
195
+
196
+ util.inherit = function(childClass, parentClass) {
197
+ var Subclass = function() {
198
+ };
199
+ Subclass.prototype = parentClass.prototype;
200
+ childClass.prototype = new Subclass();
201
+ };
202
+
203
+ util.htmlEscape = function(str) {
204
+ if (!str) {
205
+ return str;
206
+ }
207
+ return str.replace(/&/g, '&amp;')
208
+ .replace(/</g, '&lt;')
209
+ .replace(/>/g, '&gt;');
210
+ };
211
+
212
+ util.argsToArray = function(args) {
213
+ var arrayOfArgs = [];
214
+ for (var i = 0; i < args.length; i++) {
215
+ arrayOfArgs.push(args[i]);
216
+ }
217
+ return arrayOfArgs;
218
+ };
219
+
220
+ util.isUndefined = function(obj) {
221
+ return obj === void 0;
222
+ };
223
+
224
+ return util;
225
+ };
226
+
227
+ getJasmineRequireObj().Spec = function(j$) {
228
+ function Spec(attrs) {
229
+ this.expectationFactory = attrs.expectationFactory;
230
+ this.resultCallback = attrs.resultCallback || function() {};
231
+ this.id = attrs.id;
232
+ this.description = attrs.description || '';
233
+ this.fn = attrs.fn;
234
+ this.beforeFns = attrs.beforeFns || function() { return []; };
235
+ this.afterFns = attrs.afterFns || function() { return []; };
236
+ this.onStart = attrs.onStart || function() {};
237
+ this.exceptionFormatter = attrs.exceptionFormatter || function() {};
238
+ this.getSpecName = attrs.getSpecName || function() { return ''; };
239
+ this.expectationResultFactory = attrs.expectationResultFactory || function() { };
240
+ this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
241
+ this.catchingExceptions = attrs.catchingExceptions || function() { return true; };
242
+
243
+ this.timer = attrs.timer || {setTimeout: setTimeout, clearTimeout: clearTimeout};
244
+
245
+ if (!this.fn) {
246
+ this.pend();
247
+ }
248
+
249
+ this.result = {
250
+ id: this.id,
251
+ description: this.description,
252
+ fullName: this.getFullName(),
253
+ failedExpectations: []
254
+ };
255
+ }
256
+
257
+ Spec.prototype.addExpectationResult = function(passed, data) {
258
+ if (passed) {
259
+ return;
260
+ }
261
+ this.result.failedExpectations.push(this.expectationResultFactory(data));
262
+ };
263
+
264
+ Spec.prototype.expect = function(actual) {
265
+ return this.expectationFactory(actual, this);
266
+ };
267
+
268
+ Spec.prototype.execute = function(onComplete) {
269
+ var self = this,
270
+ timeout;
271
+
272
+ this.onStart(this);
273
+
274
+ if (this.markedPending || this.disabled) {
275
+ complete();
276
+ return;
277
+ }
278
+
279
+ function timeoutable(fn) {
280
+ return function(done) {
281
+ timeout = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() {
282
+ onException(new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.'));
283
+ done();
284
+ }, j$.DEFAULT_TIMEOUT_INTERVAL]]);
285
+
286
+ var callDone = function() {
287
+ clearTimeoutable();
288
+ done();
289
+ };
290
+
291
+ fn.call(this, callDone); //TODO: do we care about more than 1 arg?
292
+ };
293
+ }
294
+
295
+ function clearTimeoutable() {
296
+ Function.prototype.apply.apply(self.timer.clearTimeout, [j$.getGlobal(), [timeout]]);
297
+ timeout = void 0;
298
+ }
299
+
300
+ var allFns = this.beforeFns().concat(this.fn).concat(this.afterFns()),
301
+ allTimeoutableFns = [];
302
+ for (var i = 0; i < allFns.length; i++) {
303
+ var fn = allFns[i];
304
+ allTimeoutableFns.push(fn.length > 0 ? timeoutable(fn) : fn);
305
+ }
306
+
307
+ this.queueRunnerFactory({
308
+ fns: allTimeoutableFns,
309
+ onException: onException,
310
+ onComplete: complete
311
+ });
312
+
313
+ function onException(e) {
314
+ clearTimeoutable();
315
+ if (Spec.isPendingSpecException(e)) {
316
+ self.pend();
317
+ return;
318
+ }
319
+
320
+ self.addExpectationResult(false, {
321
+ matcherName: "",
322
+ passed: false,
323
+ expected: "",
324
+ actual: "",
325
+ error: e
326
+ });
327
+ }
328
+
329
+ function complete() {
330
+ self.result.status = self.status();
331
+ self.resultCallback(self.result);
332
+
333
+ if (onComplete) {
334
+ onComplete();
335
+ }
336
+ }
337
+ };
338
+
339
+ Spec.prototype.disable = function() {
340
+ this.disabled = true;
341
+ };
342
+
343
+ Spec.prototype.pend = function() {
344
+ this.markedPending = true;
345
+ };
346
+
347
+ Spec.prototype.status = function() {
348
+ if (this.disabled) {
349
+ return 'disabled';
350
+ }
351
+
352
+ if (this.markedPending) {
353
+ return 'pending';
354
+ }
355
+
356
+ if (this.result.failedExpectations.length > 0) {
357
+ return 'failed';
358
+ } else {
359
+ return 'passed';
360
+ }
361
+ };
362
+
363
+ Spec.prototype.getFullName = function() {
364
+ return this.getSpecName(this);
365
+ };
366
+
367
+ Spec.pendingSpecExceptionMessage = "=> marked Pending";
368
+
369
+ Spec.isPendingSpecException = function(e) {
370
+ return e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1;
371
+ };
372
+
373
+ return Spec;
374
+ };
375
+
376
+ if (typeof window == void 0 && typeof exports == "object") {
377
+ exports.Spec = jasmineRequire.Spec;
378
+ }
379
+
380
+ getJasmineRequireObj().Env = function(j$) {
381
+ function Env(options) {
382
+ options = options || {};
383
+
384
+ var self = this;
385
+ var global = options.global || j$.getGlobal();
386
+
387
+ var totalSpecsDefined = 0;
388
+
389
+ var catchExceptions = true;
390
+
391
+ var realSetTimeout = j$.getGlobal().setTimeout;
392
+ var realClearTimeout = j$.getGlobal().clearTimeout;
393
+ this.clock = new j$.Clock(global, new j$.DelayedFunctionScheduler());
394
+
395
+ var runnableLookupTable = {};
396
+
397
+ var spies = [];
398
+
399
+ var currentSpec = null;
400
+ var currentSuite = null;
401
+
402
+ var reporter = new j$.ReportDispatcher([
403
+ "jasmineStarted",
404
+ "jasmineDone",
405
+ "suiteStarted",
406
+ "suiteDone",
407
+ "specStarted",
408
+ "specDone"
409
+ ]);
410
+
411
+ this.specFilter = function() {
412
+ return true;
413
+ };
414
+
415
+ var equalityTesters = [];
416
+
417
+ var customEqualityTesters = [];
418
+ this.addCustomEqualityTester = function(tester) {
419
+ customEqualityTesters.push(tester);
420
+ };
421
+
422
+ j$.Expectation.addCoreMatchers(j$.matchers);
423
+
424
+ var nextSpecId = 0;
425
+ var getNextSpecId = function() {
426
+ return 'spec' + nextSpecId++;
427
+ };
428
+
429
+ var nextSuiteId = 0;
430
+ var getNextSuiteId = function() {
431
+ return 'suite' + nextSuiteId++;
432
+ };
433
+
434
+ var expectationFactory = function(actual, spec) {
435
+ return j$.Expectation.Factory({
436
+ util: j$.matchersUtil,
437
+ customEqualityTesters: customEqualityTesters,
438
+ actual: actual,
439
+ addExpectationResult: addExpectationResult
440
+ });
441
+
442
+ function addExpectationResult(passed, result) {
443
+ return spec.addExpectationResult(passed, result);
444
+ }
445
+ };
446
+
447
+ var specStarted = function(spec) {
448
+ currentSpec = spec;
449
+ reporter.specStarted(spec.result);
450
+ };
451
+
452
+ var beforeFns = function(suite) {
453
+ return function() {
454
+ var befores = [];
455
+ while(suite) {
456
+ befores = befores.concat(suite.beforeFns);
457
+ suite = suite.parentSuite;
458
+ }
459
+ return befores.reverse();
460
+ };
461
+ };
462
+
463
+ var afterFns = function(suite) {
464
+ return function() {
465
+ var afters = [];
466
+ while(suite) {
467
+ afters = afters.concat(suite.afterFns);
468
+ suite = suite.parentSuite;
469
+ }
470
+ return afters;
471
+ };
472
+ };
473
+
474
+ var getSpecName = function(spec, suite) {
475
+ return suite.getFullName() + ' ' + spec.description;
476
+ };
477
+
478
+ // TODO: we may just be able to pass in the fn instead of wrapping here
479
+ var buildExpectationResult = j$.buildExpectationResult,
480
+ exceptionFormatter = new j$.ExceptionFormatter(),
481
+ expectationResultFactory = function(attrs) {
482
+ attrs.messageFormatter = exceptionFormatter.message;
483
+ attrs.stackFormatter = exceptionFormatter.stack;
484
+
485
+ return buildExpectationResult(attrs);
486
+ };
487
+
488
+ // TODO: fix this naming, and here's where the value comes in
489
+ this.catchExceptions = function(value) {
490
+ catchExceptions = !!value;
491
+ return catchExceptions;
492
+ };
493
+
494
+ this.catchingExceptions = function() {
495
+ return catchExceptions;
496
+ };
497
+
498
+ var maximumSpecCallbackDepth = 20;
499
+ var currentSpecCallbackDepth = 0;
500
+
501
+ function clearStack(fn) {
502
+ currentSpecCallbackDepth++;
503
+ if (currentSpecCallbackDepth >= maximumSpecCallbackDepth) {
504
+ currentSpecCallbackDepth = 0;
505
+ realSetTimeout(fn, 0);
506
+ } else {
507
+ fn();
508
+ }
509
+ }
510
+
511
+ var catchException = function(e) {
512
+ return j$.Spec.isPendingSpecException(e) || catchExceptions;
513
+ };
514
+
515
+ var queueRunnerFactory = function(options) {
516
+ options.catchException = catchException;
517
+ options.clearStack = options.clearStack || clearStack;
518
+
519
+ new j$.QueueRunner(options).execute();
520
+ };
521
+
522
+ var topSuite = new j$.Suite({
523
+ env: this,
524
+ id: getNextSuiteId(),
525
+ description: 'Jasmine__TopLevel__Suite',
526
+ queueRunner: queueRunnerFactory,
527
+ resultCallback: function() {} // TODO - hook this up
528
+ });
529
+ runnableLookupTable[topSuite.id] = topSuite;
530
+ currentSuite = topSuite;
531
+
532
+ this.topSuite = function() {
533
+ return topSuite;
534
+ };
535
+
536
+ this.execute = function(runnablesToRun) {
537
+ runnablesToRun = runnablesToRun || [topSuite.id];
538
+
539
+ var allFns = [];
540
+ for(var i = 0; i < runnablesToRun.length; i++) {
541
+ var runnable = runnableLookupTable[runnablesToRun[i]];
542
+ allFns.push((function(runnable) { return function(done) { runnable.execute(done); }; })(runnable));
543
+ }
544
+
545
+ reporter.jasmineStarted({
546
+ totalSpecsDefined: totalSpecsDefined
547
+ });
548
+
549
+ queueRunnerFactory({fns: allFns, onComplete: reporter.jasmineDone});
550
+ };
551
+
552
+ this.addReporter = function(reporterToAdd) {
553
+ reporter.addReporter(reporterToAdd);
554
+ };
555
+
556
+ this.addMatchers = function(matchersToAdd) {
557
+ j$.Expectation.addMatchers(matchersToAdd);
558
+ };
559
+
560
+ this.spyOn = function(obj, methodName) {
561
+ if (j$.util.isUndefined(obj)) {
562
+ throw new Error("spyOn could not find an object to spy upon for " + methodName + "()");
563
+ }
564
+
565
+ if (j$.util.isUndefined(obj[methodName])) {
566
+ throw new Error(methodName + '() method does not exist');
567
+ }
568
+
569
+ if (obj[methodName] && j$.isSpy(obj[methodName])) {
570
+ //TODO?: should this return the current spy? Downside: may cause user confusion about spy state
571
+ throw new Error(methodName + ' has already been spied upon');
572
+ }
573
+
574
+ var spy = j$.createSpy(methodName, obj[methodName]);
575
+
576
+ spies.push({
577
+ spy: spy,
578
+ baseObj: obj,
579
+ methodName: methodName,
580
+ originalValue: obj[methodName]
581
+ });
582
+
583
+ obj[methodName] = spy;
584
+
585
+ return spy;
586
+ };
587
+
588
+ var suiteFactory = function(description) {
589
+ var suite = new j$.Suite({
590
+ env: self,
591
+ id: getNextSuiteId(),
592
+ description: description,
593
+ parentSuite: currentSuite,
594
+ queueRunner: queueRunnerFactory,
595
+ onStart: suiteStarted,
596
+ resultCallback: function(attrs) {
597
+ reporter.suiteDone(attrs);
598
+ }
599
+ });
600
+
601
+ runnableLookupTable[suite.id] = suite;
602
+ return suite;
603
+ };
604
+
605
+ this.describe = function(description, specDefinitions) {
606
+ var suite = suiteFactory(description);
607
+
608
+ var parentSuite = currentSuite;
609
+ parentSuite.addChild(suite);
610
+ currentSuite = suite;
611
+
612
+ var declarationError = null;
613
+ try {
614
+ specDefinitions.call(suite);
615
+ } catch (e) {
616
+ declarationError = e;
617
+ }
618
+
619
+ if (declarationError) {
620
+ this.it("encountered a declaration exception", function() {
621
+ throw declarationError;
622
+ });
623
+ }
624
+
625
+ currentSuite = parentSuite;
626
+
627
+ return suite;
628
+ };
629
+
630
+ this.xdescribe = function(description, specDefinitions) {
631
+ var suite = this.describe(description, specDefinitions);
632
+ suite.disable();
633
+ return suite;
634
+ };
635
+
636
+ var specFactory = function(description, fn, suite) {
637
+ totalSpecsDefined++;
638
+
639
+ var spec = new j$.Spec({
640
+ id: getNextSpecId(),
641
+ beforeFns: beforeFns(suite),
642
+ afterFns: afterFns(suite),
643
+ expectationFactory: expectationFactory,
644
+ exceptionFormatter: exceptionFormatter,
645
+ resultCallback: specResultCallback,
646
+ getSpecName: function(spec) {
647
+ return getSpecName(spec, suite);
648
+ },
649
+ onStart: specStarted,
650
+ description: description,
651
+ expectationResultFactory: expectationResultFactory,
652
+ queueRunnerFactory: queueRunnerFactory,
653
+ fn: fn,
654
+ timer: {setTimeout: realSetTimeout, clearTimeout: realClearTimeout}
655
+ });
656
+
657
+ runnableLookupTable[spec.id] = spec;
658
+
659
+ if (!self.specFilter(spec)) {
660
+ spec.disable();
661
+ }
662
+
663
+ return spec;
664
+
665
+ function removeAllSpies() {
666
+ for (var i = 0; i < spies.length; i++) {
667
+ var spyEntry = spies[i];
668
+ spyEntry.baseObj[spyEntry.methodName] = spyEntry.originalValue;
669
+ }
670
+ spies = [];
671
+ }
672
+
673
+ function specResultCallback(result) {
674
+ removeAllSpies();
675
+ j$.Expectation.resetMatchers();
676
+ customEqualityTesters = [];
677
+ currentSpec = null;
678
+ reporter.specDone(result);
679
+ }
680
+ };
681
+
682
+ var suiteStarted = function(suite) {
683
+ reporter.suiteStarted(suite.result);
684
+ };
685
+
686
+ this.it = function(description, fn) {
687
+ var spec = specFactory(description, fn, currentSuite);
688
+ currentSuite.addChild(spec);
689
+ return spec;
690
+ };
691
+
692
+ this.xit = function(description, fn) {
693
+ var spec = this.it(description, fn);
694
+ spec.pend();
695
+ return spec;
696
+ };
697
+
698
+ this.expect = function(actual) {
699
+ return currentSpec.expect(actual);
700
+ };
701
+
702
+ this.beforeEach = function(beforeEachFunction) {
703
+ currentSuite.beforeEach(beforeEachFunction);
704
+ };
705
+
706
+ this.afterEach = function(afterEachFunction) {
707
+ currentSuite.afterEach(afterEachFunction);
708
+ };
709
+
710
+ this.pending = function() {
711
+ throw j$.Spec.pendingSpecExceptionMessage;
712
+ };
713
+ }
714
+
715
+ return Env;
716
+ };
717
+
718
+ getJasmineRequireObj().JsApiReporter = function() {
719
+
720
+ var noopTimer = {
721
+ start: function(){},
722
+ elapsed: function(){ return 0; }
723
+ };
724
+
725
+ function JsApiReporter(options) {
726
+ var timer = options.timer || noopTimer,
727
+ status = "loaded";
728
+
729
+ this.started = false;
730
+ this.finished = false;
731
+
732
+ this.jasmineStarted = function() {
733
+ this.started = true;
734
+ status = 'started';
735
+ timer.start();
736
+ };
737
+
738
+ var executionTime;
739
+
740
+ this.jasmineDone = function() {
741
+ this.finished = true;
742
+ executionTime = timer.elapsed();
743
+ status = 'done';
744
+ };
745
+
746
+ this.status = function() {
747
+ return status;
748
+ };
749
+
750
+ var suites = {};
751
+
752
+ this.suiteStarted = function(result) {
753
+ storeSuite(result);
754
+ };
755
+
756
+ this.suiteDone = function(result) {
757
+ storeSuite(result);
758
+ };
759
+
760
+ function storeSuite(result) {
761
+ suites[result.id] = result;
762
+ }
763
+
764
+ this.suites = function() {
765
+ return suites;
766
+ };
767
+
768
+ var specs = [];
769
+ this.specStarted = function(result) { };
770
+
771
+ this.specDone = function(result) {
772
+ specs.push(result);
773
+ };
774
+
775
+ this.specResults = function(index, length) {
776
+ return specs.slice(index, index + length);
777
+ };
778
+
779
+ this.specs = function() {
780
+ return specs;
781
+ };
782
+
783
+ this.executionTime = function() {
784
+ return executionTime;
785
+ };
786
+
787
+ }
788
+
789
+ return JsApiReporter;
790
+ };
791
+
792
+ getJasmineRequireObj().Any = function() {
793
+
794
+ function Any(expectedObject) {
795
+ this.expectedObject = expectedObject;
796
+ }
797
+
798
+ Any.prototype.jasmineMatches = function(other) {
799
+ if (this.expectedObject == String) {
800
+ return typeof other == 'string' || other instanceof String;
801
+ }
802
+
803
+ if (this.expectedObject == Number) {
804
+ return typeof other == 'number' || other instanceof Number;
805
+ }
806
+
807
+ if (this.expectedObject == Function) {
808
+ return typeof other == 'function' || other instanceof Function;
809
+ }
810
+
811
+ if (this.expectedObject == Object) {
812
+ return typeof other == 'object';
813
+ }
814
+
815
+ if (this.expectedObject == Boolean) {
816
+ return typeof other == 'boolean';
817
+ }
818
+
819
+ return other instanceof this.expectedObject;
820
+ };
821
+
822
+ Any.prototype.jasmineToString = function() {
823
+ return '<jasmine.any(' + this.expectedClass + ')>';
824
+ };
825
+
826
+ return Any;
827
+ };
828
+
829
+ getJasmineRequireObj().CallTracker = function() {
830
+
831
+ function CallTracker() {
832
+ var calls = [];
833
+
834
+ this.track = function(context) {
835
+ calls.push(context);
836
+ };
837
+
838
+ this.any = function() {
839
+ return !!calls.length;
840
+ };
841
+
842
+ this.count = function() {
843
+ return calls.length;
844
+ };
845
+
846
+ this.argsFor = function(index) {
847
+ var call = calls[index];
848
+ return call ? call.args : [];
849
+ };
850
+
851
+ this.all = function() {
852
+ return calls;
853
+ };
854
+
855
+ this.allArgs = function() {
856
+ var callArgs = [];
857
+ for(var i = 0; i < calls.length; i++){
858
+ callArgs.push(calls[i].args);
859
+ }
860
+
861
+ return callArgs;
862
+ };
863
+
864
+ this.first = function() {
865
+ return calls[0];
866
+ };
867
+
868
+ this.mostRecent = function() {
869
+ return calls[calls.length - 1];
870
+ };
871
+
872
+ this.reset = function() {
873
+ calls = [];
874
+ };
875
+ }
876
+
877
+ return CallTracker;
878
+ };
879
+
880
+ getJasmineRequireObj().Clock = function() {
881
+ function Clock(global, delayedFunctionScheduler) {
882
+ var self = this,
883
+ realTimingFunctions = {
884
+ setTimeout: global.setTimeout,
885
+ clearTimeout: global.clearTimeout,
886
+ setInterval: global.setInterval,
887
+ clearInterval: global.clearInterval
888
+ },
889
+ fakeTimingFunctions = {
890
+ setTimeout: setTimeout,
891
+ clearTimeout: clearTimeout,
892
+ setInterval: setInterval,
893
+ clearInterval: clearInterval
894
+ },
895
+ installed = false,
896
+ timer;
897
+
898
+ self.install = function() {
899
+ replace(global, fakeTimingFunctions);
900
+ timer = fakeTimingFunctions;
901
+ installed = true;
902
+ };
903
+
904
+ self.uninstall = function() {
905
+ delayedFunctionScheduler.reset();
906
+ replace(global, realTimingFunctions);
907
+ timer = realTimingFunctions;
908
+ installed = false;
909
+ };
910
+
911
+ self.setTimeout = function(fn, delay, params) {
912
+ if (legacyIE()) {
913
+ if (arguments.length > 2) {
914
+ throw new Error("IE < 9 cannot support extra params to setTimeout without a polyfill");
915
+ }
916
+ return timer.setTimeout(fn, delay);
917
+ }
918
+ return Function.prototype.apply.apply(timer.setTimeout, [global, arguments]);
919
+ };
920
+
921
+ self.setInterval = function(fn, delay, params) {
922
+ if (legacyIE()) {
923
+ if (arguments.length > 2) {
924
+ throw new Error("IE < 9 cannot support extra params to setInterval without a polyfill");
925
+ }
926
+ return timer.setInterval(fn, delay);
927
+ }
928
+ return Function.prototype.apply.apply(timer.setInterval, [global, arguments]);
929
+ };
930
+
931
+ self.clearTimeout = function(id) {
932
+ return Function.prototype.call.apply(timer.clearTimeout, [global, id]);
933
+ };
934
+
935
+ self.clearInterval = function(id) {
936
+ return Function.prototype.call.apply(timer.clearInterval, [global, id]);
937
+ };
938
+
939
+ self.tick = function(millis) {
940
+ if (installed) {
941
+ delayedFunctionScheduler.tick(millis);
942
+ } else {
943
+ throw new Error("Mock clock is not installed, use jasmine.clock().install()");
944
+ }
945
+ };
946
+
947
+ return self;
948
+
949
+ function legacyIE() {
950
+ //if these methods are polyfilled, apply will be present
951
+ return !(realTimingFunctions.setTimeout || realTimingFunctions.setInterval).apply;
952
+ }
953
+
954
+ function replace(dest, source) {
955
+ for (var prop in source) {
956
+ dest[prop] = source[prop];
957
+ }
958
+ }
959
+
960
+ function setTimeout(fn, delay) {
961
+ return delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2));
962
+ }
963
+
964
+ function clearTimeout(id) {
965
+ return delayedFunctionScheduler.removeFunctionWithId(id);
966
+ }
967
+
968
+ function setInterval(fn, interval) {
969
+ return delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true);
970
+ }
971
+
972
+ function clearInterval(id) {
973
+ return delayedFunctionScheduler.removeFunctionWithId(id);
974
+ }
975
+
976
+ function argSlice(argsObj, n) {
977
+ return Array.prototype.slice.call(argsObj, 2);
978
+ }
979
+ }
980
+
981
+ return Clock;
982
+ };
983
+
984
+ getJasmineRequireObj().DelayedFunctionScheduler = function() {
985
+ function DelayedFunctionScheduler() {
986
+ var self = this;
987
+ var scheduledLookup = [];
988
+ var scheduledFunctions = {};
989
+ var currentTime = 0;
990
+ var delayedFnCount = 0;
991
+
992
+ self.tick = function(millis) {
993
+ millis = millis || 0;
994
+ var endTime = currentTime + millis;
995
+
996
+ runScheduledFunctions(endTime);
997
+ currentTime = endTime;
998
+ };
999
+
1000
+ self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) {
1001
+ var f;
1002
+ if (typeof(funcToCall) === 'string') {
1003
+ /* jshint evil: true */
1004
+ f = function() { return eval(funcToCall); };
1005
+ /* jshint evil: false */
1006
+ } else {
1007
+ f = funcToCall;
1008
+ }
1009
+
1010
+ millis = millis || 0;
1011
+ timeoutKey = timeoutKey || ++delayedFnCount;
1012
+ runAtMillis = runAtMillis || (currentTime + millis);
1013
+
1014
+ var funcToSchedule = {
1015
+ runAtMillis: runAtMillis,
1016
+ funcToCall: f,
1017
+ recurring: recurring,
1018
+ params: params,
1019
+ timeoutKey: timeoutKey,
1020
+ millis: millis
1021
+ };
1022
+
1023
+ if (runAtMillis in scheduledFunctions) {
1024
+ scheduledFunctions[runAtMillis].push(funcToSchedule);
1025
+ } else {
1026
+ scheduledFunctions[runAtMillis] = [funcToSchedule];
1027
+ scheduledLookup.push(runAtMillis);
1028
+ scheduledLookup.sort(function (a, b) {
1029
+ return a - b;
1030
+ });
1031
+ }
1032
+
1033
+ return timeoutKey;
1034
+ };
1035
+
1036
+ self.removeFunctionWithId = function(timeoutKey) {
1037
+ for (var runAtMillis in scheduledFunctions) {
1038
+ var funcs = scheduledFunctions[runAtMillis];
1039
+ var i = indexOfFirstToPass(funcs, function (func) {
1040
+ return func.timeoutKey === timeoutKey;
1041
+ });
1042
+
1043
+ if (i > -1) {
1044
+ if (funcs.length === 1) {
1045
+ delete scheduledFunctions[runAtMillis];
1046
+ deleteFromLookup(runAtMillis);
1047
+ } else {
1048
+ funcs.splice(i, 1);
1049
+ }
1050
+
1051
+ // intervals get rescheduled when executed, so there's never more
1052
+ // than a single scheduled function with a given timeoutKey
1053
+ break;
1054
+ }
1055
+ }
1056
+ };
1057
+
1058
+ self.reset = function() {
1059
+ currentTime = 0;
1060
+ scheduledLookup = [];
1061
+ scheduledFunctions = {};
1062
+ delayedFnCount = 0;
1063
+ };
1064
+
1065
+ return self;
1066
+
1067
+ function indexOfFirstToPass(array, testFn) {
1068
+ var index = -1;
1069
+
1070
+ for (var i = 0; i < array.length; ++i) {
1071
+ if (testFn(array[i])) {
1072
+ index = i;
1073
+ break;
1074
+ }
1075
+ }
1076
+
1077
+ return index;
1078
+ }
1079
+
1080
+ function deleteFromLookup(key) {
1081
+ var value = Number(key);
1082
+ var i = indexOfFirstToPass(scheduledLookup, function (millis) {
1083
+ return millis === value;
1084
+ });
1085
+
1086
+ if (i > -1) {
1087
+ scheduledLookup.splice(i, 1);
1088
+ }
1089
+ }
1090
+
1091
+ function reschedule(scheduledFn) {
1092
+ self.scheduleFunction(scheduledFn.funcToCall,
1093
+ scheduledFn.millis,
1094
+ scheduledFn.params,
1095
+ true,
1096
+ scheduledFn.timeoutKey,
1097
+ scheduledFn.runAtMillis + scheduledFn.millis);
1098
+ }
1099
+
1100
+ function runScheduledFunctions(endTime) {
1101
+ if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
1102
+ return;
1103
+ }
1104
+
1105
+ do {
1106
+ currentTime = scheduledLookup.shift();
1107
+
1108
+ var funcsToRun = scheduledFunctions[currentTime];
1109
+ delete scheduledFunctions[currentTime];
1110
+
1111
+ for (var i = 0; i < funcsToRun.length; ++i) {
1112
+ var funcToRun = funcsToRun[i];
1113
+ funcToRun.funcToCall.apply(null, funcToRun.params || []);
1114
+
1115
+ if (funcToRun.recurring) {
1116
+ reschedule(funcToRun);
1117
+ }
1118
+ }
1119
+ } while (scheduledLookup.length > 0 &&
1120
+ // checking first if we're out of time prevents setTimeout(0)
1121
+ // scheduled in a funcToRun from forcing an extra iteration
1122
+ currentTime !== endTime &&
1123
+ scheduledLookup[0] <= endTime);
1124
+ }
1125
+ }
1126
+
1127
+ return DelayedFunctionScheduler;
1128
+ };
1129
+
1130
+ getJasmineRequireObj().ExceptionFormatter = function() {
1131
+ function ExceptionFormatter() {
1132
+ this.message = function(error) {
1133
+ var message = error.name +
1134
+ ': ' +
1135
+ error.message;
1136
+
1137
+ if (error.fileName || error.sourceURL) {
1138
+ message += " in " + (error.fileName || error.sourceURL);
1139
+ }
1140
+
1141
+ if (error.line || error.lineNumber) {
1142
+ message += " (line " + (error.line || error.lineNumber) + ")";
1143
+ }
1144
+
1145
+ return message;
1146
+ };
1147
+
1148
+ this.stack = function(error) {
1149
+ return error ? error.stack : null;
1150
+ };
1151
+ }
1152
+
1153
+ return ExceptionFormatter;
1154
+ };
1155
+
1156
+ getJasmineRequireObj().Expectation = function() {
1157
+
1158
+ var matchers = {};
1159
+
1160
+ function Expectation(options) {
1161
+ this.util = options.util || { buildFailureMessage: function() {} };
1162
+ this.customEqualityTesters = options.customEqualityTesters || [];
1163
+ this.actual = options.actual;
1164
+ this.addExpectationResult = options.addExpectationResult || function(){};
1165
+ this.isNot = options.isNot;
1166
+
1167
+ for (var matcherName in matchers) {
1168
+ this[matcherName] = matchers[matcherName];
1169
+ }
1170
+ }
1171
+
1172
+ Expectation.prototype.wrapCompare = function(name, matcherFactory) {
1173
+ return function() {
1174
+ var args = Array.prototype.slice.call(arguments, 0),
1175
+ expected = args.slice(0),
1176
+ message = "";
1177
+
1178
+ args.unshift(this.actual);
1179
+
1180
+ var matcher = matcherFactory(this.util, this.customEqualityTesters),
1181
+ matcherCompare = matcher.compare;
1182
+
1183
+ function defaultNegativeCompare() {
1184
+ var result = matcher.compare.apply(null, args);
1185
+ result.pass = !result.pass;
1186
+ return result;
1187
+ }
1188
+
1189
+ if (this.isNot) {
1190
+ matcherCompare = matcher.negativeCompare || defaultNegativeCompare;
1191
+ }
1192
+
1193
+ var result = matcherCompare.apply(null, args);
1194
+
1195
+ if (!result.pass) {
1196
+ if (!result.message) {
1197
+ args.unshift(this.isNot);
1198
+ args.unshift(name);
1199
+ message = this.util.buildFailureMessage.apply(null, args);
1200
+ } else {
1201
+ message = result.message;
1202
+ }
1203
+ }
1204
+
1205
+ if (expected.length == 1) {
1206
+ expected = expected[0];
1207
+ }
1208
+
1209
+ // TODO: how many of these params are needed?
1210
+ this.addExpectationResult(
1211
+ result.pass,
1212
+ {
1213
+ matcherName: name,
1214
+ passed: result.pass,
1215
+ message: message,
1216
+ actual: this.actual,
1217
+ expected: expected // TODO: this may need to be arrayified/sliced
1218
+ }
1219
+ );
1220
+ };
1221
+ };
1222
+
1223
+ Expectation.addCoreMatchers = function(matchers) {
1224
+ var prototype = Expectation.prototype;
1225
+ for (var matcherName in matchers) {
1226
+ var matcher = matchers[matcherName];
1227
+ prototype[matcherName] = prototype.wrapCompare(matcherName, matcher);
1228
+ }
1229
+ };
1230
+
1231
+ Expectation.addMatchers = function(matchersToAdd) {
1232
+ for (var name in matchersToAdd) {
1233
+ var matcher = matchersToAdd[name];
1234
+ matchers[name] = Expectation.prototype.wrapCompare(name, matcher);
1235
+ }
1236
+ };
1237
+
1238
+ Expectation.resetMatchers = function() {
1239
+ for (var name in matchers) {
1240
+ delete matchers[name];
1241
+ }
1242
+ };
1243
+
1244
+ Expectation.Factory = function(options) {
1245
+ options = options || {};
1246
+
1247
+ var expect = new Expectation(options);
1248
+
1249
+ // TODO: this would be nice as its own Object - NegativeExpectation
1250
+ // TODO: copy instead of mutate options
1251
+ options.isNot = true;
1252
+ expect.not = new Expectation(options);
1253
+
1254
+ return expect;
1255
+ };
1256
+
1257
+ return Expectation;
1258
+ };
1259
+
1260
+ //TODO: expectation result may make more sense as a presentation of an expectation.
1261
+ getJasmineRequireObj().buildExpectationResult = function() {
1262
+ function buildExpectationResult(options) {
1263
+ var messageFormatter = options.messageFormatter || function() {},
1264
+ stackFormatter = options.stackFormatter || function() {};
1265
+
1266
+ return {
1267
+ matcherName: options.matcherName,
1268
+ expected: options.expected,
1269
+ actual: options.actual,
1270
+ message: message(),
1271
+ stack: stack(),
1272
+ passed: options.passed
1273
+ };
1274
+
1275
+ function message() {
1276
+ if (options.passed) {
1277
+ return "Passed.";
1278
+ } else if (options.message) {
1279
+ return options.message;
1280
+ } else if (options.error) {
1281
+ return messageFormatter(options.error);
1282
+ }
1283
+ return "";
1284
+ }
1285
+
1286
+ function stack() {
1287
+ if (options.passed) {
1288
+ return "";
1289
+ }
1290
+
1291
+ var error = options.error;
1292
+ if (!error) {
1293
+ try {
1294
+ throw new Error(message());
1295
+ } catch (e) {
1296
+ error = e;
1297
+ }
1298
+ }
1299
+ return stackFormatter(error);
1300
+ }
1301
+ }
1302
+
1303
+ return buildExpectationResult;
1304
+ };
1305
+
1306
+ getJasmineRequireObj().ObjectContaining = function(j$) {
1307
+
1308
+ function ObjectContaining(sample) {
1309
+ this.sample = sample;
1310
+ }
1311
+
1312
+ ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) {
1313
+ if (typeof(this.sample) !== "object") { throw new Error("You must provide an object to objectContaining, not '"+this.sample+"'."); }
1314
+
1315
+ mismatchKeys = mismatchKeys || [];
1316
+ mismatchValues = mismatchValues || [];
1317
+
1318
+ var hasKey = function(obj, keyName) {
1319
+ return obj !== null && !j$.util.isUndefined(obj[keyName]);
1320
+ };
1321
+
1322
+ for (var property in this.sample) {
1323
+ if (!hasKey(other, property) && hasKey(this.sample, property)) {
1324
+ mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
1325
+ }
1326
+ else if (!j$.matchersUtil.equals(this.sample[property], other[property])) {
1327
+ mismatchValues.push("'" + property + "' was '" + (other[property] ? j$.util.htmlEscape(other[property].toString()) : other[property]) + "' in actual, but was '" + (this.sample[property] ? j$.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in expected.");
1328
+ }
1329
+ }
1330
+
1331
+ return (mismatchKeys.length === 0 && mismatchValues.length === 0);
1332
+ };
1333
+
1334
+ ObjectContaining.prototype.jasmineToString = function() {
1335
+ return "<jasmine.objectContaining(" + j$.pp(this.sample) + ")>";
1336
+ };
1337
+
1338
+ return ObjectContaining;
1339
+ };
1340
+
1341
+ getJasmineRequireObj().pp = function(j$) {
1342
+
1343
+ function PrettyPrinter() {
1344
+ this.ppNestLevel_ = 0;
1345
+ }
1346
+
1347
+ PrettyPrinter.prototype.format = function(value) {
1348
+ this.ppNestLevel_++;
1349
+ try {
1350
+ if (j$.util.isUndefined(value)) {
1351
+ this.emitScalar('undefined');
1352
+ } else if (value === null) {
1353
+ this.emitScalar('null');
1354
+ } else if (value === j$.getGlobal()) {
1355
+ this.emitScalar('<global>');
1356
+ } else if (value.jasmineToString) {
1357
+ this.emitScalar(value.jasmineToString());
1358
+ } else if (typeof value === 'string') {
1359
+ this.emitString(value);
1360
+ } else if (j$.isSpy(value)) {
1361
+ this.emitScalar("spy on " + value.and.identity());
1362
+ } else if (value instanceof RegExp) {
1363
+ this.emitScalar(value.toString());
1364
+ } else if (typeof value === 'function') {
1365
+ this.emitScalar('Function');
1366
+ } else if (typeof value.nodeType === 'number') {
1367
+ this.emitScalar('HTMLNode');
1368
+ } else if (value instanceof Date) {
1369
+ this.emitScalar('Date(' + value + ')');
1370
+ } else if (value.__Jasmine_been_here_before__) {
1371
+ this.emitScalar('<circular reference: ' + (j$.isArray_(value) ? 'Array' : 'Object') + '>');
1372
+ } else if (j$.isArray_(value) || j$.isA_('Object', value)) {
1373
+ value.__Jasmine_been_here_before__ = true;
1374
+ if (j$.isArray_(value)) {
1375
+ this.emitArray(value);
1376
+ } else {
1377
+ this.emitObject(value);
1378
+ }
1379
+ delete value.__Jasmine_been_here_before__;
1380
+ } else {
1381
+ this.emitScalar(value.toString());
1382
+ }
1383
+ } finally {
1384
+ this.ppNestLevel_--;
1385
+ }
1386
+ };
1387
+
1388
+ PrettyPrinter.prototype.iterateObject = function(obj, fn) {
1389
+ for (var property in obj) {
1390
+ if (!obj.hasOwnProperty(property)) { continue; }
1391
+ if (property == '__Jasmine_been_here_before__') { continue; }
1392
+ fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) &&
1393
+ obj.__lookupGetter__(property) !== null) : false);
1394
+ }
1395
+ };
1396
+
1397
+ PrettyPrinter.prototype.emitArray = j$.unimplementedMethod_;
1398
+ PrettyPrinter.prototype.emitObject = j$.unimplementedMethod_;
1399
+ PrettyPrinter.prototype.emitScalar = j$.unimplementedMethod_;
1400
+ PrettyPrinter.prototype.emitString = j$.unimplementedMethod_;
1401
+
1402
+ function StringPrettyPrinter() {
1403
+ PrettyPrinter.call(this);
1404
+
1405
+ this.string = '';
1406
+ }
1407
+
1408
+ j$.util.inherit(StringPrettyPrinter, PrettyPrinter);
1409
+
1410
+ StringPrettyPrinter.prototype.emitScalar = function(value) {
1411
+ this.append(value);
1412
+ };
1413
+
1414
+ StringPrettyPrinter.prototype.emitString = function(value) {
1415
+ this.append("'" + value + "'");
1416
+ };
1417
+
1418
+ StringPrettyPrinter.prototype.emitArray = function(array) {
1419
+ if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) {
1420
+ this.append("Array");
1421
+ return;
1422
+ }
1423
+
1424
+ this.append('[ ');
1425
+ for (var i = 0; i < array.length; i++) {
1426
+ if (i > 0) {
1427
+ this.append(', ');
1428
+ }
1429
+ this.format(array[i]);
1430
+ }
1431
+ this.append(' ]');
1432
+ };
1433
+
1434
+ StringPrettyPrinter.prototype.emitObject = function(obj) {
1435
+ if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) {
1436
+ this.append("Object");
1437
+ return;
1438
+ }
1439
+
1440
+ var self = this;
1441
+ this.append('{ ');
1442
+ var first = true;
1443
+
1444
+ this.iterateObject(obj, function(property, isGetter) {
1445
+ if (first) {
1446
+ first = false;
1447
+ } else {
1448
+ self.append(', ');
1449
+ }
1450
+
1451
+ self.append(property);
1452
+ self.append(' : ');
1453
+ if (isGetter) {
1454
+ self.append('<getter>');
1455
+ } else {
1456
+ self.format(obj[property]);
1457
+ }
1458
+ });
1459
+
1460
+ this.append(' }');
1461
+ };
1462
+
1463
+ StringPrettyPrinter.prototype.append = function(value) {
1464
+ this.string += value;
1465
+ };
1466
+
1467
+ return function(value) {
1468
+ var stringPrettyPrinter = new StringPrettyPrinter();
1469
+ stringPrettyPrinter.format(value);
1470
+ return stringPrettyPrinter.string;
1471
+ };
1472
+ };
1473
+
1474
+ getJasmineRequireObj().QueueRunner = function() {
1475
+
1476
+ function QueueRunner(attrs) {
1477
+ this.fns = attrs.fns || [];
1478
+ this.onComplete = attrs.onComplete || function() {};
1479
+ this.clearStack = attrs.clearStack || function(fn) {fn();};
1480
+ this.onException = attrs.onException || function() {};
1481
+ this.catchException = attrs.catchException || function() { return true; };
1482
+ this.userContext = {};
1483
+ }
1484
+
1485
+ QueueRunner.prototype.execute = function() {
1486
+ this.run(this.fns, 0);
1487
+ };
1488
+
1489
+ QueueRunner.prototype.run = function(fns, recursiveIndex) {
1490
+ var length = fns.length,
1491
+ self = this,
1492
+ iterativeIndex;
1493
+
1494
+ for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) {
1495
+ var fn = fns[iterativeIndex];
1496
+ if (fn.length > 0) {
1497
+ return attemptAsync(fn);
1498
+ } else {
1499
+ attemptSync(fn);
1500
+ }
1501
+ }
1502
+
1503
+ var runnerDone = iterativeIndex >= length;
1504
+
1505
+ if (runnerDone) {
1506
+ this.clearStack(this.onComplete);
1507
+ }
1508
+
1509
+ function attemptSync(fn) {
1510
+ try {
1511
+ fn.call(self.userContext);
1512
+ } catch (e) {
1513
+ handleException(e);
1514
+ }
1515
+ }
1516
+
1517
+ function attemptAsync(fn) {
1518
+ var next = function () { self.run(fns, iterativeIndex + 1); };
1519
+
1520
+ try {
1521
+ fn.call(self.userContext, next);
1522
+ } catch (e) {
1523
+ handleException(e);
1524
+ next();
1525
+ }
1526
+ }
1527
+
1528
+ function handleException(e) {
1529
+ self.onException(e);
1530
+ if (!self.catchException(e)) {
1531
+ //TODO: set a var when we catch an exception and
1532
+ //use a finally block to close the loop in a nice way..
1533
+ throw e;
1534
+ }
1535
+ }
1536
+ };
1537
+
1538
+ return QueueRunner;
1539
+ };
1540
+
1541
+ getJasmineRequireObj().ReportDispatcher = function() {
1542
+ function ReportDispatcher(methods) {
1543
+
1544
+ var dispatchedMethods = methods || [];
1545
+
1546
+ for (var i = 0; i < dispatchedMethods.length; i++) {
1547
+ var method = dispatchedMethods[i];
1548
+ this[method] = (function(m) {
1549
+ return function() {
1550
+ dispatch(m, arguments);
1551
+ };
1552
+ }(method));
1553
+ }
1554
+
1555
+ var reporters = [];
1556
+
1557
+ this.addReporter = function(reporter) {
1558
+ reporters.push(reporter);
1559
+ };
1560
+
1561
+ return this;
1562
+
1563
+ function dispatch(method, args) {
1564
+ for (var i = 0; i < reporters.length; i++) {
1565
+ var reporter = reporters[i];
1566
+ if (reporter[method]) {
1567
+ reporter[method].apply(reporter, args);
1568
+ }
1569
+ }
1570
+ }
1571
+ }
1572
+
1573
+ return ReportDispatcher;
1574
+ };
1575
+
1576
+
1577
+ getJasmineRequireObj().SpyStrategy = function() {
1578
+
1579
+ function SpyStrategy(options) {
1580
+ options = options || {};
1581
+
1582
+ var identity = options.name || "unknown",
1583
+ originalFn = options.fn || function() {},
1584
+ getSpy = options.getSpy || function() {},
1585
+ plan = function() {};
1586
+
1587
+ this.identity = function() {
1588
+ return identity;
1589
+ };
1590
+
1591
+ this.exec = function() {
1592
+ return plan.apply(this, arguments);
1593
+ };
1594
+
1595
+ this.callThrough = function() {
1596
+ plan = originalFn;
1597
+ return getSpy();
1598
+ };
1599
+
1600
+ this.returnValue = function(value) {
1601
+ plan = function() {
1602
+ return value;
1603
+ };
1604
+ return getSpy();
1605
+ };
1606
+
1607
+ this.throwError = function(something) {
1608
+ var error = (something instanceof Error) ? something : new Error(something);
1609
+ plan = function() {
1610
+ throw error;
1611
+ };
1612
+ return getSpy();
1613
+ };
1614
+
1615
+ this.callFake = function(fn) {
1616
+ plan = fn;
1617
+ return getSpy();
1618
+ };
1619
+
1620
+ this.stub = function(fn) {
1621
+ plan = function() {};
1622
+ return getSpy();
1623
+ };
1624
+ }
1625
+
1626
+ return SpyStrategy;
1627
+ };
1628
+
1629
+ getJasmineRequireObj().Suite = function() {
1630
+ function Suite(attrs) {
1631
+ this.env = attrs.env;
1632
+ this.id = attrs.id;
1633
+ this.parentSuite = attrs.parentSuite;
1634
+ this.description = attrs.description;
1635
+ this.onStart = attrs.onStart || function() {};
1636
+ this.resultCallback = attrs.resultCallback || function() {};
1637
+ this.clearStack = attrs.clearStack || function(fn) {fn();};
1638
+
1639
+ this.beforeFns = [];
1640
+ this.afterFns = [];
1641
+ this.queueRunner = attrs.queueRunner || function() {};
1642
+ this.disabled = false;
1643
+
1644
+ this.children = [];
1645
+
1646
+ this.result = {
1647
+ id: this.id,
1648
+ status: this.disabled ? 'disabled' : '',
1649
+ description: this.description,
1650
+ fullName: this.getFullName()
1651
+ };
1652
+ }
1653
+
1654
+ Suite.prototype.getFullName = function() {
1655
+ var fullName = this.description;
1656
+ for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
1657
+ if (parentSuite.parentSuite) {
1658
+ fullName = parentSuite.description + ' ' + fullName;
1659
+ }
1660
+ }
1661
+ return fullName;
1662
+ };
1663
+
1664
+ Suite.prototype.disable = function() {
1665
+ this.disabled = true;
1666
+ };
1667
+
1668
+ Suite.prototype.beforeEach = function(fn) {
1669
+ this.beforeFns.unshift(fn);
1670
+ };
1671
+
1672
+ Suite.prototype.afterEach = function(fn) {
1673
+ this.afterFns.unshift(fn);
1674
+ };
1675
+
1676
+ Suite.prototype.addChild = function(child) {
1677
+ this.children.push(child);
1678
+ };
1679
+
1680
+ Suite.prototype.execute = function(onComplete) {
1681
+ var self = this;
1682
+ if (this.disabled) {
1683
+ complete();
1684
+ return;
1685
+ }
1686
+
1687
+ var allFns = [];
1688
+
1689
+ for (var i = 0; i < this.children.length; i++) {
1690
+ allFns.push(wrapChildAsAsync(this.children[i]));
1691
+ }
1692
+
1693
+ this.onStart(this);
1694
+
1695
+ this.queueRunner({
1696
+ fns: allFns,
1697
+ onComplete: complete
1698
+ });
1699
+
1700
+ function complete() {
1701
+ self.resultCallback(self.result);
1702
+
1703
+ if (onComplete) {
1704
+ onComplete();
1705
+ }
1706
+ }
1707
+
1708
+ function wrapChildAsAsync(child) {
1709
+ return function(done) { child.execute(done); };
1710
+ }
1711
+ };
1712
+
1713
+ return Suite;
1714
+ };
1715
+
1716
+ if (typeof window == void 0 && typeof exports == "object") {
1717
+ exports.Suite = jasmineRequire.Suite;
1718
+ }
1719
+
1720
+ getJasmineRequireObj().Timer = function() {
1721
+ function Timer(options) {
1722
+ options = options || {};
1723
+
1724
+ var now = options.now || function() { return new Date().getTime(); },
1725
+ startTime;
1726
+
1727
+ this.start = function() {
1728
+ startTime = now();
1729
+ };
1730
+
1731
+ this.elapsed = function() {
1732
+ return now() - startTime;
1733
+ };
1734
+ }
1735
+
1736
+ return Timer;
1737
+ };
1738
+
1739
+ getJasmineRequireObj().matchersUtil = function(j$) {
1740
+ // TODO: what to do about jasmine.pp not being inject? move to JSON.stringify? gut PrettyPrinter?
1741
+
1742
+ return {
1743
+ equals: function(a, b, customTesters) {
1744
+ customTesters = customTesters || [];
1745
+
1746
+ return eq(a, b, [], [], customTesters);
1747
+ },
1748
+
1749
+ contains: function(haystack, needle, customTesters) {
1750
+ customTesters = customTesters || [];
1751
+
1752
+ if (Object.prototype.toString.apply(haystack) === "[object Array]") {
1753
+ for (var i = 0; i < haystack.length; i++) {
1754
+ if (eq(haystack[i], needle, [], [], customTesters)) {
1755
+ return true;
1756
+ }
1757
+ }
1758
+ return false;
1759
+ }
1760
+ return haystack.indexOf(needle) >= 0;
1761
+ },
1762
+
1763
+ buildFailureMessage: function() {
1764
+ var args = Array.prototype.slice.call(arguments, 0),
1765
+ matcherName = args[0],
1766
+ isNot = args[1],
1767
+ actual = args[2],
1768
+ expected = args.slice(3),
1769
+ englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
1770
+
1771
+ var message = "Expected " +
1772
+ j$.pp(actual) +
1773
+ (isNot ? " not " : " ") +
1774
+ englishyPredicate;
1775
+
1776
+ if (expected.length > 0) {
1777
+ for (var i = 0; i < expected.length; i++) {
1778
+ if (i > 0) {
1779
+ message += ",";
1780
+ }
1781
+ message += " " + j$.pp(expected[i]);
1782
+ }
1783
+ }
1784
+
1785
+ return message + ".";
1786
+ }
1787
+ };
1788
+
1789
+ // Equality function lovingly adapted from isEqual in
1790
+ // [Underscore](http://underscorejs.org)
1791
+ function eq(a, b, aStack, bStack, customTesters) {
1792
+ var result = true;
1793
+
1794
+ for (var i = 0; i < customTesters.length; i++) {
1795
+ var customTesterResult = customTesters[i](a, b);
1796
+ if (!j$.util.isUndefined(customTesterResult)) {
1797
+ return customTesterResult;
1798
+ }
1799
+ }
1800
+
1801
+ if (a instanceof j$.Any) {
1802
+ result = a.jasmineMatches(b);
1803
+ if (result) {
1804
+ return true;
1805
+ }
1806
+ }
1807
+
1808
+ if (b instanceof j$.Any) {
1809
+ result = b.jasmineMatches(a);
1810
+ if (result) {
1811
+ return true;
1812
+ }
1813
+ }
1814
+
1815
+ if (b instanceof j$.ObjectContaining) {
1816
+ result = b.jasmineMatches(a);
1817
+ if (result) {
1818
+ return true;
1819
+ }
1820
+ }
1821
+
1822
+ if (a instanceof Error && b instanceof Error) {
1823
+ return a.message == b.message;
1824
+ }
1825
+
1826
+ // Identical objects are equal. `0 === -0`, but they aren't identical.
1827
+ // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
1828
+ if (a === b) { return a !== 0 || 1 / a == 1 / b; }
1829
+ // A strict comparison is necessary because `null == undefined`.
1830
+ if (a === null || b === null) { return a === b; }
1831
+ var className = Object.prototype.toString.call(a);
1832
+ if (className != Object.prototype.toString.call(b)) { return false; }
1833
+ switch (className) {
1834
+ // Strings, numbers, dates, and booleans are compared by value.
1835
+ case '[object String]':
1836
+ // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
1837
+ // equivalent to `new String("5")`.
1838
+ return a == String(b);
1839
+ case '[object Number]':
1840
+ // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
1841
+ // other numeric values.
1842
+ return a != +a ? b != +b : (a === 0 ? 1 / a == 1 / b : a == +b);
1843
+ case '[object Date]':
1844
+ case '[object Boolean]':
1845
+ // Coerce dates and booleans to numeric primitive values. Dates are compared by their
1846
+ // millisecond representations. Note that invalid dates with millisecond representations
1847
+ // of `NaN` are not equivalent.
1848
+ return +a == +b;
1849
+ // RegExps are compared by their source patterns and flags.
1850
+ case '[object RegExp]':
1851
+ return a.source == b.source &&
1852
+ a.global == b.global &&
1853
+ a.multiline == b.multiline &&
1854
+ a.ignoreCase == b.ignoreCase;
1855
+ }
1856
+ if (typeof a != 'object' || typeof b != 'object') { return false; }
1857
+ // Assume equality for cyclic structures. The algorithm for detecting cyclic
1858
+ // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
1859
+ var length = aStack.length;
1860
+ while (length--) {
1861
+ // Linear search. Performance is inversely proportional to the number of
1862
+ // unique nested structures.
1863
+ if (aStack[length] == a) { return bStack[length] == b; }
1864
+ }
1865
+ // Add the first object to the stack of traversed objects.
1866
+ aStack.push(a);
1867
+ bStack.push(b);
1868
+ var size = 0;
1869
+ // Recursively compare objects and arrays.
1870
+ if (className == '[object Array]') {
1871
+ // Compare array lengths to determine if a deep comparison is necessary.
1872
+ size = a.length;
1873
+ result = size == b.length;
1874
+ if (result) {
1875
+ // Deep compare the contents, ignoring non-numeric properties.
1876
+ while (size--) {
1877
+ if (!(result = eq(a[size], b[size], aStack, bStack, customTesters))) { break; }
1878
+ }
1879
+ }
1880
+ } else {
1881
+ // Objects with different constructors are not equivalent, but `Object`s
1882
+ // from different frames are.
1883
+ var aCtor = a.constructor, bCtor = b.constructor;
1884
+ if (aCtor !== bCtor && !(isFunction(aCtor) && (aCtor instanceof aCtor) &&
1885
+ isFunction(bCtor) && (bCtor instanceof bCtor))) {
1886
+ return false;
1887
+ }
1888
+ // Deep compare objects.
1889
+ for (var key in a) {
1890
+ if (has(a, key)) {
1891
+ // Count the expected number of properties.
1892
+ size++;
1893
+ // Deep compare each member.
1894
+ if (!(result = has(b, key) && eq(a[key], b[key], aStack, bStack, customTesters))) { break; }
1895
+ }
1896
+ }
1897
+ // Ensure that both objects contain the same number of properties.
1898
+ if (result) {
1899
+ for (key in b) {
1900
+ if (has(b, key) && !(size--)) { break; }
1901
+ }
1902
+ result = !size;
1903
+ }
1904
+ }
1905
+ // Remove the first object from the stack of traversed objects.
1906
+ aStack.pop();
1907
+ bStack.pop();
1908
+
1909
+ return result;
1910
+
1911
+ function has(obj, key) {
1912
+ return obj.hasOwnProperty(key);
1913
+ }
1914
+
1915
+ function isFunction(obj) {
1916
+ return typeof obj === 'function';
1917
+ }
1918
+ }
1919
+ };
1920
+
1921
+ getJasmineRequireObj().toBe = function() {
1922
+ function toBe() {
1923
+ return {
1924
+ compare: function(actual, expected) {
1925
+ return {
1926
+ pass: actual === expected
1927
+ };
1928
+ }
1929
+ };
1930
+ }
1931
+
1932
+ return toBe;
1933
+ };
1934
+
1935
+ getJasmineRequireObj().toBeCloseTo = function() {
1936
+
1937
+ function toBeCloseTo() {
1938
+ return {
1939
+ compare: function(actual, expected, precision) {
1940
+ if (precision !== 0) {
1941
+ precision = precision || 2;
1942
+ }
1943
+
1944
+ return {
1945
+ pass: Math.abs(expected - actual) < (Math.pow(10, -precision) / 2)
1946
+ };
1947
+ }
1948
+ };
1949
+ }
1950
+
1951
+ return toBeCloseTo;
1952
+ };
1953
+
1954
+ getJasmineRequireObj().toBeDefined = function() {
1955
+ function toBeDefined() {
1956
+ return {
1957
+ compare: function(actual) {
1958
+ return {
1959
+ pass: (void 0 !== actual)
1960
+ };
1961
+ }
1962
+ };
1963
+ }
1964
+
1965
+ return toBeDefined;
1966
+ };
1967
+
1968
+ getJasmineRequireObj().toBeFalsy = function() {
1969
+ function toBeFalsy() {
1970
+ return {
1971
+ compare: function(actual) {
1972
+ return {
1973
+ pass: !!!actual
1974
+ };
1975
+ }
1976
+ };
1977
+ }
1978
+
1979
+ return toBeFalsy;
1980
+ };
1981
+
1982
+ getJasmineRequireObj().toBeGreaterThan = function() {
1983
+
1984
+ function toBeGreaterThan() {
1985
+ return {
1986
+ compare: function(actual, expected) {
1987
+ return {
1988
+ pass: actual > expected
1989
+ };
1990
+ }
1991
+ };
1992
+ }
1993
+
1994
+ return toBeGreaterThan;
1995
+ };
1996
+
1997
+
1998
+ getJasmineRequireObj().toBeLessThan = function() {
1999
+ function toBeLessThan() {
2000
+ return {
2001
+
2002
+ compare: function(actual, expected) {
2003
+ return {
2004
+ pass: actual < expected
2005
+ };
2006
+ }
2007
+ };
2008
+ }
2009
+
2010
+ return toBeLessThan;
2011
+ };
2012
+ getJasmineRequireObj().toBeNaN = function(j$) {
2013
+
2014
+ function toBeNaN() {
2015
+ return {
2016
+ compare: function(actual) {
2017
+ var result = {
2018
+ pass: (actual !== actual)
2019
+ };
2020
+
2021
+ if (result.pass) {
2022
+ result.message = "Expected actual not to be NaN.";
2023
+ } else {
2024
+ result.message = "Expected " + j$.pp(actual) + " to be NaN.";
2025
+ }
2026
+
2027
+ return result;
2028
+ }
2029
+ };
2030
+ }
2031
+
2032
+ return toBeNaN;
2033
+ };
2034
+
2035
+ getJasmineRequireObj().toBeNull = function() {
2036
+
2037
+ function toBeNull() {
2038
+ return {
2039
+ compare: function(actual) {
2040
+ return {
2041
+ pass: actual === null
2042
+ };
2043
+ }
2044
+ };
2045
+ }
2046
+
2047
+ return toBeNull;
2048
+ };
2049
+
2050
+ getJasmineRequireObj().toBeTruthy = function() {
2051
+
2052
+ function toBeTruthy() {
2053
+ return {
2054
+ compare: function(actual) {
2055
+ return {
2056
+ pass: !!actual
2057
+ };
2058
+ }
2059
+ };
2060
+ }
2061
+
2062
+ return toBeTruthy;
2063
+ };
2064
+
2065
+ getJasmineRequireObj().toBeUndefined = function() {
2066
+
2067
+ function toBeUndefined() {
2068
+ return {
2069
+ compare: function(actual) {
2070
+ return {
2071
+ pass: void 0 === actual
2072
+ };
2073
+ }
2074
+ };
2075
+ }
2076
+
2077
+ return toBeUndefined;
2078
+ };
2079
+
2080
+ getJasmineRequireObj().toContain = function() {
2081
+ function toContain(util, customEqualityTesters) {
2082
+ customEqualityTesters = customEqualityTesters || [];
2083
+
2084
+ return {
2085
+ compare: function(actual, expected) {
2086
+
2087
+ return {
2088
+ pass: util.contains(actual, expected, customEqualityTesters)
2089
+ };
2090
+ }
2091
+ };
2092
+ }
2093
+
2094
+ return toContain;
2095
+ };
2096
+
2097
+ getJasmineRequireObj().toEqual = function() {
2098
+
2099
+ function toEqual(util, customEqualityTesters) {
2100
+ customEqualityTesters = customEqualityTesters || [];
2101
+
2102
+ return {
2103
+ compare: function(actual, expected) {
2104
+ var result = {
2105
+ pass: false
2106
+ };
2107
+
2108
+ result.pass = util.equals(actual, expected, customEqualityTesters);
2109
+
2110
+ return result;
2111
+ }
2112
+ };
2113
+ }
2114
+
2115
+ return toEqual;
2116
+ };
2117
+
2118
+ getJasmineRequireObj().toHaveBeenCalled = function(j$) {
2119
+
2120
+ function toHaveBeenCalled() {
2121
+ return {
2122
+ compare: function(actual) {
2123
+ var result = {};
2124
+
2125
+ if (!j$.isSpy(actual)) {
2126
+ throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.');
2127
+ }
2128
+
2129
+ if (arguments.length > 1) {
2130
+ throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith');
2131
+ }
2132
+
2133
+ result.pass = actual.calls.any();
2134
+
2135
+ result.message = result.pass ?
2136
+ "Expected spy " + actual.and.identity() + " not to have been called." :
2137
+ "Expected spy " + actual.and.identity() + " to have been called.";
2138
+
2139
+ return result;
2140
+ }
2141
+ };
2142
+ }
2143
+
2144
+ return toHaveBeenCalled;
2145
+ };
2146
+
2147
+ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
2148
+
2149
+ function toHaveBeenCalledWith(util) {
2150
+ return {
2151
+ compare: function() {
2152
+ var args = Array.prototype.slice.call(arguments, 0),
2153
+ actual = args[0],
2154
+ expectedArgs = args.slice(1),
2155
+ result = { pass: false };
2156
+
2157
+ if (!j$.isSpy(actual)) {
2158
+ throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.');
2159
+ }
2160
+
2161
+ if (!actual.calls.any()) {
2162
+ result.message = "Expected spy " + actual.and.identity() + " to have been called with " + j$.pp(expectedArgs) + " but it was never called.";
2163
+ return result;
2164
+ }
2165
+
2166
+ if (util.contains(actual.calls.allArgs(), expectedArgs)) {
2167
+ result.pass = true;
2168
+ result.message = "Expected spy " + actual.and.identity() + " not to have been called with " + j$.pp(expectedArgs) + " but it was.";
2169
+ } else {
2170
+ result.message = "Expected spy " + actual.and.identity() + " to have been called with " + j$.pp(expectedArgs) + " but actual calls were " + j$.pp(actual.calls.allArgs()).replace(/^\[ | \]$/g, '') + ".";
2171
+ }
2172
+
2173
+ return result;
2174
+ }
2175
+ };
2176
+ }
2177
+
2178
+ return toHaveBeenCalledWith;
2179
+ };
2180
+
2181
+ getJasmineRequireObj().toMatch = function() {
2182
+
2183
+ function toMatch() {
2184
+ return {
2185
+ compare: function(actual, expected) {
2186
+ var regexp = new RegExp(expected);
2187
+
2188
+ return {
2189
+ pass: regexp.test(actual)
2190
+ };
2191
+ }
2192
+ };
2193
+ }
2194
+
2195
+ return toMatch;
2196
+ };
2197
+
2198
+ getJasmineRequireObj().toThrow = function(j$) {
2199
+
2200
+ function toThrow(util) {
2201
+ return {
2202
+ compare: function(actual, expected) {
2203
+ var result = { pass: false },
2204
+ threw = false,
2205
+ thrown;
2206
+
2207
+ if (typeof actual != "function") {
2208
+ throw new Error("Actual is not a Function");
2209
+ }
2210
+
2211
+ try {
2212
+ actual();
2213
+ } catch (e) {
2214
+ threw = true;
2215
+ thrown = e;
2216
+ }
2217
+
2218
+ if (!threw) {
2219
+ result.message = "Expected function to throw an exception.";
2220
+ return result;
2221
+ }
2222
+
2223
+ if (arguments.length == 1) {
2224
+ result.pass = true;
2225
+ result.message = "Expected function not to throw, but it threw " + j$.pp(thrown) + ".";
2226
+
2227
+ return result;
2228
+ }
2229
+
2230
+ if (util.equals(thrown, expected)) {
2231
+ result.pass = true;
2232
+ result.message = "Expected function not to throw " + j$.pp(expected) + ".";
2233
+ } else {
2234
+ result.message = "Expected function to throw " + j$.pp(expected) + ", but it threw " + j$.pp(thrown) + ".";
2235
+ }
2236
+
2237
+ return result;
2238
+ }
2239
+ };
2240
+ }
2241
+
2242
+ return toThrow;
2243
+ };
2244
+
2245
+ getJasmineRequireObj().toThrowError = function(j$) {
2246
+ function toThrowError (util) {
2247
+ return {
2248
+ compare: function(actual) {
2249
+ var threw = false,
2250
+ thrown,
2251
+ errorType,
2252
+ message,
2253
+ regexp,
2254
+ name,
2255
+ constructorName;
2256
+
2257
+ if (typeof actual != "function") {
2258
+ throw new Error("Actual is not a Function");
2259
+ }
2260
+
2261
+ extractExpectedParams.apply(null, arguments);
2262
+
2263
+ try {
2264
+ actual();
2265
+ } catch (e) {
2266
+ threw = true;
2267
+ thrown = e;
2268
+ }
2269
+
2270
+ if (!threw) {
2271
+ return fail("Expected function to throw an Error.");
2272
+ }
2273
+
2274
+ if (!(thrown instanceof Error)) {
2275
+ return fail("Expected function to throw an Error, but it threw " + thrown + ".");
2276
+ }
2277
+
2278
+ if (arguments.length == 1) {
2279
+ return pass("Expected function not to throw an Error, but it threw " + fnNameFor(thrown) + ".");
2280
+ }
2281
+
2282
+ if (errorType) {
2283
+ name = fnNameFor(errorType);
2284
+ constructorName = fnNameFor(thrown.constructor);
2285
+ }
2286
+
2287
+ if (errorType && message) {
2288
+ if (thrown.constructor == errorType && util.equals(thrown.message, message)) {
2289
+ return pass("Expected function not to throw " + name + " with message \"" + message + "\".");
2290
+ } else {
2291
+ return fail("Expected function to throw " + name + " with message \"" + message +
2292
+ "\", but it threw " + constructorName + " with message \"" + thrown.message + "\".");
2293
+ }
2294
+ }
2295
+
2296
+ if (errorType && regexp) {
2297
+ if (thrown.constructor == errorType && regexp.test(thrown.message)) {
2298
+ return pass("Expected function not to throw " + name + " with message matching " + regexp + ".");
2299
+ } else {
2300
+ return fail("Expected function to throw " + name + " with message matching " + regexp +
2301
+ ", but it threw " + constructorName + " with message \"" + thrown.message + "\".");
2302
+ }
2303
+ }
2304
+
2305
+ if (errorType) {
2306
+ if (thrown.constructor == errorType) {
2307
+ return pass("Expected function not to throw " + name + ".");
2308
+ } else {
2309
+ return fail("Expected function to throw " + name + ", but it threw " + constructorName + ".");
2310
+ }
2311
+ }
2312
+
2313
+ if (message) {
2314
+ if (thrown.message == message) {
2315
+ return pass("Expected function not to throw an exception with message " + j$.pp(message) + ".");
2316
+ } else {
2317
+ return fail("Expected function to throw an exception with message " + j$.pp(message) +
2318
+ ", but it threw an exception with message " + j$.pp(thrown.message) + ".");
2319
+ }
2320
+ }
2321
+
2322
+ if (regexp) {
2323
+ if (regexp.test(thrown.message)) {
2324
+ return pass("Expected function not to throw an exception with a message matching " + j$.pp(regexp) + ".");
2325
+ } else {
2326
+ return fail("Expected function to throw an exception with a message matching " + j$.pp(regexp) +
2327
+ ", but it threw an exception with message " + j$.pp(thrown.message) + ".");
2328
+ }
2329
+ }
2330
+
2331
+ function fnNameFor(func) {
2332
+ return func.name || func.toString().match(/^\s*function\s*(\w*)\s*\(/)[1];
2333
+ }
2334
+
2335
+ function pass(notMessage) {
2336
+ return {
2337
+ pass: true,
2338
+ message: notMessage
2339
+ };
2340
+ }
2341
+
2342
+ function fail(message) {
2343
+ return {
2344
+ pass: false,
2345
+ message: message
2346
+ };
2347
+ }
2348
+
2349
+ function extractExpectedParams() {
2350
+ if (arguments.length == 1) {
2351
+ return;
2352
+ }
2353
+
2354
+ if (arguments.length == 2) {
2355
+ var expected = arguments[1];
2356
+
2357
+ if (expected instanceof RegExp) {
2358
+ regexp = expected;
2359
+ } else if (typeof expected == "string") {
2360
+ message = expected;
2361
+ } else if (checkForAnErrorType(expected)) {
2362
+ errorType = expected;
2363
+ }
2364
+
2365
+ if (!(errorType || message || regexp)) {
2366
+ throw new Error("Expected is not an Error, string, or RegExp.");
2367
+ }
2368
+ } else {
2369
+ if (checkForAnErrorType(arguments[1])) {
2370
+ errorType = arguments[1];
2371
+ } else {
2372
+ throw new Error("Expected error type is not an Error.");
2373
+ }
2374
+
2375
+ if (arguments[2] instanceof RegExp) {
2376
+ regexp = arguments[2];
2377
+ } else if (typeof arguments[2] == "string") {
2378
+ message = arguments[2];
2379
+ } else {
2380
+ throw new Error("Expected error message is not a string or RegExp.");
2381
+ }
2382
+ }
2383
+ }
2384
+
2385
+ function checkForAnErrorType(type) {
2386
+ if (typeof type !== "function") {
2387
+ return false;
2388
+ }
2389
+
2390
+ var Surrogate = function() {};
2391
+ Surrogate.prototype = type.prototype;
2392
+ return (new Surrogate()) instanceof Error;
2393
+ }
2394
+ }
2395
+ };
2396
+ }
2397
+
2398
+ return toThrowError;
2399
+ };
2400
+
2401
+ getJasmineRequireObj().version = function() {
2402
+ return "2.0.0";
2403
+ };