unpoly-rails 0.20.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of unpoly-rails might be problematic. Click here for more details.

Files changed (339) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.ruby-version +2 -0
  4. data/.yardopts +1 -0
  5. data/CHANGELOG.md +577 -0
  6. data/Gemfile +8 -0
  7. data/Gemfile.lock +42 -0
  8. data/LICENSE +22 -0
  9. data/README.md +75 -0
  10. data/README_RAILS.md +116 -0
  11. data/Rakefile +45 -0
  12. data/bower.json +26 -0
  13. data/design/animation-ghosting.txt +72 -0
  14. data/design/design.txt +34 -0
  15. data/design/draft.html.erb +48 -0
  16. data/design/draft.rb +9 -0
  17. data/design/ghost-debugging.txt +118 -0
  18. data/design/homepage.txt +236 -0
  19. data/design/rename.txt +0 -0
  20. data/dist/unpoly-bootstrap3.css +5 -0
  21. data/dist/unpoly-bootstrap3.js +28 -0
  22. data/dist/unpoly-bootstrap3.min.css +1 -0
  23. data/dist/unpoly-bootstrap3.min.js +1 -0
  24. data/dist/unpoly.css +98 -0
  25. data/dist/unpoly.js +9041 -0
  26. data/dist/unpoly.min.css +1 -0
  27. data/dist/unpoly.min.js +3 -0
  28. data/lib/assets/javascripts/unpoly-bootstrap3.js.coffee +2 -0
  29. data/lib/assets/javascripts/unpoly-bootstrap3/form-ext.js.coffee +1 -0
  30. data/lib/assets/javascripts/unpoly-bootstrap3/layout-ext.js.coffee +5 -0
  31. data/lib/assets/javascripts/unpoly-bootstrap3/modal-ext.js.coffee +11 -0
  32. data/lib/assets/javascripts/unpoly-bootstrap3/navigation-ext.js.coffee +3 -0
  33. data/lib/assets/javascripts/unpoly.js.coffee +20 -0
  34. data/lib/assets/javascripts/unpoly/browser.js.coffee +252 -0
  35. data/lib/assets/javascripts/unpoly/bus.js.coffee +393 -0
  36. data/lib/assets/javascripts/unpoly/flow.js.coffee +809 -0
  37. data/lib/assets/javascripts/unpoly/form.js.coffee +864 -0
  38. data/lib/assets/javascripts/unpoly/history.js.coffee +204 -0
  39. data/lib/assets/javascripts/unpoly/layout.js.coffee +529 -0
  40. data/lib/assets/javascripts/unpoly/link.js.coffee +496 -0
  41. data/lib/assets/javascripts/unpoly/log.js.coffee +73 -0
  42. data/lib/assets/javascripts/unpoly/modal.js.coffee +509 -0
  43. data/lib/assets/javascripts/unpoly/module.js.coffee +4 -0
  44. data/lib/assets/javascripts/unpoly/motion.js.coffee +690 -0
  45. data/lib/assets/javascripts/unpoly/navigation.js.coffee +219 -0
  46. data/lib/assets/javascripts/unpoly/popup.js.coffee +409 -0
  47. data/lib/assets/javascripts/unpoly/proxy.js.coffee +521 -0
  48. data/lib/assets/javascripts/unpoly/rails.js.coffee +36 -0
  49. data/lib/assets/javascripts/unpoly/syntax.js.coffee +337 -0
  50. data/lib/assets/javascripts/unpoly/tooltip.js.coffee +183 -0
  51. data/lib/assets/javascripts/unpoly/util.js.coffee +1593 -0
  52. data/lib/assets/stylesheets/unpoly-bootstrap3.css.sass +1 -0
  53. data/lib/assets/stylesheets/unpoly-bootstrap3/modal-ext.css.sass +9 -0
  54. data/lib/assets/stylesheets/unpoly.css.sass +1 -0
  55. data/lib/assets/stylesheets/unpoly/close.css.sass +2 -0
  56. data/lib/assets/stylesheets/unpoly/error.css.sass +15 -0
  57. data/lib/assets/stylesheets/unpoly/link.css.sass +2 -0
  58. data/lib/assets/stylesheets/unpoly/modal.css.sass +69 -0
  59. data/lib/assets/stylesheets/unpoly/popup.css.sass +8 -0
  60. data/lib/assets/stylesheets/unpoly/tooltip.css.sass +42 -0
  61. data/lib/unpoly-rails.rb +7 -0
  62. data/lib/unpoly/rails/engine.rb +6 -0
  63. data/lib/unpoly/rails/inspector.rb +78 -0
  64. data/lib/unpoly/rails/inspector_accessor.rb +30 -0
  65. data/lib/unpoly/rails/request_echo_headers.rb +27 -0
  66. data/lib/unpoly/rails/request_method_cookie.rb +36 -0
  67. data/lib/unpoly/rails/version.rb +9 -0
  68. data/spec_app/.firefox-version +1 -0
  69. data/spec_app/.gitignore +17 -0
  70. data/spec_app/.rspec +2 -0
  71. data/spec_app/Bowerfile +3 -0
  72. data/spec_app/Gemfile +29 -0
  73. data/spec_app/Gemfile.lock +212 -0
  74. data/spec_app/README.rdoc +28 -0
  75. data/spec_app/Rakefile +6 -0
  76. data/spec_app/app/assets/images/.keep +0 -0
  77. data/spec_app/app/assets/javascripts/application.js +20 -0
  78. data/spec_app/app/assets/stylesheets/application.css +17 -0
  79. data/spec_app/app/assets/stylesheets/blocks/card.css.sass +11 -0
  80. data/spec_app/app/assets/stylesheets/blocks/controls.css.sass +7 -0
  81. data/spec_app/app/assets/stylesheets/blocks/menu.css.sass +13 -0
  82. data/spec_app/app/assets/stylesheets/blocks/panel.css.sass +8 -0
  83. data/spec_app/app/assets/stylesheets/jasmine_specs.css +5 -0
  84. data/spec_app/app/controllers/application_controller.rb +6 -0
  85. data/spec_app/app/controllers/concerns/.keep +0 -0
  86. data/spec_app/app/controllers/test_controller.rb +28 -0
  87. data/spec_app/app/helpers/application_helper.rb +2 -0
  88. data/spec_app/app/mailers/.keep +0 -0
  89. data/spec_app/app/models/concerns/.keep +0 -0
  90. data/spec_app/app/views/layouts/application.html.erb +12 -0
  91. data/spec_app/bin/bundle +3 -0
  92. data/spec_app/bin/rails +8 -0
  93. data/spec_app/bin/rake +8 -0
  94. data/spec_app/bin/setup +29 -0
  95. data/spec_app/bin/spring +18 -0
  96. data/spec_app/config.ru +4 -0
  97. data/spec_app/config/application.rb +26 -0
  98. data/spec_app/config/boot.rb +3 -0
  99. data/spec_app/config/database.yml +25 -0
  100. data/spec_app/config/environment.rb +5 -0
  101. data/spec_app/config/environments/development.rb +41 -0
  102. data/spec_app/config/environments/production.rb +79 -0
  103. data/spec_app/config/environments/test.rb +42 -0
  104. data/spec_app/config/initializers/assets.rb +11 -0
  105. data/spec_app/config/initializers/backtrace_silencers.rb +7 -0
  106. data/spec_app/config/initializers/bower_rails.rb +16 -0
  107. data/spec_app/config/initializers/cookies_serializer.rb +3 -0
  108. data/spec_app/config/initializers/filter_parameter_logging.rb +4 -0
  109. data/spec_app/config/initializers/inflections.rb +16 -0
  110. data/spec_app/config/initializers/mime_types.rb +4 -0
  111. data/spec_app/config/initializers/session_store.rb +3 -0
  112. data/spec_app/config/initializers/wrap_parameters.rb +14 -0
  113. data/spec_app/config/locales/en.yml +23 -0
  114. data/spec_app/config/routes.rb +8 -0
  115. data/spec_app/config/secrets.yml +22 -0
  116. data/spec_app/db/schema.rb +23 -0
  117. data/spec_app/db/seeds.rb +7 -0
  118. data/spec_app/lib/assets/.keep +0 -0
  119. data/spec_app/lib/tasks/.keep +0 -0
  120. data/spec_app/lib/tasks/cucumber.rake +65 -0
  121. data/spec_app/log/.keep +0 -0
  122. data/spec_app/public/404.html +67 -0
  123. data/spec_app/public/422.html +67 -0
  124. data/spec_app/public/500.html +66 -0
  125. data/spec_app/public/favicon.ico +0 -0
  126. data/spec_app/public/robots.txt +5 -0
  127. data/spec_app/script/cucumber +10 -0
  128. data/spec_app/spec/controllers/test_controller_spec.rb +76 -0
  129. data/spec_app/spec/javascripts/helpers/append_fixture.js.coffee +8 -0
  130. data/spec_app/spec/javascripts/helpers/browser_switches.js.coffee +9 -0
  131. data/spec_app/spec/javascripts/helpers/index.js.coffee +1 -0
  132. data/spec_app/spec/javascripts/helpers/knife.js.coffee +69 -0
  133. data/spec_app/spec/javascripts/helpers/last_request.js.coffee +22 -0
  134. data/spec_app/spec/javascripts/helpers/mock_ajax.js.coffee +5 -0
  135. data/spec_app/spec/javascripts/helpers/mock_clock.js.coffee +2 -0
  136. data/spec_app/spec/javascripts/helpers/remove_body_margin.js.coffee +5 -0
  137. data/spec_app/spec/javascripts/helpers/reset_knife.js.coffee +2 -0
  138. data/spec_app/spec/javascripts/helpers/reset_path.js.coffee +8 -0
  139. data/spec_app/spec/javascripts/helpers/reset_up.js.coffee +4 -0
  140. data/spec_app/spec/javascripts/helpers/restore_body_scroll.js.coffee +2 -0
  141. data/spec_app/spec/javascripts/helpers/set_timer.js.coffee +3 -0
  142. data/spec_app/spec/javascripts/helpers/to_be_around.js.coffee +5 -0
  143. data/spec_app/spec/javascripts/helpers/to_be_blank.js.coffee +5 -0
  144. data/spec_app/spec/javascripts/helpers/to_be_given.js.coffee +5 -0
  145. data/spec_app/spec/javascripts/helpers/to_be_missing.js.coffee +5 -0
  146. data/spec_app/spec/javascripts/helpers/to_be_present.js.coffee +5 -0
  147. data/spec_app/spec/javascripts/helpers/to_end_with.js.coffee +8 -0
  148. data/spec_app/spec/javascripts/helpers/to_equal_jquery.js.coffee +9 -0
  149. data/spec_app/spec/javascripts/helpers/to_have_request_method.js.coffee +8 -0
  150. data/spec_app/spec/javascripts/helpers/trigger.js.coffee +68 -0
  151. data/spec_app/spec/javascripts/support/jasmine.yml +51 -0
  152. data/spec_app/spec/javascripts/up/bus_spec.js.coffee +122 -0
  153. data/spec_app/spec/javascripts/up/flow_spec.js.coffee +755 -0
  154. data/spec_app/spec/javascripts/up/form_spec.js.coffee +471 -0
  155. data/spec_app/spec/javascripts/up/history_spec.js.coffee +96 -0
  156. data/spec_app/spec/javascripts/up/layout_spec.js.coffee +318 -0
  157. data/spec_app/spec/javascripts/up/link_spec.js.coffee +340 -0
  158. data/spec_app/spec/javascripts/up/modal_spec.js.coffee +265 -0
  159. data/spec_app/spec/javascripts/up/motion_spec.js.coffee +306 -0
  160. data/spec_app/spec/javascripts/up/navigation_spec.js.coffee +132 -0
  161. data/spec_app/spec/javascripts/up/popup_spec.js.coffee +220 -0
  162. data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +371 -0
  163. data/spec_app/spec/javascripts/up/rails_spec.js.coffee +101 -0
  164. data/spec_app/spec/javascripts/up/syntax_spec.js.coffee +99 -0
  165. data/spec_app/spec/javascripts/up/tooltip_spec.js.coffee +60 -0
  166. data/spec_app/spec/javascripts/up/util_spec.js.coffee +325 -0
  167. data/spec_app/spec/spec_helper.rb +62 -0
  168. data/spec_app/test/controllers/.keep +0 -0
  169. data/spec_app/test/fixtures/.keep +0 -0
  170. data/spec_app/test/helpers/.keep +0 -0
  171. data/spec_app/test/integration/.keep +0 -0
  172. data/spec_app/test/mailers/.keep +0 -0
  173. data/spec_app/test/models/.keep +0 -0
  174. data/spec_app/test/test_helper.rb +10 -0
  175. data/spec_app/vendor/assets/.bowerrc +3 -0
  176. data/spec_app/vendor/assets/bower.json +8 -0
  177. data/spec_app/vendor/assets/bower_components/jasmine-ajax/.bower.json +43 -0
  178. data/spec_app/vendor/assets/bower_components/jasmine-ajax/MIT.LICENSE +20 -0
  179. data/spec_app/vendor/assets/bower_components/jasmine-ajax/README.markdown +289 -0
  180. data/spec_app/vendor/assets/bower_components/jasmine-ajax/bower.json +35 -0
  181. data/spec_app/vendor/assets/bower_components/jasmine-ajax/lib/mock-ajax.js +733 -0
  182. data/spec_app/vendor/assets/bower_components/jasmine-ajax/package.json +26 -0
  183. data/spec_app/vendor/assets/bower_components/jasmine-ajax/release_notes/2.0.2.md +50 -0
  184. data/spec_app/vendor/assets/bower_components/jasmine-ajax/release_notes/2.99.md +14 -0
  185. data/spec_app/vendor/assets/bower_components/jasmine-ajax/release_notes/3.0.md +28 -0
  186. data/spec_app/vendor/assets/bower_components/jasmine-ajax/release_notes/3.1.0.md +24 -0
  187. data/spec_app/vendor/assets/bower_components/jasmine-ajax/release_notes/3.1.1.md +23 -0
  188. data/spec_app/vendor/assets/bower_components/jasmine-ajax/release_notes/3.2.0.md +20 -0
  189. data/spec_app/vendor/assets/bower_components/jasmine-fixture/.bower.json +27 -0
  190. data/spec_app/vendor/assets/bower_components/jasmine-fixture/.gitignore +8 -0
  191. data/spec_app/vendor/assets/bower_components/jasmine-fixture/.npmignore +8 -0
  192. data/spec_app/vendor/assets/bower_components/jasmine-fixture/LICENSE.txt +24 -0
  193. data/spec_app/vendor/assets/bower_components/jasmine-fixture/README.md +118 -0
  194. data/spec_app/vendor/assets/bower_components/jasmine-fixture/bower.json +17 -0
  195. data/spec_app/vendor/assets/bower_components/jasmine-fixture/dist/jasmine-fixture.js +433 -0
  196. data/spec_app/vendor/assets/bower_components/jasmine-fixture/dist/jasmine-fixture.min.js +5 -0
  197. data/spec_app/vendor/assets/bower_components/jasmine-fixture/spec-e2e/basic-usage-spec.coffee +14 -0
  198. data/spec_app/vendor/assets/bower_components/jasmine-fixture/spec-e2e/helpers/invariants.coffee +17 -0
  199. data/spec_app/vendor/assets/bower_components/jasmine-fixture/spec-e2e/helpers/spec-within-a-spec.coffee +24 -0
  200. data/spec_app/vendor/assets/bower_components/jasmine-fixture/spec-e2e/helpers/tmp-files.coffee +8 -0
  201. data/spec_app/vendor/assets/bower_components/jasmine-fixture/spec-e2e/support/jasmine1-testem-config.json +11 -0
  202. data/spec_app/vendor/assets/bower_components/jasmine-fixture/spec-e2e/support/jasmine2-testem-config.json +11 -0
  203. data/spec_app/vendor/assets/bower_components/jasmine-fixture/vendor/js/jquery-1.11.0.js +10337 -0
  204. data/spec_app/vendor/assets/bower_components/jasmine-fixture/vendor/js/jquery-1.8.3.js +9472 -0
  205. data/spec_app/vendor/assets/bower_components/jasmine-fixture/vendor/js/jquery-2.1.0.js +9111 -0
  206. data/spec_app/vendor/assets/bower_components/jasmine-jquery/.bower.json +26 -0
  207. data/spec_app/vendor/assets/bower_components/jasmine-jquery/CONTRIBUTING.md +28 -0
  208. data/spec_app/vendor/assets/bower_components/jasmine-jquery/Gruntfile.js +49 -0
  209. data/spec_app/vendor/assets/bower_components/jasmine-jquery/LICENSE +20 -0
  210. data/spec_app/vendor/assets/bower_components/jasmine-jquery/README.md +367 -0
  211. data/spec_app/vendor/assets/bower_components/jasmine-jquery/bower.json +15 -0
  212. data/spec_app/vendor/assets/bower_components/jasmine-jquery/lib/jasmine-jquery.js +838 -0
  213. data/spec_app/vendor/assets/bower_components/jasmine-jquery/package.json +35 -0
  214. data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/fixtures/fixture_with_checkbox_with_checked.html +6 -0
  215. data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/fixtures/fixture_with_javascript.html +1 -0
  216. data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/fixtures/fixture_with_javascript_block.html +1 -0
  217. data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/fixtures/javascripts/jasmine_javascript_click.js +1 -0
  218. data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/fixtures/javascripts/jasmine_javascript_hover.js +1 -0
  219. data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/fixtures/json/jasmine_json_test.json +1 -0
  220. data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/fixtures/real_non_mocked_fixture.html +1 -0
  221. data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/fixtures/real_non_mocked_fixture_style.css +1 -0
  222. data/spec_app/vendor/assets/bower_components/jasmine-jquery/spec/suites/jasmine-jquery-spec.js +1842 -0
  223. data/spec_app/vendor/assets/bower_components/jasmine/.bower.json +50 -0
  224. data/spec_app/vendor/assets/bower_components/jasmine/CONTRIBUTING.md +130 -0
  225. data/spec_app/vendor/assets/bower_components/jasmine/GOALS_2.0.md +64 -0
  226. data/spec_app/vendor/assets/bower_components/jasmine/MANIFEST.in +5 -0
  227. data/spec_app/vendor/assets/bower_components/jasmine/MIT.LICENSE +20 -0
  228. data/spec_app/vendor/assets/bower_components/jasmine/README.md +73 -0
  229. data/spec_app/vendor/assets/bower_components/jasmine/RELEASE.md +73 -0
  230. data/spec_app/vendor/assets/bower_components/jasmine/bower.json +41 -0
  231. data/spec_app/vendor/assets/bower_components/jasmine/images/jasmine-horizontal.png +0 -0
  232. data/spec_app/vendor/assets/bower_components/jasmine/images/jasmine-horizontal.svg +102 -0
  233. data/spec_app/vendor/assets/bower_components/jasmine/images/jasmine_favicon.png +0 -0
  234. data/spec_app/vendor/assets/bower_components/jasmine/lib/console/console.js +190 -0
  235. data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core.js +37 -0
  236. data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core/boot.js +143 -0
  237. data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core/example/node_example/lib/jasmine_examples/Player.js +24 -0
  238. data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core/example/node_example/lib/jasmine_examples/Song.js +9 -0
  239. data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core/jasmine-html.js +446 -0
  240. data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core/jasmine.css +58 -0
  241. data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core/jasmine.js +3298 -0
  242. data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core/json2.js +489 -0
  243. data/spec_app/vendor/assets/bower_components/jasmine/lib/jasmine-core/node_boot.js +41 -0
  244. data/spec_app/vendor/assets/bower_components/jasmine/package.json +34 -0
  245. data/spec_app/vendor/assets/bower_components/jasmine/requirements.txt +1 -0
  246. data/spec_app/vendor/assets/bower_components/jquery/.bower.json +38 -0
  247. data/spec_app/vendor/assets/bower_components/jquery/MIT-LICENSE.txt +21 -0
  248. data/spec_app/vendor/assets/bower_components/jquery/bower.json +28 -0
  249. data/spec_app/vendor/assets/bower_components/jquery/dist/jquery.js +9210 -0
  250. data/spec_app/vendor/assets/bower_components/jquery/dist/jquery.min.js +5 -0
  251. data/spec_app/vendor/assets/bower_components/jquery/dist/jquery.min.map +1 -0
  252. data/spec_app/vendor/assets/bower_components/jquery/src/ajax.js +786 -0
  253. data/spec_app/vendor/assets/bower_components/jquery/src/ajax/jsonp.js +89 -0
  254. data/spec_app/vendor/assets/bower_components/jquery/src/ajax/load.js +75 -0
  255. data/spec_app/vendor/assets/bower_components/jquery/src/ajax/parseJSON.js +13 -0
  256. data/spec_app/vendor/assets/bower_components/jquery/src/ajax/parseXML.js +28 -0
  257. data/spec_app/vendor/assets/bower_components/jquery/src/ajax/script.js +64 -0
  258. data/spec_app/vendor/assets/bower_components/jquery/src/ajax/var/nonce.js +5 -0
  259. data/spec_app/vendor/assets/bower_components/jquery/src/ajax/var/rquery.js +3 -0
  260. data/spec_app/vendor/assets/bower_components/jquery/src/ajax/xhr.js +136 -0
  261. data/spec_app/vendor/assets/bower_components/jquery/src/attributes.js +11 -0
  262. data/spec_app/vendor/assets/bower_components/jquery/src/attributes/attr.js +141 -0
  263. data/spec_app/vendor/assets/bower_components/jquery/src/attributes/classes.js +158 -0
  264. data/spec_app/vendor/assets/bower_components/jquery/src/attributes/prop.js +94 -0
  265. data/spec_app/vendor/assets/bower_components/jquery/src/attributes/support.js +35 -0
  266. data/spec_app/vendor/assets/bower_components/jquery/src/attributes/val.js +161 -0
  267. data/spec_app/vendor/assets/bower_components/jquery/src/callbacks.js +205 -0
  268. data/spec_app/vendor/assets/bower_components/jquery/src/core.js +502 -0
  269. data/spec_app/vendor/assets/bower_components/jquery/src/core/access.js +60 -0
  270. data/spec_app/vendor/assets/bower_components/jquery/src/core/init.js +123 -0
  271. data/spec_app/vendor/assets/bower_components/jquery/src/core/parseHTML.js +39 -0
  272. data/spec_app/vendor/assets/bower_components/jquery/src/core/ready.js +97 -0
  273. data/spec_app/vendor/assets/bower_components/jquery/src/core/var/rsingleTag.js +4 -0
  274. data/spec_app/vendor/assets/bower_components/jquery/src/css.js +450 -0
  275. data/spec_app/vendor/assets/bower_components/jquery/src/css/addGetHookIf.js +22 -0
  276. data/spec_app/vendor/assets/bower_components/jquery/src/css/curCSS.js +57 -0
  277. data/spec_app/vendor/assets/bower_components/jquery/src/css/defaultDisplay.js +70 -0
  278. data/spec_app/vendor/assets/bower_components/jquery/src/css/hiddenVisibleSelectors.js +15 -0
  279. data/spec_app/vendor/assets/bower_components/jquery/src/css/support.js +96 -0
  280. data/spec_app/vendor/assets/bower_components/jquery/src/css/swap.js +28 -0
  281. data/spec_app/vendor/assets/bower_components/jquery/src/css/var/cssExpand.js +3 -0
  282. data/spec_app/vendor/assets/bower_components/jquery/src/css/var/getStyles.js +12 -0
  283. data/spec_app/vendor/assets/bower_components/jquery/src/css/var/isHidden.js +13 -0
  284. data/spec_app/vendor/assets/bower_components/jquery/src/css/var/rmargin.js +3 -0
  285. data/spec_app/vendor/assets/bower_components/jquery/src/css/var/rnumnonpx.js +5 -0
  286. data/spec_app/vendor/assets/bower_components/jquery/src/data.js +178 -0
  287. data/spec_app/vendor/assets/bower_components/jquery/src/data/Data.js +181 -0
  288. data/spec_app/vendor/assets/bower_components/jquery/src/data/accepts.js +20 -0
  289. data/spec_app/vendor/assets/bower_components/jquery/src/data/var/data_priv.js +5 -0
  290. data/spec_app/vendor/assets/bower_components/jquery/src/data/var/data_user.js +5 -0
  291. data/spec_app/vendor/assets/bower_components/jquery/src/deferred.js +149 -0
  292. data/spec_app/vendor/assets/bower_components/jquery/src/deprecated.js +13 -0
  293. data/spec_app/vendor/assets/bower_components/jquery/src/dimensions.js +50 -0
  294. data/spec_app/vendor/assets/bower_components/jquery/src/effects.js +648 -0
  295. data/spec_app/vendor/assets/bower_components/jquery/src/effects/Tween.js +114 -0
  296. data/spec_app/vendor/assets/bower_components/jquery/src/effects/animatedSelector.js +13 -0
  297. data/spec_app/vendor/assets/bower_components/jquery/src/event.js +868 -0
  298. data/spec_app/vendor/assets/bower_components/jquery/src/event/ajax.js +13 -0
  299. data/spec_app/vendor/assets/bower_components/jquery/src/event/alias.js +39 -0
  300. data/spec_app/vendor/assets/bower_components/jquery/src/event/support.js +9 -0
  301. data/spec_app/vendor/assets/bower_components/jquery/src/exports/amd.js +24 -0
  302. data/spec_app/vendor/assets/bower_components/jquery/src/exports/global.js +32 -0
  303. data/spec_app/vendor/assets/bower_components/jquery/src/intro.js +44 -0
  304. data/spec_app/vendor/assets/bower_components/jquery/src/jquery.js +37 -0
  305. data/spec_app/vendor/assets/bower_components/jquery/src/manipulation.js +580 -0
  306. data/spec_app/vendor/assets/bower_components/jquery/src/manipulation/_evalUrl.js +18 -0
  307. data/spec_app/vendor/assets/bower_components/jquery/src/manipulation/support.js +32 -0
  308. data/spec_app/vendor/assets/bower_components/jquery/src/manipulation/var/rcheckableType.js +3 -0
  309. data/spec_app/vendor/assets/bower_components/jquery/src/offset.js +207 -0
  310. data/spec_app/vendor/assets/bower_components/jquery/src/outro.js +1 -0
  311. data/spec_app/vendor/assets/bower_components/jquery/src/queue.js +142 -0
  312. data/spec_app/vendor/assets/bower_components/jquery/src/queue/delay.js +22 -0
  313. data/spec_app/vendor/assets/bower_components/jquery/src/selector-native.js +172 -0
  314. data/spec_app/vendor/assets/bower_components/jquery/src/selector-sizzle.js +14 -0
  315. data/spec_app/vendor/assets/bower_components/jquery/src/selector.js +1 -0
  316. data/spec_app/vendor/assets/bower_components/jquery/src/serialize.js +111 -0
  317. data/spec_app/vendor/assets/bower_components/jquery/src/sizzle/dist/sizzle.js +2067 -0
  318. data/spec_app/vendor/assets/bower_components/jquery/src/sizzle/dist/sizzle.min.js +3 -0
  319. data/spec_app/vendor/assets/bower_components/jquery/src/sizzle/dist/sizzle.min.map +1 -0
  320. data/spec_app/vendor/assets/bower_components/jquery/src/traversing.js +199 -0
  321. data/spec_app/vendor/assets/bower_components/jquery/src/traversing/findFilter.js +100 -0
  322. data/spec_app/vendor/assets/bower_components/jquery/src/traversing/var/rneedsContext.js +6 -0
  323. data/spec_app/vendor/assets/bower_components/jquery/src/var/arr.js +3 -0
  324. data/spec_app/vendor/assets/bower_components/jquery/src/var/class2type.js +4 -0
  325. data/spec_app/vendor/assets/bower_components/jquery/src/var/concat.js +5 -0
  326. data/spec_app/vendor/assets/bower_components/jquery/src/var/hasOwn.js +5 -0
  327. data/spec_app/vendor/assets/bower_components/jquery/src/var/indexOf.js +5 -0
  328. data/spec_app/vendor/assets/bower_components/jquery/src/var/pnum.js +3 -0
  329. data/spec_app/vendor/assets/bower_components/jquery/src/var/push.js +5 -0
  330. data/spec_app/vendor/assets/bower_components/jquery/src/var/rnotwhite.js +3 -0
  331. data/spec_app/vendor/assets/bower_components/jquery/src/var/slice.js +5 -0
  332. data/spec_app/vendor/assets/bower_components/jquery/src/var/strundefined.js +3 -0
  333. data/spec_app/vendor/assets/bower_components/jquery/src/var/support.js +4 -0
  334. data/spec_app/vendor/assets/bower_components/jquery/src/var/toString.js +5 -0
  335. data/spec_app/vendor/assets/bower_components/jquery/src/wrap.js +79 -0
  336. data/spec_app/vendor/assets/javascripts/.keep +0 -0
  337. data/spec_app/vendor/assets/stylesheets/.keep +0 -0
  338. data/unpoly-rails.gemspec +24 -0
  339. metadata +423 -0
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "jasmine-jquery",
3
+ "description": "jQuery matchers and fixture loader for Jasmine framework",
4
+ "version": "2.1.1",
5
+ "keywords": [
6
+ "jasmine",
7
+ "jquery"
8
+ ],
9
+ "main": "lib/jasmine-jquery.js",
10
+ "files": [
11
+ "lib/"
12
+ ],
13
+ "homepage": "http://github.com/velesin/jasmine-jquery",
14
+ "author": {
15
+ "name": "Travis Jeffery",
16
+ "email": "tj@travisjeffery.com",
17
+ "url": "travisjeffery.com"
18
+ },
19
+ "scripts": {
20
+ "test": "grunt test"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/velesin/jasmine-jquery.git"
25
+ },
26
+ "bugs": {
27
+ "url": "http://github.com/velesin/jasmine-jquery/issues"
28
+ },
29
+ "license": "MIT",
30
+ "devDependencies": {
31
+ "grunt": "0.4.5",
32
+ "grunt-contrib-jshint": "0.10.0",
33
+ "grunt-contrib-jasmine": "git://github.com/travisjeffery/grunt-contrib-jasmine#9d5874dd592cf41e8268918fe9baeb261afd75b2"
34
+ }
35
+ }
@@ -0,0 +1,6 @@
1
+ <div id="anchor_01">
2
+ <label>
3
+ <input type="checkbox" id="checked-box" checked />
4
+ This should render properly
5
+ </label>
6
+ </div>
@@ -0,0 +1 @@
1
+ <div id="anchor_01"><script src="spec/fixtures/javascripts/jasmine_javascript_click.js"></script><script src="spec/fixtures/javascripts/jasmine_javascript_hover.js"></script></div>
@@ -0,0 +1 @@
1
+ <div id="anchor_01"><script type="text/template">{{name}</script></div>
@@ -0,0 +1 @@
1
+ $(function (){ $('#anchor_01').click(function(){ $(this).addClass('foo'); }) });
@@ -0,0 +1 @@
1
+ $(function (){ $('#anchor_01').on('hover', function(){ $(this).addClass('bar'); }) });
@@ -0,0 +1 @@
1
+ <div id="real_non_mocked_fixture"></div>
@@ -0,0 +1,1842 @@
1
+ describe("jasmine.Fixtures", function () {
2
+ var ajaxData = 'some ajax data'
3
+ var fixtureUrl = 'some_url'
4
+ var anotherFixtureUrl = 'another_url'
5
+ var fixturesContainer = function () {
6
+ return $('#' + jasmine.getFixtures().containerId)
7
+ }
8
+ var appendFixturesContainerToDom = function () {
9
+ $('body').append('<div id="' + jasmine.getFixtures().containerId + '">old content</div>')
10
+ }
11
+
12
+ beforeEach(function () {
13
+ jasmine.getFixtures().clearCache()
14
+ spyOn(jasmine.Fixtures.prototype, 'loadFixtureIntoCache_').and.callFake(function (relativeUrl){
15
+ this.fixturesCache_[relativeUrl] = ajaxData
16
+ })
17
+ })
18
+
19
+ describe("default initial config values", function () {
20
+ it("should set 'jasmine-fixtures' as the default container id", function () {
21
+ expect(jasmine.getFixtures().containerId).toEqual('jasmine-fixtures')
22
+ })
23
+
24
+ it("should set 'spec/javascripts/fixtures' as the default fixtures path", function () {
25
+ expect(jasmine.getFixtures().fixturesPath).toEqual('spec/javascripts/fixtures')
26
+ })
27
+ })
28
+
29
+ describe("cache", function () {
30
+ describe("clearCache", function () {
31
+ it("should clear cache and in effect force subsequent AJAX call", function () {
32
+ jasmine.getFixtures().read(fixtureUrl)
33
+ jasmine.getFixtures().clearCache()
34
+ jasmine.getFixtures().read(fixtureUrl)
35
+ expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(2)
36
+ })
37
+ })
38
+
39
+ it("first-time read should go through AJAX", function () {
40
+ jasmine.getFixtures().read(fixtureUrl)
41
+ expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(1)
42
+ })
43
+
44
+ it("subsequent read from the same URL should go from cache", function () {
45
+ jasmine.getFixtures().read(fixtureUrl, fixtureUrl)
46
+ expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(1)
47
+ })
48
+ })
49
+
50
+ describe("read", function () {
51
+ it("should return fixture HTML", function () {
52
+ var html = jasmine.getFixtures().read(fixtureUrl)
53
+ expect(html).toEqual(ajaxData)
54
+ })
55
+
56
+ it("should return duplicated HTML of a fixture when its url is provided twice in a single call", function () {
57
+ var html = jasmine.getFixtures().read(fixtureUrl, fixtureUrl)
58
+ expect(html).toEqual(ajaxData + ajaxData)
59
+ })
60
+
61
+ it("should return merged HTML of two fixtures when two different urls are provided in a single call", function () {
62
+ var html = jasmine.getFixtures().read(fixtureUrl, anotherFixtureUrl)
63
+ expect(html).toEqual(ajaxData + ajaxData)
64
+ })
65
+
66
+ it("should have shortcut global method readFixtures", function () {
67
+ var html = readFixtures(fixtureUrl, anotherFixtureUrl)
68
+ expect(html).toEqual(ajaxData + ajaxData)
69
+ })
70
+
71
+ it("should use the configured fixtures path concatenating it to the requested url (without concatenating a slash if it already has an ending one)", function () {
72
+ jasmine.getFixtures().fixturesPath = 'a path ending with slash/'
73
+ expect(jasmine.getFixtures().makeFixtureUrl_(fixtureUrl)).toEqual('a path ending with slash/'+fixtureUrl)
74
+ })
75
+
76
+ it("should use the configured fixtures path concatenating it to the requested url (concatenating a slash if it doesn't have an ending one)", function () {
77
+ jasmine.getFixtures().fixturesPath = 'a path without an ending slash'
78
+ expect(jasmine.getFixtures().makeFixtureUrl_(fixtureUrl)).toEqual('a path without an ending slash/'+fixtureUrl)
79
+ })
80
+ })
81
+
82
+ describe("load", function () {
83
+ it("should insert fixture HTML into container", function () {
84
+ jasmine.getFixtures().load(fixtureUrl)
85
+ expect(fixturesContainer().html()).toEqual(ajaxData)
86
+ })
87
+
88
+ it("should insert duplicated fixture HTML into container when the same url is provided twice in a single call", function () {
89
+ jasmine.getFixtures().load(fixtureUrl, fixtureUrl)
90
+ expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
91
+ })
92
+
93
+ it("should insert merged HTML of two fixtures into container when two different urls are provided in a single call", function () {
94
+ jasmine.getFixtures().load(fixtureUrl, anotherFixtureUrl)
95
+ expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
96
+ })
97
+
98
+ it("should have shortcut global method loadFixtures", function () {
99
+ loadFixtures(fixtureUrl, anotherFixtureUrl)
100
+ expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
101
+ })
102
+
103
+ describe("when fixture container does not exist", function () {
104
+ it("should automatically create fixtures container and append it to DOM", function () {
105
+ jasmine.getFixtures().load(fixtureUrl)
106
+ expect(fixturesContainer().size()).toEqual(1)
107
+ })
108
+ })
109
+
110
+ describe("when fixture container exists", function () {
111
+ beforeEach(function () {
112
+ appendFixturesContainerToDom()
113
+ })
114
+
115
+ it("should replace it with new content", function () {
116
+ jasmine.getFixtures().load(fixtureUrl)
117
+ expect(fixturesContainer().html()).toEqual(ajaxData)
118
+ })
119
+ })
120
+
121
+ describe("when fixture contains an inline <script> tag", function (){
122
+ beforeEach(function (){
123
+ ajaxData = "<div><a id=\"anchor_01\"></a><script>$(function (){ $('#anchor_01').addClass('foo')});</script></div>"
124
+ })
125
+
126
+ it("should execute the inline javascript after the fixture has been inserted into the body", function (){
127
+ jasmine.getFixtures().load(fixtureUrl)
128
+ expect($("#anchor_01")).toHaveClass('foo')
129
+ })
130
+ })
131
+ })
132
+
133
+ describe("appendLoad", function () {
134
+ beforeEach(function (){
135
+ ajaxData = 'some ajax data'
136
+ })
137
+
138
+ it("should insert fixture HTML into container", function () {
139
+ jasmine.getFixtures().appendLoad(fixtureUrl)
140
+ expect(fixturesContainer().html()).toEqual(ajaxData)
141
+ })
142
+
143
+ it("should insert duplicated fixture HTML into container when the same url is provided twice in a single call", function () {
144
+ jasmine.getFixtures().appendLoad(fixtureUrl, fixtureUrl)
145
+ expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
146
+ })
147
+
148
+ it("should insert merged HTML of two fixtures into container when two different urls are provided in a single call", function () {
149
+ jasmine.getFixtures().appendLoad(fixtureUrl, anotherFixtureUrl)
150
+ expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
151
+ })
152
+
153
+ it("should have shortcut global method loadFixtures", function () {
154
+ appendLoadFixtures(fixtureUrl, anotherFixtureUrl)
155
+ expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
156
+ })
157
+
158
+ it("should automatically create fixtures container and append it to DOM", function () {
159
+ jasmine.getFixtures().appendLoad(fixtureUrl)
160
+ expect(fixturesContainer().size()).toEqual(1)
161
+ })
162
+
163
+ describe("with a prexisting fixture",function (){
164
+ beforeEach(function () {
165
+ jasmine.getFixtures().appendLoad(fixtureUrl)
166
+ })
167
+
168
+ it("should add new content", function () {
169
+ jasmine.getFixtures().appendLoad(fixtureUrl)
170
+ expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
171
+ })
172
+
173
+ it("should not add a new fixture container", function (){
174
+ jasmine.getFixtures().appendLoad(fixtureUrl)
175
+ expect(fixturesContainer().size()).toEqual(1)
176
+ })
177
+ })
178
+
179
+ describe("when fixture contains an inline <script> tag", function (){
180
+ beforeEach(function (){
181
+ ajaxData = "<div><a id=\"anchor_01\"></a><script>$(function (){ $('#anchor_01').addClass('foo')});</script></div>"
182
+ })
183
+
184
+ it("should execute the inline javascript after the fixture has been inserted into the body", function (){
185
+ jasmine.getFixtures().appendLoad(fixtureUrl)
186
+ expect($("#anchor_01")).toHaveClass('foo')
187
+ })
188
+ })
189
+ })
190
+
191
+ describe("preload", function () {
192
+ describe("read after preload", function () {
193
+ it("should go from cache", function () {
194
+ jasmine.getFixtures().preload(fixtureUrl, anotherFixtureUrl)
195
+ jasmine.getFixtures().read(fixtureUrl, anotherFixtureUrl)
196
+ expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(2)
197
+ })
198
+
199
+ it("should return correct HTMLs", function () {
200
+ jasmine.getFixtures().preload(fixtureUrl, anotherFixtureUrl)
201
+ var html = jasmine.getFixtures().read(fixtureUrl, anotherFixtureUrl)
202
+ expect(html).toEqual(ajaxData + ajaxData)
203
+ })
204
+ })
205
+
206
+ it("should not preload the same fixture twice", function () {
207
+ jasmine.getFixtures().preload(fixtureUrl, fixtureUrl)
208
+ expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(1)
209
+ })
210
+
211
+ it("should have shortcut global method preloadFixtures", function () {
212
+ preloadFixtures(fixtureUrl, anotherFixtureUrl)
213
+ jasmine.getFixtures().read(fixtureUrl, anotherFixtureUrl)
214
+ expect(jasmine.Fixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(2)
215
+ })
216
+ })
217
+
218
+ describe("set", function () {
219
+ var html = '<div>some HTML</div>'
220
+
221
+ it("should insert HTML into container", function () {
222
+ jasmine.getFixtures().set(html)
223
+ expect(fixturesContainer().html()).toEqual(jasmine.jQuery.browserTagCaseIndependentHtml(html))
224
+ })
225
+
226
+ it("should insert jQuery element into container", function () {
227
+ jasmine.getFixtures().set($(html))
228
+ expect(fixturesContainer().html()).toEqual(jasmine.jQuery.browserTagCaseIndependentHtml(html))
229
+ })
230
+
231
+ describe("when fixture container does not exist", function () {
232
+ it("should automatically create fixtures container and append it to DOM", function () {
233
+ jasmine.getFixtures().set(html)
234
+ expect(fixturesContainer().size()).toEqual(1)
235
+ })
236
+
237
+ it("should return the fixture container", function () {
238
+ var container = jasmine.getFixtures().set(html)
239
+ expect(container).toExist()
240
+ expect(container[0]).toEqual(fixturesContainer()[0])
241
+ })
242
+ })
243
+
244
+ describe("when fixture container exists", function () {
245
+ beforeEach(function () {
246
+ appendFixturesContainerToDom()
247
+ })
248
+
249
+ it("should replace it with new content", function () {
250
+ jasmine.getFixtures().set(html)
251
+ expect(fixturesContainer().html()).toEqual(jasmine.jQuery.browserTagCaseIndependentHtml(html))
252
+ })
253
+
254
+ it("should return the fixture container", function (){
255
+ var container = jasmine.getFixtures().set(html)
256
+ expect(container).toExist()
257
+ expect(container[0]).toEqual(fixturesContainer()[0])
258
+ })
259
+ })
260
+ })
261
+
262
+ describe("setFixtures", function () {
263
+ var html = '<div>some HTML</div>'
264
+
265
+ it("should be a shortcut global method", function () {
266
+ setFixtures(html)
267
+ expect(fixturesContainer().html()).toEqual(jasmine.jQuery.browserTagCaseIndependentHtml(html))
268
+ })
269
+
270
+ it("should return the fixture container", function () {
271
+ var container = setFixtures(html)
272
+ expect(container).toExist()
273
+ expect(container[0]).toEqual(fixturesContainer()[0])
274
+ })
275
+ })
276
+
277
+ describe("appendSet",function (){
278
+ var html = '<div>some HTML</div>'
279
+ it("should insert HTML into container", function () {
280
+ jasmine.getFixtures().appendSet(html)
281
+ expect(fixturesContainer().html()).toEqual(jasmine.jQuery.browserTagCaseIndependentHtml(html))
282
+ })
283
+
284
+ it("should insert jQuery element into container", function () {
285
+ jasmine.getFixtures().appendSet($(html))
286
+ expect(fixturesContainer().html()).toEqual(jasmine.jQuery.browserTagCaseIndependentHtml(html))
287
+ })
288
+
289
+ it("should have shortcut global method setFixtures", function () {
290
+ appendSetFixtures(html)
291
+ expect(fixturesContainer().html()).toEqual(jasmine.jQuery.browserTagCaseIndependentHtml(html))
292
+ })
293
+
294
+ describe("when fixture container does not exist", function () {
295
+ it("should automatically create fixtures container and append it to DOM", function () {
296
+ jasmine.getFixtures().appendSet(html)
297
+ expect(fixturesContainer().size()).toEqual(1)
298
+ })
299
+ })
300
+
301
+ describe("when fixture container exists", function () {
302
+ beforeEach(function () {
303
+ jasmine.getFixtures().appendSet(html)
304
+ })
305
+
306
+ it("should add new content", function () {
307
+ jasmine.getFixtures().appendSet(html)
308
+ expect(fixturesContainer().html()).toEqual(jasmine.jQuery.browserTagCaseIndependentHtml(html)+jasmine.jQuery.browserTagCaseIndependentHtml(html))
309
+ })
310
+ })
311
+ })
312
+
313
+ describe("sandbox", function () {
314
+ describe("with no attributes parameter specified", function () {
315
+ it("should create DIV with id #sandbox", function () {
316
+ expect(jasmine.getFixtures().sandbox().html()).toEqual($('<div id="sandbox" />').html())
317
+ })
318
+ })
319
+
320
+ describe("with attributes parameter specified", function () {
321
+ it("should create DIV with attributes", function () {
322
+ var attributes = {
323
+ attr1: 'attr1 value',
324
+ attr2: 'attr2 value'
325
+ }
326
+ var element = $(jasmine.getFixtures().sandbox(attributes))
327
+
328
+ expect(element.attr('attr1')).toEqual(attributes.attr1)
329
+ expect(element.attr('attr2')).toEqual(attributes.attr2)
330
+ })
331
+
332
+ it("should be able to override id by setting it as attribute", function () {
333
+ var idOverride = 'overridden'
334
+ var element = $(jasmine.getFixtures().sandbox({id: idOverride}))
335
+ expect(element.attr('id')).toEqual(idOverride)
336
+ })
337
+ })
338
+
339
+ it("should have shortcut global method sandbox", function () {
340
+ var attributes = {
341
+ id: 'overridden'
342
+ }
343
+ var element = $(sandbox(attributes))
344
+ expect(element.attr('id')).toEqual(attributes.id)
345
+ })
346
+ })
347
+
348
+ describe("cleanUp", function () {
349
+ it("should remove fixtures container from DOM", function () {
350
+ appendFixturesContainerToDom()
351
+ jasmine.getFixtures().cleanUp()
352
+ expect(fixturesContainer().size()).toEqual(0)
353
+ })
354
+ })
355
+
356
+ // WARNING: this block requires its two tests to be invoked in order!
357
+ // (Really ugly solution, but unavoidable in this specific case)
358
+ describe("automatic DOM clean-up between tests", function () {
359
+ // WARNING: this test must be invoked first (before 'SECOND TEST')!
360
+ it("FIRST TEST: should pollute the DOM", function () {
361
+ appendFixturesContainerToDom()
362
+ })
363
+
364
+ // WARNING: this test must be invoked second (after 'FIRST TEST')!
365
+ it("SECOND TEST: should see the DOM in a blank state", function () {
366
+ expect(fixturesContainer().size()).toEqual(0)
367
+ })
368
+ })
369
+ })
370
+
371
+ describe("jasmine.Fixtures using real AJAX call", function () {
372
+ var defaultFixturesPath
373
+
374
+ beforeEach(function () {
375
+ defaultFixturesPath = jasmine.getFixtures().fixturesPath
376
+ jasmine.getFixtures().fixturesPath = 'spec/fixtures'
377
+ })
378
+
379
+ afterEach(function () {
380
+ jasmine.getFixtures().fixturesPath = defaultFixturesPath
381
+ })
382
+
383
+ describe("when fixture file exists", function () {
384
+ var fixtureUrl = "real_non_mocked_fixture.html"
385
+
386
+ it("should load content of fixture file", function () {
387
+ var fixtureContent = jasmine.getFixtures().read(fixtureUrl)
388
+ expect(fixtureContent).toEqual('<div id="real_non_mocked_fixture"></div>')
389
+ })
390
+ })
391
+
392
+ describe("when fixture file does not exist", function () {
393
+ var fixtureUrl = "not_existing_fixture"
394
+
395
+ it("should throw an exception", function () {
396
+ expect(function () {
397
+ jasmine.getFixtures().read(fixtureUrl)
398
+ }).toThrow()
399
+ })
400
+ })
401
+
402
+ describe("when fixture contains an <script src='to/your/source'> tag", function () {
403
+ var fixtureUrl = "fixture_with_javascript.html"
404
+
405
+ it("should load content of fixture file and javascript and bind events", function () {
406
+ jasmine.getFixtures().load(fixtureUrl)
407
+ $('#anchor_01').click()
408
+ expect($("#anchor_01")).toHaveClass('foo')
409
+ })
410
+
411
+ it("should load multiple javascripts and bind events in fixture", function () {
412
+ jasmine.getFixtures().load(fixtureUrl)
413
+ $('#anchor_01').click()
414
+ $('#anchor_01').trigger('hover')
415
+ expect($("#anchor_01")).toHaveClass('foo')
416
+ expect($("#anchor_01")).toHaveClass('bar')
417
+ })
418
+ })
419
+
420
+ describe("when fixture contains a <script> tag without a src attribute", function () {
421
+ var fixtureUrl = "fixture_with_javascript_block.html"
422
+
423
+ it("should load the fixture and ignore the script tag", function () {
424
+ jasmine.getFixtures().load(fixtureUrl)
425
+ expect($("#anchor_01").length).toBe(1)
426
+ })
427
+ })
428
+
429
+ describe("When the fixture contains a HTML 5 style checked checkbox", function () {
430
+ var fixtureUrl = "fixture_with_checkbox_with_checked.html"
431
+
432
+ it("Then the fixture is loaded successfully", function () {
433
+ jasmine.getFixtures().load(fixtureUrl)
434
+ expect('#' + jasmine.getFixtures().containerId).toContainElement('#checked-box')
435
+ })
436
+ })
437
+ })
438
+
439
+ describe("jQuery matcher", function () {
440
+ describe("when invoked multiple times on the same fixture", function () {
441
+ it("should not reset fixture after first call", function () {
442
+ setFixtures(sandbox())
443
+ expect($('#sandbox')).toExist()
444
+ expect($('#sandbox')).toExist()
445
+ })
446
+ })
447
+
448
+ describe("toHaveClass", function () {
449
+ var className = "some-class"
450
+
451
+ it("should pass when class found", function () {
452
+ setFixtures(sandbox({'class': className}))
453
+ expect($('#sandbox')).toHaveClass(className)
454
+ expect($('#sandbox').get(0)).toHaveClass(className)
455
+ })
456
+
457
+ it("should pass negated when class not found", function () {
458
+ setFixtures(sandbox())
459
+ expect($('#sandbox')).not.toHaveClass(className)
460
+ expect($('#sandbox').get(0)).not.toHaveClass(className)
461
+ })
462
+
463
+ it("should not crash when documentElement provided", function (){
464
+ var doc = $(document.documentElement).addClass(className)
465
+ expect(doc).toHaveClass(className)
466
+ doc.removeClass(className)
467
+ expect(doc).not.toHaveClass(className)
468
+ })
469
+ })
470
+
471
+ describe("toHaveAttr", function () {
472
+ var attributeName = 'attr1'
473
+ var attributeValue = 'attr1 value'
474
+ var wrongAttributeName = 'wrongName'
475
+ var wrongAttributeValue = 'wrong value'
476
+
477
+ beforeEach(function () {
478
+ var attributes = {}
479
+ attributes[attributeName] = attributeValue
480
+ setFixtures(sandbox(attributes))
481
+ })
482
+
483
+ describe("when only attribute name is provided", function () {
484
+ it("should pass if element has matching attribute", function () {
485
+ expect($('#sandbox')).toHaveAttr(attributeName)
486
+ expect($('#sandbox').get(0)).toHaveAttr(attributeName)
487
+ })
488
+
489
+ it("should pass negated if element has no matching attribute", function () {
490
+ expect($('#sandbox')).not.toHaveAttr(wrongAttributeName)
491
+ expect($('#sandbox').get(0)).not.toHaveAttr(wrongAttributeName)
492
+ })
493
+ })
494
+
495
+ describe("when both attribute name and value are provided", function () {
496
+ it("should pass if element has matching attribute with matching value", function () {
497
+ expect($('#sandbox')).toHaveAttr(attributeName, attributeValue)
498
+ expect($('#sandbox').get(0)).toHaveAttr(attributeName, attributeValue)
499
+ })
500
+
501
+ it("should pass negated if element has matching attribute but with wrong value", function () {
502
+ expect($('#sandbox')).not.toHaveAttr(attributeName, wrongAttributeValue)
503
+ expect($('#sandbox').get(0)).not.toHaveAttr(attributeName, wrongAttributeValue)
504
+ })
505
+
506
+ it("should pass negated if element has no matching attribute", function () {
507
+ expect($('#sandbox')).not.toHaveAttr(wrongAttributeName, attributeValue)
508
+ expect($('#sandbox').get(0)).not.toHaveAttr(wrongAttributeName, attributeValue)
509
+ })
510
+ })
511
+ })
512
+
513
+ describe("toHaveProp", function () {
514
+ var propertyName = 'prop1'
515
+ var propertyValue = 'prop1 value'
516
+ var wrongPropertyName = 'wrongName'
517
+ var wrongPropertyValue = 'wrong value'
518
+
519
+ beforeEach(function () {
520
+ setFixtures(sandbox())
521
+ var element = $('#sandbox')[0]
522
+ element[propertyName] = propertyValue
523
+ })
524
+
525
+ describe("when only property name is provided", function () {
526
+ it("should pass if element has matching property", function () {
527
+ expect($('#sandbox')).toHaveProp(propertyName)
528
+ })
529
+
530
+ it("should pass negated if element has no matching property", function () {
531
+ expect($('#sandbox')).not.toHaveProp(wrongPropertyName)
532
+ })
533
+ })
534
+
535
+ describe("when both property name and value are provided", function () {
536
+ it("should pass if element has matching property with matching value", function () {
537
+ expect($('#sandbox')).toHaveProp(propertyName, propertyValue)
538
+ })
539
+
540
+ it("should pass negated if element has matching property but with wrong value", function () {
541
+ expect($('#sandbox')).not.toHaveProp(propertyName, wrongPropertyValue)
542
+ })
543
+
544
+ it("should pass negated if element has no matching property", function () {
545
+ expect($('#sandbox')).not.toHaveProp(wrongPropertyName, propertyValue)
546
+ })
547
+ })
548
+ })
549
+
550
+ describe("toHaveCss", function (){
551
+ beforeEach(function (){
552
+ setFixtures(sandbox())
553
+ })
554
+
555
+ it("should pass if the element has matching css", function (){
556
+ $("#sandbox").css("display", "none")
557
+ $("#sandbox").css("margin-left", "10px")
558
+ expect($("#sandbox")).toHaveCss({display: "none", "margin-left": "10px"})
559
+ })
560
+
561
+ it("should be able to check a subset of element's css", function (){
562
+ $("#sandbox").css("display", "none")
563
+ $("#sandbox").css("margin-left", "10px")
564
+ expect($("#sandbox")).toHaveCss({"margin-left": "10px"})
565
+ })
566
+
567
+ it("should fail if the element doesn't have matching css", function (){
568
+ $("#sandbox").css("display", "none")
569
+ $("#sandbox").css("margin-left", "20px")
570
+ expect($("#sandbox")).not.toHaveCss({display: "none", "margin-left": "10px"})
571
+ })
572
+
573
+ it("should pass if the css property is auto and you check that property for auto", function (){
574
+ $("#sandbox").css("height", "auto");
575
+ $("#sandbox").css("margin-left", "auto");
576
+ $("#sandbox").css("display", "none");
577
+ expect($("#sandbox")).toHaveCss({height: 'auto', 'margin-left': "auto", display: "none"});
578
+ })
579
+ })
580
+
581
+ describe("toHaveId", function () {
582
+ beforeEach(function () {
583
+ setFixtures(sandbox())
584
+ })
585
+
586
+ it("should pass if id attribute matches expectation", function () {
587
+ expect($('#sandbox')).toHaveId('sandbox')
588
+ expect($('#sandbox').get(0)).toHaveId('sandbox')
589
+ })
590
+
591
+ it("should pass negated if id attribute does not match expectation", function () {
592
+ expect($('#sandbox')).not.toHaveId('wrongId')
593
+ expect($('#sandbox').get(0)).not.toHaveId('wrongId')
594
+ })
595
+
596
+ it("should pass negated if id attribute is not present", function () {
597
+ expect($('<div />')).not.toHaveId('sandbox')
598
+ expect($('<div />').get(0)).not.toHaveId('sandbox')
599
+ })
600
+ })
601
+
602
+ describe("toHaveHtml", function () {
603
+ var html = '<div>some text</div>'
604
+ var wrongHtml = '<span>some text</span>'
605
+ var element
606
+
607
+ beforeEach(function () {
608
+ element = $('<div/>').append(html)
609
+ })
610
+
611
+ it("should pass when html matches", function () {
612
+ expect(element).toHaveHtml(html)
613
+ expect(element.get(0)).toHaveHtml(html)
614
+ })
615
+
616
+ it("should pass negated when html does not match", function () {
617
+ expect(element).not.toHaveHtml(wrongHtml)
618
+ expect(element.get(0)).not.toHaveHtml(wrongHtml)
619
+ })
620
+ })
621
+
622
+ describe("toContainHtml", function (){
623
+ beforeEach(function (){
624
+ setFixtures(sandbox())
625
+ })
626
+
627
+ it("should pass when the element contains given html", function (){
628
+ $("#sandbox").html("<div><ul></ul><h1>foo</h1></div>")
629
+ expect($("#sandbox")).toContainHtml("<ul></ul>")
630
+ })
631
+
632
+ it("should fail when the element doesn't contain given html", function (){
633
+ $("#sandbox").html("<div><h1>foo</h1></div>")
634
+ expect($("#sandbox")).not.toContainHtml("<ul></ul>")
635
+ })
636
+ })
637
+
638
+ describe("toHaveText", function () {
639
+ var text = 'some text'
640
+ var wrongText = 'some other text'
641
+ var element
642
+
643
+ beforeEach(function () {
644
+ element = $('<div/>').append(text)
645
+ })
646
+
647
+ it("should pass when text matches", function () {
648
+ expect(element).toHaveText(text)
649
+ expect(element.get(0)).toHaveText(text)
650
+ })
651
+
652
+ it("should ignore surrounding whitespace in the element", function () {
653
+ element = $('<div>\n' + text + '\n</div>')
654
+ expect(element).toHaveText(text)
655
+ expect(element.get(0)).toHaveText(text)
656
+ })
657
+
658
+ it("should match with surrounding whitespace in the input", function () {
659
+ element = $('<div>\n' + text + '\n</div>')
660
+ expect(element).toHaveText('\n' + text + '\n')
661
+ expect(element.get(0)).toHaveText(text)
662
+ })
663
+
664
+ it("should pass negated when text does not match", function () {
665
+ expect(element).not.toHaveText(wrongText)
666
+ expect(element.get(0)).not.toHaveText(wrongText)
667
+ })
668
+
669
+ it('should pass when text matches a regex', function () {
670
+ expect(element).toHaveText(/some/)
671
+ expect(element.get(0)).toHaveText(/some/)
672
+ })
673
+
674
+ it('should pass negated when text does not match a regex', function () {
675
+ expect(element).not.toHaveText(/other/)
676
+ expect(element.get(0)).not.toHaveText(/other/)
677
+ })
678
+ })
679
+
680
+ describe("toContainText", function () {
681
+ var text = 'some pretty long bits of text'
682
+ var textPart = 'pret'
683
+ var wrongText = 'some other text'
684
+ var element
685
+
686
+ beforeEach(function () {
687
+ element = $('<div/>').append(text)
688
+ })
689
+
690
+ it("should pass when text contains text part", function () {
691
+ expect(element).toContainText(textPart)
692
+ expect(element.get(0)).toContainText(textPart)
693
+ })
694
+
695
+ it("should pass negated when text does not match", function () {
696
+ expect(element).not.toContainText(wrongText)
697
+ expect(element.get(0)).not.toContainText(wrongText)
698
+ })
699
+
700
+ it('should pass when text matches a regex', function () {
701
+ expect(element).toContainText(/some/)
702
+ expect(element.get(0)).toContainText(/some/)
703
+ })
704
+
705
+ it('should pass negated when text does not match a regex', function () {
706
+ expect(element).not.toContainText(/other/)
707
+ expect(element.get(0)).not.toContainText(/other/)
708
+ })
709
+ })
710
+
711
+ describe("toHaveValue", function () {
712
+ var value = 'some value'
713
+ var differentValue = 'different value'
714
+
715
+ beforeEach(function () {
716
+ setFixtures($('<input id="sandbox" type="text" />').val(value))
717
+ })
718
+
719
+ it("should pass if value matches expectation", function () {
720
+ expect($('#sandbox')).toHaveValue(value)
721
+ expect($('#sandbox').get(0)).toHaveValue(value)
722
+ })
723
+
724
+ it("should pass negated if value does not match expectation", function () {
725
+ expect($('#sandbox')).not.toHaveValue(differentValue)
726
+ expect($('#sandbox').get(0)).not.toHaveValue(differentValue)
727
+ })
728
+
729
+ it("should pass negated if value attribute is not present", function () {
730
+ expect(sandbox()).not.toHaveValue(value)
731
+ expect(sandbox().get(0)).not.toHaveValue(value)
732
+ })
733
+
734
+ it("should not coerce types", function (){
735
+ setFixtures($('<input id="sandbox" type="text" />').val(""))
736
+ expect($('#sandbox')).not.toHaveValue(0)
737
+ })
738
+ })
739
+
740
+ describe("toHaveData", function () {
741
+ var key = 'some key'
742
+ var value = 'some value'
743
+ var wrongKey = 'wrong key'
744
+ var wrongValue = 'wrong value'
745
+
746
+ beforeEach(function () {
747
+ setFixtures(sandbox().data(key, value))
748
+ })
749
+
750
+ describe("when only key is provided", function () {
751
+ it("should pass if element has matching data key", function () {
752
+ expect($('#sandbox')).toHaveData(key)
753
+ expect($('#sandbox').get(0)).toHaveData(key)
754
+ })
755
+
756
+ it("should pass negated if element has no matching data key", function () {
757
+ expect($('#sandbox')).not.toHaveData(wrongKey)
758
+ expect($('#sandbox').get(0)).not.toHaveData(wrongKey)
759
+ })
760
+ })
761
+
762
+ describe("when both key and value are provided", function () {
763
+ it("should pass if element has matching key with matching value", function () {
764
+ expect($('#sandbox')).toHaveData(key, value)
765
+ expect($('#sandbox').get(0)).toHaveData(key, value)
766
+ })
767
+
768
+ it("should pass negated if element has matching key but with wrong value", function () {
769
+ expect($('#sandbox')).not.toHaveData(key, wrongValue)
770
+ expect($('#sandbox').get(0)).not.toHaveData(key, wrongValue)
771
+ })
772
+
773
+ it("should pass negated if element has no matching key", function () {
774
+ expect($('#sandbox')).not.toHaveData(wrongKey, value)
775
+ expect($('#sandbox').get(0)).not.toHaveData(wrongKey, value)
776
+ })
777
+ })
778
+
779
+ describe("when the value is a JSON object", function() {
780
+ var objectKey = 'object-key'
781
+ var objectValue = {'foo': 'bar'}
782
+ var objectString = '[object Object]'
783
+
784
+ beforeEach(function() {
785
+ setFixtures(sandbox().data(objectKey, objectValue))
786
+ })
787
+
788
+ it("should pass if element has matching key with matching value", function () {
789
+ expect($('#sandbox')).toHaveData(objectKey, objectValue)
790
+ expect($('#sandbox').get(0)).toHaveData(objectKey, objectValue)
791
+ })
792
+
793
+ it("should not pass if element has matching key but the value is just a string representation of the value", function () {
794
+ expect($('#sandbox')).not.toHaveData(objectKey, objectString)
795
+ expect($('#sandbox').get(0)).not.toHaveData(objectKey, objectString)
796
+ })
797
+
798
+ it("should not pass if element has matching key but the value is just a string representation of the value", function () {
799
+ setFixtures('<div id="foo" div data-bar="[object Object]"></div>')
800
+ expect($('#foo')).not.toHaveData('bar', { 'answer': 42 })
801
+ expect($('#foo').get(0)).not.toHaveData('bar', { 'answer': 42 })
802
+ })
803
+ })
804
+ })
805
+
806
+ describe("toBeVisible", function () {
807
+ it("should pass on visible element", function () {
808
+ setFixtures(sandbox())
809
+ expect($('#sandbox')).toBeVisible()
810
+ expect($('#sandbox').get(0)).toBeVisible()
811
+ })
812
+
813
+ it("should pass negated on hidden element", function () {
814
+ setFixtures(sandbox().hide())
815
+ expect($('#sandbox')).not.toBeVisible()
816
+ expect($('#sandbox').get(0)).not.toBeVisible()
817
+ })
818
+ })
819
+
820
+ describe("toBeHidden", function () {
821
+ it("should pass on hidden element", function () {
822
+ setFixtures(sandbox().hide())
823
+ expect($('#sandbox')).toBeHidden()
824
+ expect($('#sandbox').get(0)).toBeHidden()
825
+ })
826
+
827
+ it("should pass negated on visible element", function () {
828
+ setFixtures(sandbox())
829
+ expect($('#sandbox')).not.toBeHidden()
830
+ expect($('#sandbox').get(0)).not.toBeHidden()
831
+ })
832
+ })
833
+
834
+ describe("toBeSelected", function () {
835
+ beforeEach(function () {
836
+ setFixtures('\
837
+ <select>\n\
838
+ <option id="not-selected"></option>\n\
839
+ <option id="selected" selected="selected"></option>\n\
840
+ </select>')
841
+ })
842
+
843
+ it("should pass on selected element", function () {
844
+ expect($('#selected')).toBeSelected()
845
+ expect($('#selected').get(0)).toBeSelected()
846
+ })
847
+
848
+ it("should pass negated on not selected element", function () {
849
+ expect($('#not-selected')).not.toBeSelected()
850
+ expect($('#not-selected').get(0)).not.toBeSelected()
851
+ })
852
+ })
853
+
854
+ describe("toBeChecked", function () {
855
+ beforeEach(function () {
856
+ setFixtures('\
857
+ <input type="checkbox" id="checked" checked="checked" />\n\
858
+ <input type="checkbox" id="not-checked" />\n\
859
+ <input type="radio" name="radio-name" id="radio-checked" checked="checked" />')
860
+ })
861
+
862
+ it("should pass on checked element", function () {
863
+ expect($('#checked')).toBeChecked()
864
+ expect($('#checked').get(0)).toBeChecked()
865
+ })
866
+
867
+ it("should pass negated on not checked element", function () {
868
+ expect($('#not-checked')).not.toBeChecked()
869
+ expect($('#not-checked').get(0)).not.toBeChecked()
870
+ })
871
+
872
+ it("shoud not change the checked status of a radio button", function () {
873
+ expect($('#radio-checked')).toBeChecked()
874
+ expect($('#radio-checked')).toBeChecked()
875
+ })
876
+ })
877
+
878
+ describe("toBeEmpty", function () {
879
+ it("should pass on empty element", function () {
880
+ setFixtures(sandbox())
881
+ expect($('#sandbox')).toBeEmpty()
882
+ expect($('#sandbox').get(0)).toBeEmpty()
883
+ })
884
+
885
+ it("should pass negated on element with a tag inside", function () {
886
+ setFixtures(sandbox().html($('<span />')))
887
+ expect($('#sandbox')).not.toBeEmpty()
888
+ expect($('#sandbox').get(0)).not.toBeEmpty()
889
+ })
890
+
891
+ it("should pass negated on element with text inside", function () {
892
+ setFixtures(sandbox().text('some text'))
893
+ expect($('#sandbox')).not.toBeEmpty()
894
+ expect($('#sandbox').get(0)).not.toBeEmpty()
895
+ })
896
+ })
897
+
898
+ describe("toBeInDOM", function () {
899
+ it("should pass on elements in the DOM", function () {
900
+ setFixtures(sandbox())
901
+ expect($('#sandbox')).toBeInDOM()
902
+ })
903
+
904
+ it("should pass negated on elements not in the DOM", function () {
905
+ expect($('<div>')).not.toBeInDOM()
906
+ })
907
+ })
908
+
909
+ describe("toExist", function () {
910
+ it("should pass on visible element", function () {
911
+ setFixtures(sandbox())
912
+ expect($('#sandbox')).toExist()
913
+ expect($('#sandbox').get(0)).toExist()
914
+ })
915
+
916
+ it("should pass on hidden element", function () {
917
+ setFixtures(sandbox().hide())
918
+ expect($('#sandbox')).toExist()
919
+ expect($('#sandbox').get(0)).toExist()
920
+ })
921
+
922
+ it("should pass negated if element is not present in DOM", function () {
923
+ expect($('#non-existent-element')).not.toExist()
924
+ expect($('#non-existent-element').get(0)).not.toExist()
925
+ })
926
+ })
927
+
928
+ describe("toHaveLength", function () {
929
+ it("should pass on an object with more than zero items", function () {
930
+ var $three = $('<div>').add('<span>').add("<pre>")
931
+ expect($three.length).toBe(3)
932
+ expect($three).toHaveLength(3)
933
+ })
934
+
935
+ it("should pass negated on an object with more than zero items", function () {
936
+ var $three = $('<div>').add('<span>').add("<pre>")
937
+ expect($three.length).toBe(3)
938
+ expect($three).not.toHaveLength(2)
939
+ })
940
+
941
+ it("should pass on an object with zero items", function () {
942
+ var $zero = $()
943
+ expect($zero.length).toBe(0)
944
+ expect($zero).toHaveLength(0)
945
+ })
946
+
947
+ it("should pass negated on an object with zero items", function () {
948
+ var $zero = $()
949
+ expect($zero.length).not.toBe(1)
950
+ expect($zero).not.toHaveLength(1)
951
+ })
952
+ })
953
+
954
+ describe("toEqual", function () {
955
+ beforeEach(function () {
956
+ setFixtures(sandbox())
957
+ })
958
+
959
+ it("should pass if object matches selector", function () {
960
+ expect($('#sandbox')).toEqual('#sandbox')
961
+ expect($('#sandbox').get(0)).toEqual('#sandbox')
962
+ })
963
+
964
+ it("should pass negated if object does not match selector", function () {
965
+ expect($('#sandbox')).not.toEqual('#wrong-id')
966
+ expect($('#sandbox').get(0)).not.toEqual('#wrong-id')
967
+ })
968
+ })
969
+
970
+ describe("toContainElement", function () {
971
+ beforeEach(function () {
972
+ setFixtures(sandbox().html('<span />'))
973
+ })
974
+
975
+ it("should pass if object contains selector", function () {
976
+ expect($('#sandbox')).toContainElement('span')
977
+ expect($('#sandbox').get(0)).toContainElement('span')
978
+ })
979
+
980
+ it("should pass negated if object does not contain selector", function () {
981
+ expect($('#sandbox')).not.toContainElement('div')
982
+ expect($('#sandbox').get(0)).not.toContainElement('div')
983
+ })
984
+ })
985
+
986
+ describe("toBeMatchedBy", function () {
987
+ beforeEach(function () {
988
+ setFixtures(sandbox().html('<span id="js-match"></span>'))
989
+ })
990
+
991
+ it("should pass if selector contains given selector", function () {
992
+ expect($('#sandbox span')).toBeMatchedBy('#js-match')
993
+ })
994
+
995
+ it("should pass negated if selector does not contain given selector", function () {
996
+ expect($('#sandbox span')).not.toBeMatchedBy('#js-match-not')
997
+ })
998
+ })
999
+
1000
+ describe("toBeDisabled", function () {
1001
+ beforeEach(function () {
1002
+ setFixtures('\
1003
+ <input type="text" disabled="disabled" id="disabled"/>\n\
1004
+ <input type="text" id="enabled"/>')
1005
+ })
1006
+
1007
+ it("should pass on disabled element", function () {
1008
+ expect($('#disabled')).toBeDisabled()
1009
+ expect($('#disabled').get(0)).toBeDisabled()
1010
+ })
1011
+
1012
+ it("should pass negated on not selected element", function () {
1013
+ expect($('#enabled')).not.toBeDisabled()
1014
+ expect($('#enabled').get(0)).not.toBeDisabled()
1015
+ })
1016
+ })
1017
+
1018
+ describe("toBeFocused", function () {
1019
+ beforeEach(function () {
1020
+ setFixtures('<input type="text" id="focused"/>')
1021
+ })
1022
+
1023
+ it("should pass on focused element", function () {
1024
+ var el = $("#focused").focus()
1025
+ expect(el).toBeFocused()
1026
+ })
1027
+
1028
+ it("should pass negated on not focused element", function () {
1029
+ var el = $("#focused")
1030
+ expect(el).not.toBeFocused()
1031
+ })
1032
+ })
1033
+
1034
+ describe('toHaveBeenTriggeredOn', function () {
1035
+ var spyEvents = {}
1036
+ beforeEach(function () {
1037
+ setFixtures(sandbox().html('<a id="clickme">Click Me</a> <a id="otherlink">Other Link</a>'))
1038
+ spyEvents['#clickme'] = spyOnEvent($('#clickme'), 'click')
1039
+ spyOnEvent(document, 'click')
1040
+ spyOnEvent($('#otherlink'), 'click')
1041
+ })
1042
+
1043
+ it('should pass if the event was triggered on the object', function () {
1044
+ $('#clickme').click()
1045
+ expect('click').toHaveBeenTriggeredOn($('#clickme'))
1046
+ expect('click').toHaveBeenTriggeredOn('#clickme')
1047
+ })
1048
+
1049
+ it('should pass if the event was triggered on document', function () {
1050
+ $(document).click()
1051
+ expect('click').toHaveBeenTriggeredOn($(document))
1052
+ expect('click').toHaveBeenTriggeredOn(document)
1053
+ })
1054
+
1055
+ it('should pass if the event was triggered on a descendant of document', function () {
1056
+ $('#clickme').click()
1057
+ expect('click').toHaveBeenTriggeredOn($(document))
1058
+ expect('click').toHaveBeenTriggeredOn(document)
1059
+ })
1060
+
1061
+ it('should pass negated if the event was never triggered', function () {
1062
+ expect('click').not.toHaveBeenTriggeredOn($('#clickme'))
1063
+ expect('click').not.toHaveBeenTriggeredOn('#clickme')
1064
+ })
1065
+
1066
+ it('should pass negated if the event was triggered on another non-descendant object', function () {
1067
+ $('#otherlink').click()
1068
+ expect('click').not.toHaveBeenTriggeredOn($('#clickme'))
1069
+ expect('click').not.toHaveBeenTriggeredOn('#clickme')
1070
+ })
1071
+
1072
+ it('should pass if the event call count is incremented', function () {
1073
+ expect(spyEvents['#clickme'].calls.any()).toEqual(false);
1074
+ expect(spyEvents['#clickme'].calls.count()).toEqual(0);
1075
+ $('#clickme').click()
1076
+ expect('click').toHaveBeenTriggeredOn($('#clickme'))
1077
+ expect('click').toHaveBeenTriggeredOn('#clickme')
1078
+ expect(spyEvents['#clickme'].calls.count()).toEqual(1);
1079
+ expect(spyEvents['#clickme'].calls.any()).toEqual(true);
1080
+ $('#clickme').click()
1081
+ $('#clickme').click()
1082
+ expect(spyEvents['#clickme'].calls.count()).toEqual(3);
1083
+ expect(spyEvents['#clickme'].calls.any()).toEqual(true);
1084
+ })
1085
+ })
1086
+
1087
+ describe('toHaveBeenTriggeredOnAndWith', function () {
1088
+ beforeEach(function () {
1089
+ spyOnEvent(document, 'event')
1090
+ })
1091
+
1092
+ describe("when extra parameter is an object", function () {
1093
+ it('should pass if the event was triggered on the object with expected arguments', function () {
1094
+ $(document).trigger('event', { key1: "value1", key2: "value2" })
1095
+ expect('event').toHaveBeenTriggeredOnAndWith(document, { key1: "value1", key2: "value2" })
1096
+ })
1097
+
1098
+ it('should pass negated if the event was never triggered', function () {
1099
+ expect('event').not.toHaveBeenTriggeredOnAndWith(document, { key1: "value1", key2: "value2" })
1100
+ })
1101
+
1102
+ it('should pass negated if the event was triggered on another non-descendant object', function () {
1103
+ $(window).trigger('event', { key1: "value1", key2: "value2" })
1104
+ expect('event').not.toHaveBeenTriggeredOnAndWith(document, { key1: "value1", key2: "value2" })
1105
+ })
1106
+
1107
+ it('should pass negated if the event was triggered but the arguments do not match with the expected arguments', function () {
1108
+ $(document).trigger('event', { key1: "value1" })
1109
+ expect('event').not.toHaveBeenTriggeredOnAndWith(document, { key1: "value1", key2: "value2" })
1110
+ $(document).trigger('event', { key1: "value1", key2: "value2" })
1111
+ expect('event').not.toHaveBeenTriggeredOnAndWith(document, { key1: "value1" })
1112
+ $(document).trigger('event', { key1: "different value" })
1113
+ expect('event').not.toHaveBeenTriggeredOnAndWith(document, { key1: "value1" })
1114
+ $(document).trigger('event', { different_key: "value1" })
1115
+ expect('event').not.toHaveBeenTriggeredOnAndWith(document, { key1: "value1" })
1116
+ })
1117
+
1118
+ it('should pass if the arguments match using jasmine.objectContaining', function () {
1119
+ $(document).trigger('event', { key1: "value1", key2: "value2" })
1120
+ expect('event').toHaveBeenTriggeredOnAndWith(document, jasmine.objectContaining({ key1: "value1" }))
1121
+ })
1122
+ })
1123
+
1124
+ describe("when extra parameter is an array", function () {
1125
+ it('should pass if the event was triggered on the object with expected arguments', function () {
1126
+ $(document).trigger('event', [1, 2])
1127
+ expect('event').toHaveBeenTriggeredOnAndWith(document, [1, 2])
1128
+ })
1129
+
1130
+ it('should pass negated if the event was never triggered', function () {
1131
+ expect('event').not.toHaveBeenTriggeredOnAndWith(document, [1, 2])
1132
+ })
1133
+
1134
+ it('should pass negated if the event was triggered on another non-descendant object', function () {
1135
+ $(window).trigger('event', [1, 2])
1136
+ expect('event').not.toHaveBeenTriggeredOnAndWith(document, [1, 2])
1137
+ })
1138
+
1139
+ it('should pass negated if the event was triggered but the arguments do not match with the expected arguments', function () {
1140
+ $(document).trigger('event', [1])
1141
+ expect('event').not.toHaveBeenTriggeredOnAndWith(document, [1, 2])
1142
+ $(document).trigger('event', [1, 2])
1143
+ expect('event').not.toHaveBeenTriggeredOnAndWith(document, [1])
1144
+ $(document).trigger('event', [1, 3])
1145
+ expect('event').not.toHaveBeenTriggeredOnAndWith(document, [1, 2])
1146
+ })
1147
+ })
1148
+ })
1149
+
1150
+ describe('toHaveBeenTriggered', function () {
1151
+ var spyEvents = {}
1152
+ beforeEach(function () {
1153
+ setFixtures(sandbox().html('<a id="clickme">Click Me</a> <a id="otherlink">Other Link</a>'))
1154
+ spyEvents['#clickme'] = spyOnEvent($('#clickme'), 'click')
1155
+ spyEvents['#otherlink'] = spyOnEvent($('#otherlink'), 'click')
1156
+ })
1157
+
1158
+ it('should pass if the event was triggered on the object', function () {
1159
+ $('#clickme').click()
1160
+ expect(spyEvents['#clickme']).toHaveBeenTriggered()
1161
+ })
1162
+
1163
+ it('should pass negated if the event was never triggered', function () {
1164
+ expect(spyEvents['#clickme']).not.toHaveBeenTriggered()
1165
+ })
1166
+
1167
+ it('should pass negated if the event was triggered on another non-descendant object', function () {
1168
+ $('#otherlink').click()
1169
+ expect(spyEvents['#clickme']).not.toHaveBeenTriggered()
1170
+ })
1171
+
1172
+ it('should pass negated if the spy event was reset', function (){
1173
+ $('#clickme').click()
1174
+ expect('click').toHaveBeenTriggeredOn($('#clickme'))
1175
+ expect('click').toHaveBeenTriggeredOn('#clickme')
1176
+ expect(spyEvents['#clickme']).toHaveBeenTriggered()
1177
+ spyEvents['#clickme'].reset()
1178
+ expect('click').not.toHaveBeenTriggeredOn($('#clickme'))
1179
+ expect('click').not.toHaveBeenTriggeredOn('#clickme')
1180
+ expect(spyEvents['#clickme']).not.toHaveBeenTriggered()
1181
+ })
1182
+
1183
+ it('should pass if the event call count is incremented', function () {
1184
+ expect(spyEvents['#clickme'].calls.any()).toEqual(false);
1185
+ expect(spyEvents['#clickme'].calls.count()).toEqual(0);
1186
+ $('#clickme').click()
1187
+ expect(spyEvents['#clickme']).toHaveBeenTriggered()
1188
+ expect(spyEvents['#clickme'].calls.count()).toEqual(1);
1189
+ expect(spyEvents['#clickme'].calls.any()).toEqual(true);
1190
+ $('#clickme').click()
1191
+ $('#clickme').click()
1192
+ expect(spyEvents['#clickme'].calls.count()).toEqual(3);
1193
+ expect(spyEvents['#clickme'].calls.any()).toEqual(true);
1194
+ })
1195
+ })
1196
+
1197
+ describe('toHaveBeenPreventedOn', function () {
1198
+ beforeEach(function () {
1199
+ setFixtures(sandbox().html('<a id="clickme">Click Me</a> <a id="otherlink">Other Link</a>'))
1200
+ spyOnEvent($('#clickme'), 'click')
1201
+ spyOnEvent($('#otherlink'), 'click')
1202
+ })
1203
+
1204
+ it('should pass if the event was prevented on the object', function () {
1205
+ $('#clickme').bind('click', function (event) {
1206
+ event.preventDefault()
1207
+ })
1208
+ $('#clickme').click()
1209
+ expect('click').toHaveBeenPreventedOn($('#clickme'))
1210
+ expect('click').toHaveBeenPreventedOn('#clickme')
1211
+ })
1212
+
1213
+ it('should pass negated if the event was never prevented', function () {
1214
+ $('#clickme').click()
1215
+ expect('click').not.toHaveBeenPreventedOn($('#clickme'))
1216
+ expect('click').not.toHaveBeenPreventedOn('#clickme')
1217
+ })
1218
+
1219
+ it('should pass negated if the event was prevented on another non-descendant object', function () {
1220
+ $('#otherlink').bind('click', function (event) {
1221
+ event.preventDefault()
1222
+ })
1223
+ $('#clickme').click()
1224
+ expect('click').not.toHaveBeenPreventedOn($('#clickme'))
1225
+ })
1226
+ })
1227
+
1228
+ describe('toHaveBeenPrevented', function () {
1229
+ var spyEvents = {}
1230
+ beforeEach(function () {
1231
+ setFixtures(sandbox().html('<a id="clickme">Click Me</a> <a id="otherlink">Other Link</a>'))
1232
+ spyEvents['#clickme'] = spyOnEvent($('#clickme'), 'click')
1233
+ spyEvents['#otherlink'] = spyOnEvent($('#otherlink'), 'click')
1234
+ })
1235
+
1236
+ it('should pass if the event was prevented on the object', function () {
1237
+ $('#clickme').bind('click', function (event) {
1238
+ event.preventDefault()
1239
+ })
1240
+ $('#clickme').click()
1241
+ expect(spyEvents['#clickme']).toHaveBeenPrevented()
1242
+ })
1243
+
1244
+ it('should pass negated if the event was never prevented', function () {
1245
+ $('#clickme').click()
1246
+ expect(spyEvents['#clickme']).not.toHaveBeenPrevented()
1247
+ })
1248
+
1249
+ it('should pass negated if the event was prevented on another non-descendant object', function () {
1250
+ $('#otherlink').bind('click', function (event) {
1251
+ event.preventDefault()
1252
+ })
1253
+ $('#clickme').click()
1254
+ expect(spyEvents['#clickme']).not.toHaveBeenPrevented()
1255
+ })
1256
+
1257
+ it('should pass negated if nothing was triggered', function () {
1258
+ expect(spyEvents['#clickme']).not.toHaveBeenPrevented()
1259
+ })
1260
+
1261
+ })
1262
+
1263
+ describe('toHaveBeenStoppedOn', function () {
1264
+ beforeEach(function () {
1265
+ setFixtures(sandbox().html('<a id="clickme">Click Me</a> <a id="otherlink">Other Link</a>'))
1266
+ spyOnEvent($('#clickme'), 'click')
1267
+ spyOnEvent($('#otherlink'), 'click')
1268
+ })
1269
+
1270
+ it('should pass if the event was stopped on the object', function () {
1271
+ $('#clickme').bind('click', function (event) {
1272
+ event.stopPropagation()
1273
+ })
1274
+ $('#clickme').click()
1275
+ expect('click').toHaveBeenStoppedOn($('#clickme'))
1276
+ expect('click').toHaveBeenStoppedOn('#clickme')
1277
+ })
1278
+
1279
+ it('should pass negated if the event was never stopped', function () {
1280
+ $('#clickme').click()
1281
+ expect('click').not.toHaveBeenStoppedOn($('#clickme'))
1282
+ expect('click').not.toHaveBeenStoppedOn('#clickme')
1283
+ })
1284
+
1285
+ it('should pass negated if the event was stopped on another non-descendant object', function () {
1286
+ $('#otherlink').bind('click', function (event) {
1287
+ event.stopPropagation()
1288
+ })
1289
+ $('#clickme').click()
1290
+ expect('click').not.toHaveBeenStoppedOn($('#clickme'))
1291
+ })
1292
+ })
1293
+
1294
+ describe('toHaveBeenStopped', function () {
1295
+ var spyEvents = {}
1296
+ beforeEach(function () {
1297
+ setFixtures(sandbox().html('<a id="clickme">Click Me</a> <a id="otherlink">Other Link</a>'))
1298
+ spyEvents['#clickme'] = spyOnEvent($('#clickme'), 'click')
1299
+ spyEvents['#otherlink'] = spyOnEvent($('#otherlink'), 'click')
1300
+ })
1301
+
1302
+ it('should pass if the event was stopped on the object', function () {
1303
+ $('#clickme').bind('click', function (event) {
1304
+ event.stopPropagation()
1305
+ })
1306
+ $('#clickme').click()
1307
+ expect(spyEvents['#clickme']).toHaveBeenStopped()
1308
+ })
1309
+
1310
+ it('should pass negated if the event was never stopped', function () {
1311
+ $('#clickme').click()
1312
+ expect(spyEvents['#clickme']).not.toHaveBeenStopped()
1313
+ })
1314
+
1315
+ it('should pass negated if the event was stopped on another non-descendant object', function () {
1316
+ $('#otherlink').bind('click', function (event) {
1317
+ event.stopPropagation()
1318
+ })
1319
+ $('#clickme').click()
1320
+ expect(spyEvents['#clickme']).not.toHaveBeenStopped()
1321
+ })
1322
+
1323
+ it('should pass negated if nothing was triggered', function () {
1324
+ expect(spyEvents['#clickme']).not.toHaveBeenStopped()
1325
+ })
1326
+ })
1327
+
1328
+ describe('toHandle', function () {
1329
+ var handler
1330
+ beforeEach(function () {
1331
+ setFixtures(sandbox().html('<a id="clickme">Click Me</a> <a id="otherlink">Other Link</a>'))
1332
+ handler = function (){}
1333
+ })
1334
+
1335
+ it("should handle events on the window object", function (){
1336
+ $(window).bind("resize", handler)
1337
+ expect($(window)).toHandle("resize")
1338
+ })
1339
+
1340
+ it('should pass if the event is bound', function () {
1341
+ $('#clickme').bind("click", handler)
1342
+ expect($('#clickme')).toHandle("click")
1343
+ expect($('#clickme').get(0)).toHandle("click")
1344
+ })
1345
+
1346
+ it('should pass if the event is not bound', function () {
1347
+ expect($('#clickme')).not.toHandle("click")
1348
+ expect($('#clickme').get(0)).not.toHandle("click")
1349
+ })
1350
+
1351
+ it('should pass if the namespaced event is bound', function (){
1352
+ $('#clickme').bind("click", handler); //another event for the click array
1353
+ $('#clickme').bind("click.NameSpace", handler)
1354
+ expect($('#clickme')).toHandle("click.NameSpace")
1355
+ })
1356
+
1357
+ it('should not fail when events is empty', function () {
1358
+ $('#clickme').change(function () { })
1359
+ expect($('#clickme')).not.toHandle('click')
1360
+ })
1361
+
1362
+ it('should recognize an event with multiple namespaces', function (){
1363
+ $('#clickme').bind("click.NSone.NStwo.NSthree", handler)
1364
+ expect($('#clickme')).toHandle("click.NSone")
1365
+ expect($('#clickme')).toHandle("click.NStwo")
1366
+ expect($('#clickme')).toHandle("click.NSthree")
1367
+ expect($('#clickme')).toHandle("click.NSthree.NStwo")
1368
+ expect($('#clickme')).toHandle("click.NStwo.NSone")
1369
+ expect($('#clickme')).toHandle("click")
1370
+ })
1371
+
1372
+ it('should pass if a namespaced event is not bound', function () {
1373
+ $('#clickme').bind("click", handler); //non namespaced event
1374
+ $('#clickme').bind("click.OtherNameSpace", handler); //different namespaced event
1375
+ expect($('#clickme')).not.toHandle("click.NameSpace")
1376
+ })
1377
+
1378
+ it('should handle event on any object', function (){
1379
+ var object = new function (){}
1380
+ $(object).bind('click', function (){})
1381
+ expect($(object)).toHandle('click')
1382
+ })
1383
+
1384
+ it('should not fail when actual has no matches', function (){
1385
+ expect($('#notreal')).not.toHandle('click')
1386
+ })
1387
+
1388
+ it('should not fail when actual is null', function (){
1389
+ expect(null).not.toHandle('click')
1390
+ })
1391
+
1392
+ })
1393
+
1394
+ describe('toHandleWith', function () {
1395
+ beforeEach(function () {
1396
+ setFixtures(sandbox().html('<a id="clickme">Click Me</a> <a id="otherlink">Other Link</a>'))
1397
+ })
1398
+
1399
+ it('should pass if the event is bound with the given handler', function () {
1400
+ var handler = function (){}
1401
+ $('#clickme').bind("click", handler)
1402
+ expect($('#clickme')).toHandleWith("click", handler)
1403
+ expect($('#clickme').get(0)).toHandleWith("click", handler)
1404
+ })
1405
+
1406
+ it('should pass if the event is not bound with the given handler', function () {
1407
+ var handler = function (){}
1408
+ $('#clickme').bind("click", handler)
1409
+
1410
+ var aDifferentHandler = function (){}
1411
+ expect($('#clickme')).not.toHandleWith("click", aDifferentHandler)
1412
+ expect($('#clickme').get(0)).not.toHandleWith("click", aDifferentHandler)
1413
+ })
1414
+
1415
+ it('should pass if the event is not bound at all', function () {
1416
+ expect($('#clickme')).not.toHandle("click")
1417
+ expect($('#clickme').get(0)).not.toHandle("click")
1418
+ })
1419
+
1420
+ it("should pass if the event on window is bound with the given handler", function (){
1421
+ var handler = function (){}
1422
+ $(window).bind("resize", handler)
1423
+ expect($(window)).toHandleWith("resize", handler)
1424
+ })
1425
+
1426
+ it("should pass if the event on any object is bound with the given handler", function (){
1427
+ var object = new function (){}
1428
+ var handler = function (){}
1429
+ $(object).bind('click', handler)
1430
+ expect($(object)).toHandleWith('click', handler)
1431
+ })
1432
+
1433
+ it("should pass if the namespaced event is bound with the given handler", function () {
1434
+ var handler = function (){}
1435
+ $('#clickme').bind("click.namespaced", handler)
1436
+ expect($('#clickme')).toHandleWith("click.namespaced", handler)
1437
+ expect($('#clickme').get(0)).toHandleWith("click.namespaced", handler)
1438
+ })
1439
+
1440
+ it('should pass if the namespaced event is not bound with the given handler', function () {
1441
+ var handler = function (){}
1442
+ $('#clickme').bind("click", handler)
1443
+
1444
+ var aDifferentHandler = function (){}
1445
+ expect($('#clickme')).not.toHandleWith("click.namespaced", aDifferentHandler)
1446
+ expect($('#clickme').get(0)).not.toHandleWith("click.namespaced", aDifferentHandler)
1447
+ })
1448
+
1449
+ it('should pass if the namespaced event is not bound at all', function () {
1450
+ expect($('#clickme')).not.toHandle("click.namespaced")
1451
+ expect($('#clickme').get(0)).not.toHandle("click.namespaced")
1452
+ })
1453
+
1454
+ it("should pass if the namespaced event on window is bound with the given handler", function (){
1455
+ var handler = function (){}
1456
+ $(window).bind("resize.namespaced", handler)
1457
+ expect($(window)).toHandleWith("resize.namespaced", handler)
1458
+ })
1459
+
1460
+ it("should pass if the namespaced event on any object is bound with the given handler", function (){
1461
+ var object = new function (){}
1462
+ var handler = function (){}
1463
+ $(object).bind('click.namespaced', handler)
1464
+ expect($(object)).toHandleWith('click.namespaced', handler)
1465
+ })
1466
+
1467
+ it('should not fail when actual has no matches', function (){
1468
+ expect($('#notreal')).not.toHandleWith('click')
1469
+ })
1470
+
1471
+ it('should not fail when actual is null', function (){
1472
+ expect(null).not.toHandleWith('click')
1473
+ })
1474
+
1475
+ })
1476
+ })
1477
+
1478
+ describe("jasmine.StyleFixtures", function () {
1479
+ var ajaxData = 'some ajax data'
1480
+ var fixtureUrl = 'some_url'
1481
+ var anotherFixtureUrl = 'another_url'
1482
+ var fixturesContainer = function () {
1483
+ return $('head style').last()
1484
+ }
1485
+
1486
+ beforeEach(function () {
1487
+ jasmine.getStyleFixtures().clearCache()
1488
+ spyOn(jasmine.StyleFixtures.prototype, 'loadFixtureIntoCache_').and.callFake(function (relativeUrl){
1489
+ this.fixturesCache_[relativeUrl] = ajaxData
1490
+ })
1491
+ })
1492
+
1493
+ describe("default initial config values", function () {
1494
+ it("should set 'spec/javascripts/fixtures' as the default style fixtures path", function () {
1495
+ expect(jasmine.getStyleFixtures().fixturesPath).toEqual('spec/javascripts/fixtures')
1496
+ })
1497
+ })
1498
+
1499
+ describe("load", function () {
1500
+ it("should insert CSS fixture within style tag into HEAD", function () {
1501
+ var stylesNumOld = $('head style').length
1502
+
1503
+ jasmine.getStyleFixtures().load(fixtureUrl)
1504
+ expect($('head style').length - stylesNumOld).toEqual(1)
1505
+ expect(fixturesContainer().html()).toEqual(ajaxData)
1506
+ })
1507
+
1508
+ it("should insert duplicated CSS fixture into one style tag when the same url is provided twice in a single call", function () {
1509
+ jasmine.getStyleFixtures().load(fixtureUrl, fixtureUrl)
1510
+ expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
1511
+ })
1512
+
1513
+ it("should insert merged CSS of two fixtures into one style tag when two different urls are provided in a single call", function () {
1514
+ jasmine.getStyleFixtures().load(fixtureUrl, anotherFixtureUrl)
1515
+ expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
1516
+ })
1517
+
1518
+ it("should have shortcut global method loadStyleFixtures", function () {
1519
+ loadStyleFixtures(fixtureUrl, anotherFixtureUrl)
1520
+ expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
1521
+ })
1522
+ })
1523
+
1524
+ describe("appendLoad", function () {
1525
+ beforeEach(function (){
1526
+ ajaxData = 'some ajax data'
1527
+ })
1528
+
1529
+ it("should insert CSS fixture within style tag into HEAD", function () {
1530
+ var stylesNumOld = $('head style').length
1531
+
1532
+ jasmine.getStyleFixtures().appendLoad(fixtureUrl)
1533
+ expect($('head style').length - stylesNumOld).toEqual(1)
1534
+ expect(fixturesContainer().html()).toEqual(ajaxData)
1535
+ })
1536
+
1537
+ it("should insert duplicated CSS fixture into one style tag when the same url is provided twice in a single call", function () {
1538
+ jasmine.getStyleFixtures().appendLoad(fixtureUrl, fixtureUrl)
1539
+ expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
1540
+ })
1541
+
1542
+ it("should insert merged CSS of two fixtures into one style tag when two different urls are provided in a single call", function () {
1543
+ jasmine.getStyleFixtures().appendLoad(fixtureUrl, anotherFixtureUrl)
1544
+ expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
1545
+ })
1546
+
1547
+ it("should have shortcut global method appendLoadStyleFixtures", function () {
1548
+ appendLoadStyleFixtures(fixtureUrl, anotherFixtureUrl)
1549
+ expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
1550
+ })
1551
+
1552
+ describe("with a prexisting fixture",function (){
1553
+ beforeEach(function () {
1554
+ jasmine.getStyleFixtures().appendLoad(fixtureUrl)
1555
+ })
1556
+
1557
+ it("should add new content within new style tag in HEAD", function () {
1558
+ jasmine.getStyleFixtures().appendLoad(anotherFixtureUrl)
1559
+ expect(fixturesContainer().html()).toEqual(ajaxData)
1560
+ })
1561
+
1562
+ it("should not delete prexisting fixtures", function () {
1563
+ jasmine.getStyleFixtures().appendLoad(anotherFixtureUrl)
1564
+ expect(fixturesContainer().prev().html()).toEqual(ajaxData)
1565
+ })
1566
+ })
1567
+ })
1568
+
1569
+ describe("preload", function () {
1570
+ describe("load after preload", function () {
1571
+ it("should go from cache", function () {
1572
+ jasmine.getStyleFixtures().preload(fixtureUrl, anotherFixtureUrl)
1573
+ jasmine.getStyleFixtures().load(fixtureUrl, anotherFixtureUrl)
1574
+ expect(jasmine.StyleFixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(2)
1575
+ })
1576
+
1577
+ it("should return correct CSSs", function () {
1578
+ jasmine.getStyleFixtures().preload(fixtureUrl, anotherFixtureUrl)
1579
+ jasmine.getStyleFixtures().load(fixtureUrl, anotherFixtureUrl)
1580
+ expect(fixturesContainer().html()).toEqual(ajaxData + ajaxData)
1581
+ })
1582
+ })
1583
+
1584
+ it("should not preload the same fixture twice", function () {
1585
+ jasmine.getStyleFixtures().preload(fixtureUrl, fixtureUrl)
1586
+ expect(jasmine.StyleFixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(1)
1587
+ })
1588
+
1589
+ it("should have shortcut global method preloadStyleFixtures", function () {
1590
+ preloadStyleFixtures(fixtureUrl, anotherFixtureUrl)
1591
+ expect(jasmine.StyleFixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(2)
1592
+ })
1593
+ })
1594
+
1595
+ describe("set", function () {
1596
+ var css = 'body { color: red }'
1597
+
1598
+ it("should insert CSS within style tag into HEAD", function () {
1599
+ var stylesNumOld = $('head style').length
1600
+
1601
+ jasmine.getStyleFixtures().set(css)
1602
+ expect($('head style').length - stylesNumOld).toEqual(1)
1603
+ expect(fixturesContainer().html()).toEqual(css)
1604
+ })
1605
+
1606
+ it("should have shortcut global method setStyleFixtures", function () {
1607
+ setStyleFixtures(css)
1608
+ expect(fixturesContainer().html()).toEqual(css)
1609
+ })
1610
+ })
1611
+
1612
+ describe("appendSet",function (){
1613
+ var css = 'body { color: red }'
1614
+
1615
+ it("should insert CSS within style tag into HEAD", function () {
1616
+ var stylesNumOld = $('head style').length
1617
+
1618
+ jasmine.getStyleFixtures().appendSet(css)
1619
+ expect($('head style').length - stylesNumOld).toEqual(1)
1620
+ expect(fixturesContainer().html()).toEqual(css)
1621
+ })
1622
+
1623
+ it("should have shortcut global method appendSetStyleFixtures", function () {
1624
+ appendSetStyleFixtures(css)
1625
+ expect(fixturesContainer().html()).toEqual(css)
1626
+ })
1627
+
1628
+ describe("when fixture container exists", function () {
1629
+ beforeEach(function () {
1630
+ jasmine.getStyleFixtures().appendSet(css)
1631
+ })
1632
+
1633
+ it("should add new content within new style tag in HEAD", function () {
1634
+ jasmine.getStyleFixtures().appendSet(css)
1635
+ expect(fixturesContainer().html()).toEqual(css)
1636
+ })
1637
+
1638
+ it("should not delete prexisting fixtures", function () {
1639
+ jasmine.getStyleFixtures().appendSet(css)
1640
+ expect(fixturesContainer().prev().html()).toEqual(css)
1641
+ })
1642
+ })
1643
+ })
1644
+
1645
+ describe("cleanUp", function () {
1646
+ it("should remove CSS fixtures from DOM", function () {
1647
+ var stylesNumOld = $('head style').length
1648
+
1649
+ jasmine.getStyleFixtures().load(fixtureUrl, anotherFixtureUrl)
1650
+ jasmine.getStyleFixtures().cleanUp()
1651
+
1652
+ expect($('head style').length).toEqual(stylesNumOld)
1653
+ })
1654
+ })
1655
+
1656
+ describe("automatic DOM clean-up between tests", function () {
1657
+ var stylesNumOld = $('head style').length
1658
+
1659
+ // WARNING: this test must be invoked first (before 'SECOND TEST')!
1660
+ it("FIRST TEST: should pollute the DOM", function () {
1661
+ jasmine.getStyleFixtures().load(fixtureUrl)
1662
+ expect($('head style').length).toEqual(stylesNumOld + 1)
1663
+ })
1664
+
1665
+ // WARNING: this test must be invoked second (after 'FIRST TEST')!
1666
+ it("SECOND TEST: should see the DOM in a blank state", function () {
1667
+ expect($('head style').length).toEqual(stylesNumOld)
1668
+ })
1669
+ })
1670
+ })
1671
+
1672
+ describe("jasmine.StyleFixtures using real AJAX call", function () {
1673
+ var defaultFixturesPath
1674
+
1675
+ beforeEach(function () {
1676
+ defaultFixturesPath = jasmine.getStyleFixtures().fixturesPath
1677
+ jasmine.getStyleFixtures().fixturesPath = 'spec/fixtures'
1678
+ })
1679
+
1680
+ afterEach(function () {
1681
+ jasmine.getStyleFixtures().fixturesPath = defaultFixturesPath
1682
+ })
1683
+
1684
+ describe("when fixture file exists", function () {
1685
+ var fixtureUrl = "real_non_mocked_fixture_style.css"
1686
+
1687
+ it("should load content of fixture file", function () {
1688
+ jasmine.getStyleFixtures().load(fixtureUrl)
1689
+ expect($('head style').last().html()).toEqual('body { background: red; }')
1690
+ })
1691
+ })
1692
+ })
1693
+
1694
+ describe("jasmine.JSONFixtures", function () {
1695
+ var ajaxData = {a:1, b:2, arr: [1,2,'stuff'], hsh: { blurp: 8, blop: 'blip' }}
1696
+ var moreAjaxData = [1,2,'stuff']
1697
+ var fixtureUrl = 'some_json'
1698
+ var anotherFixtureUrl = 'another_json'
1699
+ var _sortedKeys = function (obj) {
1700
+ var arr = []
1701
+ for(var k in obj) arr.push(k)
1702
+ return arr.sort()
1703
+ }
1704
+
1705
+ beforeEach(function () {
1706
+ jasmine.getJSONFixtures().clearCache()
1707
+ spyOn(jasmine.JSONFixtures.prototype, 'loadFixtureIntoCache_').and.callFake(function (relativeUrl){
1708
+ fakeData = {}
1709
+ // we put the data directly here, instead of using the variables to simulate rereading the file
1710
+ fakeData[fixtureUrl] = {a:1, b:2, arr: [1,2,'stuff'], hsh: { blurp: 8, blop: 'blip' }}
1711
+ fakeData[anotherFixtureUrl] = [1,2,'stuff']
1712
+ this.fixturesCache_[relativeUrl] = fakeData[relativeUrl]
1713
+ })
1714
+ })
1715
+
1716
+ describe("default initial config values", function () {
1717
+ it("should set 'spec/javascripts/fixtures/json' as the default style fixtures path", function () {
1718
+ expect(jasmine.getJSONFixtures().fixturesPath).toEqual('spec/javascripts/fixtures/json')
1719
+ })
1720
+ })
1721
+
1722
+ describe("load", function () {
1723
+ it("should load the JSON data under the key 'fixture_url'", function () {
1724
+ data = jasmine.getJSONFixtures().load(fixtureUrl)
1725
+ expect(_sortedKeys(data)).toEqual([fixtureUrl])
1726
+ expect(data[fixtureUrl]).toEqual(ajaxData)
1727
+ })
1728
+
1729
+ it("should load the JSON data under the key 'fixture_url', even if it's loaded twice in one call", function () {
1730
+ data = jasmine.getJSONFixtures().load(fixtureUrl, fixtureUrl)
1731
+ expect(_sortedKeys(data)).toEqual([fixtureUrl])
1732
+ })
1733
+
1734
+ it("should load the JSON data under 2 keys given two files in a single call", function () {
1735
+ data = jasmine.getJSONFixtures().load(anotherFixtureUrl, fixtureUrl)
1736
+ expect(_sortedKeys(data)).toEqual([anotherFixtureUrl, fixtureUrl])
1737
+ expect(data[anotherFixtureUrl]).toEqual(moreAjaxData)
1738
+ expect(data[fixtureUrl]).toEqual(ajaxData)
1739
+ })
1740
+
1741
+ it("should have shortcut global method loadJSONFixtures", function () {
1742
+ data = loadJSONFixtures(fixtureUrl, anotherFixtureUrl)
1743
+ expect(_sortedKeys(data)).toEqual([anotherFixtureUrl, fixtureUrl])
1744
+ expect(data[anotherFixtureUrl]).toEqual(moreAjaxData)
1745
+ expect(data[fixtureUrl]).toEqual(ajaxData)
1746
+ })
1747
+ })
1748
+
1749
+ describe('getJSONFixture', function () {
1750
+ it("fetches the fixture you ask for", function () {
1751
+ expect(getJSONFixture(fixtureUrl)).toEqual(ajaxData)
1752
+ expect(jasmine.JSONFixtures.prototype.loadFixtureIntoCache_).toHaveBeenCalled()
1753
+ expect(getJSONFixture(anotherFixtureUrl)).toEqual(moreAjaxData)
1754
+ expect(jasmine.JSONFixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(2)
1755
+ })
1756
+
1757
+ it("retrieves from cache on subsequent requests for the same fixture", function () {
1758
+ expect(getJSONFixture(fixtureUrl)).toEqual(ajaxData)
1759
+ expect(jasmine.JSONFixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(1)
1760
+ expect(getJSONFixture(fixtureUrl)).toEqual(ajaxData)
1761
+ expect(jasmine.JSONFixtures.prototype.loadFixtureIntoCache_.calls.count()).toEqual(1)
1762
+ })
1763
+ })
1764
+
1765
+ describe("reloading data will restore the fixture data", function () {
1766
+ var data
1767
+ beforeEach(function () {
1768
+ data = jasmine.getJSONFixtures().load(anotherFixtureUrl)[anotherFixtureUrl]
1769
+ })
1770
+ // WARNING: this test must be invoked first (before 'SECOND TEST')!
1771
+ it("FIRST TEST: should pollute the fixture data", function () {
1772
+ data.push('moredata')
1773
+ expect(data.length).toEqual(4)
1774
+ })
1775
+
1776
+ // WARNING: this test must be invoked second (after 'FIRST TEST')!
1777
+ it("SECOND TEST: should see cleansed JSON fixture data", function () {
1778
+ expect(data.length).toEqual(3)
1779
+ })
1780
+ })
1781
+ })
1782
+
1783
+ describe("jasmine.JSONFixtures using real AJAX call", function () {
1784
+ var defaultFixturesPath
1785
+
1786
+ beforeEach(function () {
1787
+ defaultFixturesPath = jasmine.getJSONFixtures().fixturesPath
1788
+ jasmine.getJSONFixtures().fixturesPath = 'spec/fixtures/json'
1789
+ })
1790
+
1791
+ afterEach(function () {
1792
+ jasmine.getJSONFixtures().fixturesPath = defaultFixturesPath
1793
+ })
1794
+
1795
+ describe("when fixture file exists", function () {
1796
+ var fixtureUrl = "jasmine_json_test.json"
1797
+
1798
+ it("should load content of fixture file", function () {
1799
+ data = jasmine.getJSONFixtures().load(fixtureUrl)
1800
+ expect(data[fixtureUrl]).toEqual([1,2,3])
1801
+ })
1802
+ })
1803
+ })
1804
+
1805
+ describe("jasmine.Env.equalityTesters_", function () {
1806
+ describe("jQuery object tester", function () {
1807
+ beforeEach(function () {
1808
+ setFixtures(sandbox())
1809
+ })
1810
+
1811
+ it("should equate the same element with different selectors", function () {
1812
+ expect($('#sandbox')).toEqual($('div#sandbox'))
1813
+ })
1814
+
1815
+ it("should equate jquery objects that match a set of elements", function () {
1816
+ $('#sandbox').append($('<div></div>'))
1817
+ $('#sandbox').append($('<div></div>'))
1818
+ expect($('#sandbox div')).toEqual($('div#sandbox div'))
1819
+ })
1820
+
1821
+ it("should not equate jquery objects that match a set of elements where one has an extra", function () {
1822
+ $('#sandbox').append($('<div></div>'))
1823
+ $('#sandbox').append($('<div></div>'))
1824
+ $('#sandbox').append($('<span></span>'))
1825
+ expect($('#sandbox div')).not.toEqual($('div#sandbox div, div#sandbox span'))
1826
+ })
1827
+
1828
+ it("should not equate jquery objects that match a set of elements of the same type where the tag types are the same, but they are not the same DOM elements", function () {
1829
+ $('#sandbox').append($('<div class="one"></div>'))
1830
+ $('#sandbox').append($('<span class="one"></span>'))
1831
+ $('#sandbox').append($('<div class="two"></div>'))
1832
+ $('#sandbox').append($('<span class="two"></span>'))
1833
+ expect($('.one')).not.toEqual($('.two').first())
1834
+ })
1835
+
1836
+ it("should not equate jquery objects that match a set of elements of the same type where one is missing a single element", function () {
1837
+ $('#sandbox').append($('<div></div>'))
1838
+ $('#sandbox').append($('<div></div>'))
1839
+ expect($('#sandbox div')).not.toEqual($('div#sandbox div').first())
1840
+ })
1841
+ })
1842
+ });