magic_carpet 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +202 -0
- data/README.md +232 -0
- data/Rakefile +15 -0
- data/app/assets/javascripts/magic_carpet/application.js +13 -0
- data/app/assets/javascripts/magic_carpet/magic_carpet.js +80 -0
- data/app/assets/stylesheets/magic_carpet/application.css +13 -0
- data/app/controllers/magic_carpet/application_controller.rb +4 -0
- data/app/controllers/magic_carpet/js_fixtures_controller.rb +110 -0
- data/app/helpers/magic_carpet/application_helper.rb +4 -0
- data/app/helpers/magic_carpet/js_fixtures_helper.rb +139 -0
- data/config/routes.rb +3 -0
- data/lib/magic_carpet/engine.rb +12 -0
- data/lib/magic_carpet/version.rb +3 -0
- data/lib/magic_carpet.rb +4 -0
- data/lib/tasks/magic_carpet_tasks.rake +4 -0
- data/spec/controllers/magic_carpet/js_fixtures_controller_spec.rb +275 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/javascripts/jquery-2.1.0.js +9111 -0
- data/spec/dummy/app/assets/javascripts/users.js +2 -0
- data/spec/dummy/app/assets/javascripts/wishes.js +2 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/spec/dummy/app/assets/stylesheets/users.css +4 -0
- data/spec/dummy/app/assets/stylesheets/wishes.css +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/users_controller.rb +58 -0
- data/spec/dummy/app/controllers/wishes_controller.rb +70 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/helpers/users_helper.rb +2 -0
- data/spec/dummy/app/helpers/wishes_helper.rb +2 -0
- data/spec/dummy/app/models/user.rb +3 -0
- data/spec/dummy/app/models/wish.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +19 -0
- data/spec/dummy/app/views/layouts/other_layout.html.erb +15 -0
- data/spec/dummy/app/views/shared/_id_able.html.erb +5 -0
- data/spec/dummy/app/views/users/_form.html.erb +29 -0
- data/spec/dummy/app/views/users/edit.html.erb +6 -0
- data/spec/dummy/app/views/users/index.html.erb +31 -0
- data/spec/dummy/app/views/users/new.html.erb +5 -0
- data/spec/dummy/app/views/users/show.html.erb +19 -0
- data/spec/dummy/app/views/wishes/_form.html.erb +21 -0
- data/spec/dummy/app/views/wishes/_some_partial.html.erb +1 -0
- data/spec/dummy/app/views/wishes/_wish.html.erb +6 -0
- data/spec/dummy/app/views/wishes/_wish_list_item.html.erb +3 -0
- data/spec/dummy/app/views/wishes/edit.html.erb +6 -0
- data/spec/dummy/app/views/wishes/index.html.erb +22 -0
- data/spec/dummy/app/views/wishes/local_models.html.erb +3 -0
- data/spec/dummy/app/views/wishes/locals.html.erb +6 -0
- data/spec/dummy/app/views/wishes/new.html.erb +5 -0
- data/spec/dummy/app/views/wishes/numbers.html.erb +4 -0
- data/spec/dummy/app/views/wishes/plain.html.erb +1 -0
- data/spec/dummy/app/views/wishes/show.html.erb +9 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +28 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +9 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20140201230228_create_wishes.rb +9 -0
- data/spec/dummy/db/migrate/20140201230247_create_users.rb +11 -0
- data/spec/dummy/db/migrate/20140208042514_associate_users_and_wishes.rb +5 -0
- data/spec/dummy/db/schema.rb +31 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +21112 -0
- data/spec/dummy/log/test.log +33634 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/spec/javascripts/helpers/spec_helper.js +367 -0
- data/spec/dummy/spec/javascripts/magic_carpet_spec.js +314 -0
- data/spec/dummy/spec/javascripts/support/jasmine.yml +29 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/0743af5c3f490550c6a448f45e6889b4 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/0800f54ee19cf3cee10b956fa9786799 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/082245bc7cce1345893a81643f76284a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/08b0d9573e11dc361c93563cec2a0106 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/09f277e17472af932cda6f7dd86ff943 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/0e3142f2ae2a0b8902383f65b86a5299 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/0f87038bb320b83592e071bff83e4195 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/10925724a66880466e7f3b4e158196cb +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/10fb651bf6e564ad505e391670c11a8d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/12090b2e7e2e9ac2632e486d02ee346a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/142047722c23a8e9a96c6355d224b67e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1b4c56479f40fe3f7fc8daf684f4f71c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1c3579416ea74586464f5969c6949d5d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1e259f0863fa6da47ded59eef77ac351 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/21d2c592e1570709ecd1208a030cfc66 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/220ab8240fd9e0712b64dd9ff515f5df +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/277a51802284d997817fcaca55211243 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/28c409c3bba590030a8074120aa781db +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/35906b4cd565b14db8ba786fc66c7eb3 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/388a1d725ffd01cc06a34d720ea97775 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/4050a4e5062ab95c9f32e9b6940821ea +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/442917e5b534e0e7ac0a3bac0c5299e7 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/45ccf991e042a7cf7abe52d1125eeae3 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/469198efe71fedae413489ff2fad66e4 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/4817f65b5fc5c2042e04af7eb83a4c99 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/497ff8927ce695e3febb3cdfd3e4a74e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/51202fde1d49c04c5d5588ca203b7b1e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/55ea602f40a0ad2185e22964a16b4d42 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/596788b2d37e650dd4cf582b185f9d37 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5c09faba4e454de97f078861e82db15c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5f1a0d05e77ca8b9a1fc2a47e17a8174 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/64de9e1fa2dd01768d6e85552dcdb18a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/68c5fa1f98ca79274b1f6750d8611af5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6bcea01ea8389e9a2ee296904803a01c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7406b6e2ecfc7b024db7822fb753c796 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/744bda5bad4a3b9b9b244a4583fb6e29 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/786804147f5da16b37ef8932e422797c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/793dc2ede21315a9eabfe2b0a0ff13d4 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7b1c8fbfabc405ee6e5c8887095e6b43 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7c2edc3a2733a7bc22c572af66983a2e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7cd1032c2c1fa8a02016ac207cd9c76f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7d4bf0f7a6d67ade27f05b9bbdfaa13f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/809136388a8f6d7a862b20361fad205c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/80ba335c5610df2a1defeab247d03cc9 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/817b43e6477d4059b9006261356b7147 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/81b537f4760199f4030b928268605909 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/83521bb0fd5da34426e16d8825eb314e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/85b590662faa5956a7cb3a38390f16ca +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8733ef9be8fb368ac9aa5b1ccbfce14c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/87b209c0c9da28094a8d5581a21262c6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8931ae3296ab13e8eed90f434208887f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8cb4c1afbd9a270155d8cdd697a8b20d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8d1f1fbd708160b30af96a108fef6c0d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/91ef1ca0ef363be62f4a38fb3fbc2291 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/9a25637a28779d7c49c40044188bd0e5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a0d10779d647db6ab1328734733a0e4d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a0e04aab47dc3631152c26632687f898 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a74883b193a8e72f27cba5703a696a89 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a839288628913e4533ef8cba740de1eb +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a95ead461bd72142ffb3040f8cd7cfa0 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ac47afc414ae67e366a330dc003edf1a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b1d1383958868d6f0e9e05c848682d70 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b4ff5ac95c02b56ca97786b337f8b845 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b718bc4e8c8146520d982e086897fe24 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b848029d2fa6db3db28ccbce818b399b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ba05f15307eb6d2c7e31e50768867139 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c1a8bdfcb2dca842a48acc85d3ff658a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c2eb6c5cabed0e6b333c035ac8400bbc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c3dbe303660d299b488648fc157fd32b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c45af704cb234484a8e1d0852f8fe0bc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c4868ba5188e0672b480e24d979224d0 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/caa2f86bb055636b69e292f2ae993914 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ce4b669883cb8df0ccd1c6aca12e0434 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cebc6db0bbb8120f430da3970b173d2f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d8a7bed1e7150777f59a9e107c1acaa8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/db4f843f0e597f7ba079bec345a91d58 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/dd5a838f402c1f78ff0f6e43b3ce6624 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/dfd7187ca1d53815395570d20d933e13 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e4092eb95487a855cb730373c97b8756 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e41b3d9532b5ef87c246ef6eb88417ed +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e8266bddb6510ce3a2bc5ae1469ab3f6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e86f67e739e4d85d5b8b1830b327ee67 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/efc1c13c84f6f8686ade375b47913c8d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f1e3cae1b4d4c1085b32f88d26fd1f89 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f21b1a83f2c41f61ba73c424b057ee19 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f25cc7f3223a9259336cb2dd38df220e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f56253b5f374fff1a33fbbc9881c9124 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/10fb651bf6e564ad505e391670c11a8d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/142047722c23a8e9a96c6355d224b67e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/4050a4e5062ab95c9f32e9b6940821ea +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/51202fde1d49c04c5d5588ca203b7b1e +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/596788b2d37e650dd4cf582b185f9d37 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/5f1a0d05e77ca8b9a1fc2a47e17a8174 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/81b537f4760199f4030b928268605909 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/87b209c0c9da28094a8d5581a21262c6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/8cb4c1afbd9a270155d8cdd697a8b20d +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f56253b5f374fff1a33fbbc9881c9124 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/jasmine/assets/application.js +9132 -0
- data/spec/dummy/tmp/jasmine/assets/boot.js +204 -0
- data/spec/dummy/tmp/jasmine/assets/helpers/spec_helper.js +462 -0
- data/spec/dummy/tmp/jasmine/assets/jasmine-console-reporter.js +125 -0
- data/spec/dummy/tmp/jasmine/assets/jasmine-console-shims.js +31 -0
- data/spec/dummy/tmp/jasmine/assets/jasmine-html.js +360 -0
- data/spec/dummy/tmp/jasmine/assets/jasmine-specs.js +0 -0
- data/spec/dummy/tmp/jasmine/assets/jasmine.css +55 -0
- data/spec/dummy/tmp/jasmine/assets/jasmine.js +2403 -0
- data/spec/dummy/tmp/jasmine/assets/jquery-2.1.0.js +9112 -0
- data/spec/dummy/tmp/jasmine/assets/json2.js +479 -0
- data/spec/dummy/tmp/jasmine/assets/magic_carpet/application.js +95 -0
- data/spec/dummy/tmp/jasmine/assets/magic_carpet/magic_carpet.js +81 -0
- data/spec/dummy/tmp/jasmine/assets/magic_carpet_spec.js +317 -0
- data/spec/dummy/tmp/jasmine/assets/users.js +3 -0
- data/spec/dummy/tmp/jasmine/assets/wishes.js +3 -0
- data/spec/dummy/tmp/jasmine/runner.html +28 -0
- data/spec/dummy/tmp/pids/server.pid +1 -0
- data/spec/helpers/magic_carpet/js_fixtures_helper_spec.rb +249 -0
- data/spec/spec_helper.rb +14 -0
- metadata +590 -0
@@ -0,0 +1,204 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2008-2013 Pivotal Labs
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
*/
|
23
|
+
/**
|
24
|
+
Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
|
25
|
+
|
26
|
+
If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
|
27
|
+
|
28
|
+
The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
|
29
|
+
|
30
|
+
[jasmine-gem]: http://github.com/pivotal/jasmine-gem
|
31
|
+
*/
|
32
|
+
|
33
|
+
|
34
|
+
(function() {
|
35
|
+
|
36
|
+
/**
|
37
|
+
* ## Require & Instantiate
|
38
|
+
*
|
39
|
+
* Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
|
40
|
+
*/
|
41
|
+
window.jasmine = jasmineRequire.core(jasmineRequire);
|
42
|
+
|
43
|
+
/**
|
44
|
+
* Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
|
45
|
+
*/
|
46
|
+
jasmineRequire.html(jasmine);
|
47
|
+
|
48
|
+
/**
|
49
|
+
* Create the Jasmine environment. This is used to run all specs in a project.
|
50
|
+
*/
|
51
|
+
var env = jasmine.getEnv();
|
52
|
+
|
53
|
+
/**
|
54
|
+
* ## The Global Interface
|
55
|
+
*
|
56
|
+
* Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
|
57
|
+
*/
|
58
|
+
var jasmineInterface = {
|
59
|
+
describe: function(description, specDefinitions) {
|
60
|
+
return env.describe(description, specDefinitions);
|
61
|
+
},
|
62
|
+
|
63
|
+
xdescribe: function(description, specDefinitions) {
|
64
|
+
return env.xdescribe(description, specDefinitions);
|
65
|
+
},
|
66
|
+
|
67
|
+
it: function(desc, func) {
|
68
|
+
return env.it(desc, func);
|
69
|
+
},
|
70
|
+
|
71
|
+
xit: function(desc, func) {
|
72
|
+
return env.xit(desc, func);
|
73
|
+
},
|
74
|
+
|
75
|
+
beforeEach: function(beforeEachFunction) {
|
76
|
+
return env.beforeEach(beforeEachFunction);
|
77
|
+
},
|
78
|
+
|
79
|
+
afterEach: function(afterEachFunction) {
|
80
|
+
return env.afterEach(afterEachFunction);
|
81
|
+
},
|
82
|
+
|
83
|
+
expect: function(actual) {
|
84
|
+
return env.expect(actual);
|
85
|
+
},
|
86
|
+
|
87
|
+
pending: function() {
|
88
|
+
return env.pending();
|
89
|
+
},
|
90
|
+
|
91
|
+
spyOn: function(obj, methodName) {
|
92
|
+
return env.spyOn(obj, methodName);
|
93
|
+
},
|
94
|
+
|
95
|
+
jsApiReporter: new jasmine.JsApiReporter({
|
96
|
+
timer: new jasmine.Timer()
|
97
|
+
})
|
98
|
+
};
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Add all of the Jasmine global/public interface to the proper global, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
|
102
|
+
*/
|
103
|
+
if (typeof window == "undefined" && typeof exports == "object") {
|
104
|
+
extend(exports, jasmineInterface);
|
105
|
+
} else {
|
106
|
+
extend(window, jasmineInterface);
|
107
|
+
}
|
108
|
+
|
109
|
+
/**
|
110
|
+
* Expose the interface for adding custom equality testers.
|
111
|
+
*/
|
112
|
+
jasmine.addCustomEqualityTester = function(tester) {
|
113
|
+
env.addCustomEqualityTester(tester);
|
114
|
+
};
|
115
|
+
|
116
|
+
/**
|
117
|
+
* Expose the interface for adding custom expectation matchers
|
118
|
+
*/
|
119
|
+
jasmine.addMatchers = function(matchers) {
|
120
|
+
return env.addMatchers(matchers);
|
121
|
+
};
|
122
|
+
|
123
|
+
/**
|
124
|
+
* Expose the mock interface for the JavaScript timeout functions
|
125
|
+
*/
|
126
|
+
jasmine.clock = function() {
|
127
|
+
return env.clock;
|
128
|
+
};
|
129
|
+
|
130
|
+
/**
|
131
|
+
* ## Runner Parameters
|
132
|
+
*
|
133
|
+
* More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
|
134
|
+
*/
|
135
|
+
|
136
|
+
var queryString = new jasmine.QueryString({
|
137
|
+
getWindowLocation: function() { return window.location; }
|
138
|
+
});
|
139
|
+
|
140
|
+
var catchingExceptions = queryString.getParam("catch");
|
141
|
+
env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
|
142
|
+
|
143
|
+
/**
|
144
|
+
* ## Reporters
|
145
|
+
* The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
|
146
|
+
*/
|
147
|
+
var htmlReporter = new jasmine.HtmlReporter({
|
148
|
+
env: env,
|
149
|
+
onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
|
150
|
+
getContainer: function() { return document.body; },
|
151
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
152
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
|
153
|
+
timer: new jasmine.Timer()
|
154
|
+
});
|
155
|
+
|
156
|
+
/**
|
157
|
+
* The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
|
158
|
+
*/
|
159
|
+
env.addReporter(jasmineInterface.jsApiReporter);
|
160
|
+
env.addReporter(htmlReporter);
|
161
|
+
|
162
|
+
/**
|
163
|
+
* Filter which specs will be run by matching the start of the full name against the `spec` query param.
|
164
|
+
*/
|
165
|
+
var specFilter = new jasmine.HtmlSpecFilter({
|
166
|
+
filterString: function() { return queryString.getParam("spec"); }
|
167
|
+
});
|
168
|
+
|
169
|
+
env.specFilter = function(spec) {
|
170
|
+
return specFilter.matches(spec.getFullName());
|
171
|
+
};
|
172
|
+
|
173
|
+
/**
|
174
|
+
* Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
|
175
|
+
*/
|
176
|
+
window.setTimeout = window.setTimeout;
|
177
|
+
window.setInterval = window.setInterval;
|
178
|
+
window.clearTimeout = window.clearTimeout;
|
179
|
+
window.clearInterval = window.clearInterval;
|
180
|
+
|
181
|
+
/**
|
182
|
+
* ## Execution
|
183
|
+
*
|
184
|
+
* Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
|
185
|
+
*/
|
186
|
+
var currentWindowOnload = window.onload;
|
187
|
+
|
188
|
+
window.onload = function() {
|
189
|
+
if (currentWindowOnload) {
|
190
|
+
currentWindowOnload();
|
191
|
+
}
|
192
|
+
htmlReporter.initialize();
|
193
|
+
env.execute();
|
194
|
+
};
|
195
|
+
|
196
|
+
/**
|
197
|
+
* Helper function for readability above.
|
198
|
+
*/
|
199
|
+
function extend(destination, source) {
|
200
|
+
for (var property in source) destination[property] = source[property];
|
201
|
+
return destination;
|
202
|
+
}
|
203
|
+
|
204
|
+
}());
|
@@ -0,0 +1,462 @@
|
|
1
|
+
(MagicCarpet = {
|
2
|
+
async: false,
|
3
|
+
asyncComplete: true,
|
4
|
+
cache: {},
|
5
|
+
|
6
|
+
initialize: function() {
|
7
|
+
this.bindAll();
|
8
|
+
this.cacheElements();
|
9
|
+
this.appendSandbox();
|
10
|
+
},
|
11
|
+
|
12
|
+
bindAll: function() {
|
13
|
+
for(var prop in this) {
|
14
|
+
if (typeof this[prop] === "function" && this.hasOwnProperty(prop))
|
15
|
+
this.bind(this, prop);
|
16
|
+
}
|
17
|
+
},
|
18
|
+
|
19
|
+
bind: function(context, methodName) {
|
20
|
+
var func = context[methodName];
|
21
|
+
context[methodName] = function() {
|
22
|
+
return func.apply(context, arguments);
|
23
|
+
};
|
24
|
+
},
|
25
|
+
|
26
|
+
cacheElements: function() {
|
27
|
+
this.sandbox = this.createSandbox();
|
28
|
+
},
|
29
|
+
|
30
|
+
createSandbox: function() {
|
31
|
+
var div = document.createElement("div");
|
32
|
+
div.setAttribute("id", "magic-carpet");
|
33
|
+
return div;
|
34
|
+
},
|
35
|
+
|
36
|
+
appendSandbox: function() {
|
37
|
+
document.body.appendChild(this.sandbox);
|
38
|
+
},
|
39
|
+
|
40
|
+
emptySandbox: function() {
|
41
|
+
this.sandbox.innerHTML = "";
|
42
|
+
},
|
43
|
+
|
44
|
+
request: function(data) {
|
45
|
+
var cachedMarkup = this.cache[$.param(data)];
|
46
|
+
if (cachedMarkup) {
|
47
|
+
this.sandbox.innerHTML = cachedMarkup;
|
48
|
+
} else {
|
49
|
+
this.fetch(data);
|
50
|
+
}
|
51
|
+
},
|
52
|
+
|
53
|
+
fetch: function(data) {
|
54
|
+
this.lastRequest = data;
|
55
|
+
this.asyncComplete = false;
|
56
|
+
$.ajax({
|
57
|
+
url: "/magic_carpet",
|
58
|
+
method: "get",
|
59
|
+
async: this.async,
|
60
|
+
data: data
|
61
|
+
})
|
62
|
+
.done(this.handleSuccess)
|
63
|
+
.fail(this.handleFailure)
|
64
|
+
.always(this.afterRequest);
|
65
|
+
},
|
66
|
+
|
67
|
+
handleSuccess: function(markup) {
|
68
|
+
var cacheKey = $.param(this.lastRequest);
|
69
|
+
this.cache[cacheKey] = markup;
|
70
|
+
this.request(this.lastRequest);
|
71
|
+
},
|
72
|
+
|
73
|
+
handleFailure: function(response) {
|
74
|
+
debugger;
|
75
|
+
throw new Error(response.responseJSON.error);
|
76
|
+
},
|
77
|
+
|
78
|
+
afterRequest: function() {
|
79
|
+
this.asyncComplete = true;
|
80
|
+
}
|
81
|
+
}).initialize();
|
82
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
83
|
+
// listed below.
|
84
|
+
//
|
85
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
86
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
87
|
+
//
|
88
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
89
|
+
// compiled file.
|
90
|
+
//
|
91
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
92
|
+
// about supported directives.
|
93
|
+
//
|
94
|
+
|
95
|
+
;
|
96
|
+
|
97
|
+
|
98
|
+
// Stub agent string for testing agent detection code
|
99
|
+
function stubAgent(agentString) {
|
100
|
+
var __originalNavigator = navigator;
|
101
|
+
navigator = new Object();
|
102
|
+
navigator.__proto__ = __originalNavigator;
|
103
|
+
navigator.__defineGetter__('userAgent', function () { return agentString; });
|
104
|
+
}
|
105
|
+
|
106
|
+
// Stub event object for testing DOM events
|
107
|
+
var eventStub;
|
108
|
+
// Stub promise object for testing asynchronous code
|
109
|
+
var promiseStub;
|
110
|
+
|
111
|
+
// Stub an event object with a few basic spies
|
112
|
+
// for assertions.
|
113
|
+
eventStub = {
|
114
|
+
preventDefault: jasmine.createSpy("preventDefault"),
|
115
|
+
stopPropagation: jasmine.createSpy("stopPropagation"),
|
116
|
+
target: jasmine.createSpy("target"),
|
117
|
+
keyCode: 13 // Send enter keyCode by default
|
118
|
+
};
|
119
|
+
|
120
|
+
// The promise stub requres a bit more setup to
|
121
|
+
// enable assertions. Since promises are chainable
|
122
|
+
// every spy must return the promise stub
|
123
|
+
promiseStub = jasmine.createSpy("promiseStub");
|
124
|
+
promiseStub.abort = jasmine.createSpy("abort").and.returnValue(promiseStub);
|
125
|
+
promiseStub.fail = jasmine.createSpy("fail").and.returnValue(promiseStub);
|
126
|
+
promiseStub.done = jasmine.createSpy("done").and.returnValue(promiseStub);
|
127
|
+
promiseStub.always = jasmine.createSpy("always").and.returnValue(promiseStub);
|
128
|
+
|
129
|
+
beforeEach(function() {
|
130
|
+
jasmine.addMatchers({
|
131
|
+
toBeTrue: function() {
|
132
|
+
return {
|
133
|
+
compare: function(actual) {
|
134
|
+
return {
|
135
|
+
pass: actual === true,
|
136
|
+
message: "Expected " + actual + " to be true"
|
137
|
+
};
|
138
|
+
}
|
139
|
+
};
|
140
|
+
},
|
141
|
+
|
142
|
+
toBeFalse: function() {
|
143
|
+
return {
|
144
|
+
compare: function(actual) {
|
145
|
+
return {
|
146
|
+
pass: actual === false,
|
147
|
+
message: "Expected " + actual + " to be false"
|
148
|
+
};
|
149
|
+
}
|
150
|
+
};
|
151
|
+
},
|
152
|
+
|
153
|
+
toBeEmpty: function() {
|
154
|
+
return {
|
155
|
+
compare: function(actual) {
|
156
|
+
var pass;
|
157
|
+
if ((/Array/).test(Object.prototype.toString.call(actual))) {
|
158
|
+
pass = actual.length === 0;
|
159
|
+
} else {
|
160
|
+
for (var prop in actual) {
|
161
|
+
pass = false;
|
162
|
+
}
|
163
|
+
pass = (pass === undefined) ? true : false;
|
164
|
+
}
|
165
|
+
return {
|
166
|
+
pass: pass,
|
167
|
+
message: "Expected " + actual + " to be empty"
|
168
|
+
};
|
169
|
+
}
|
170
|
+
};
|
171
|
+
},
|
172
|
+
|
173
|
+
toBeObject: function() {
|
174
|
+
return {
|
175
|
+
compare: function(actual) {
|
176
|
+
return {
|
177
|
+
pass: compareConstructor(actual, Object),
|
178
|
+
message: "Expected " + actual + " to be an Object"
|
179
|
+
};
|
180
|
+
}
|
181
|
+
};
|
182
|
+
},
|
183
|
+
|
184
|
+
toBeArray: function() {
|
185
|
+
return {
|
186
|
+
compare: function(actual) {
|
187
|
+
return {
|
188
|
+
pass: compareConstructor(actual, Array),
|
189
|
+
message: "Expected " + actual + " to be an Array"
|
190
|
+
};
|
191
|
+
}
|
192
|
+
};
|
193
|
+
},
|
194
|
+
|
195
|
+
toBeNumber: function() {
|
196
|
+
return {
|
197
|
+
compare: function(actual) {
|
198
|
+
return {
|
199
|
+
pass: compareConstructor(actual, Number),
|
200
|
+
message: "Expected " + actual + " to be a Number"
|
201
|
+
};
|
202
|
+
}
|
203
|
+
};
|
204
|
+
},
|
205
|
+
|
206
|
+
toBeString: function() {
|
207
|
+
return {
|
208
|
+
compare: function(actual) {
|
209
|
+
return {
|
210
|
+
pass: compareConstructor(actual, String),
|
211
|
+
message: "Expected " + actual + " to be a String"
|
212
|
+
};
|
213
|
+
}
|
214
|
+
};
|
215
|
+
},
|
216
|
+
|
217
|
+
toBeFunction: function() {
|
218
|
+
return {
|
219
|
+
compare: function(actual) {
|
220
|
+
return {
|
221
|
+
pass: compareConstructor(actual, Function),
|
222
|
+
message: "Expected " + actual + " to be a Function"
|
223
|
+
};
|
224
|
+
}
|
225
|
+
};
|
226
|
+
},
|
227
|
+
|
228
|
+
toBeTypeof: function() {
|
229
|
+
return {
|
230
|
+
compare: function(actual, b) {
|
231
|
+
return {
|
232
|
+
pass: compareConstructor(actual, b),
|
233
|
+
message: "Expected " + actual + " to be a typeof " + b
|
234
|
+
};
|
235
|
+
}
|
236
|
+
};
|
237
|
+
},
|
238
|
+
|
239
|
+
toDeepEqual: function() {
|
240
|
+
var eq = function(a, b, aStack, bStack) {
|
241
|
+
// Identical objects are equal. `0 === -0`, but they aren't identical.
|
242
|
+
// See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
|
243
|
+
if (a === b) return a !== 0 || 1 / a == 1 / b;
|
244
|
+
// A strict comparison is necessary because `null == undefined`.
|
245
|
+
if (a == null || b == null) return a === b;
|
246
|
+
// Compare `[[Class]]` names.
|
247
|
+
var className = toString.call(a);
|
248
|
+
if (className != toString.call(b)) return false;
|
249
|
+
switch (className) {
|
250
|
+
// Strings, numbers, dates, and booleans are compared by value.
|
251
|
+
case '[object String]':
|
252
|
+
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
|
253
|
+
// equivalent to `new String("5")`.
|
254
|
+
return a == String(b);
|
255
|
+
case '[object Number]':
|
256
|
+
// `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
|
257
|
+
// other numeric values.
|
258
|
+
return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
|
259
|
+
case '[object Date]':
|
260
|
+
case '[object Boolean]':
|
261
|
+
// Coerce dates and booleans to numeric primitive values. Dates are compared by their
|
262
|
+
// millisecond representations. Note that invalid dates with millisecond representations
|
263
|
+
// of `NaN` are not equivalent.
|
264
|
+
return +a == +b;
|
265
|
+
// RegExps are compared by their source patterns and flags.
|
266
|
+
case '[object RegExp]':
|
267
|
+
return a.source == b.source &&
|
268
|
+
a.global == b.global &&
|
269
|
+
a.multiline == b.multiline &&
|
270
|
+
a.ignoreCase == b.ignoreCase;
|
271
|
+
}
|
272
|
+
if (typeof a != 'object' || typeof b != 'object') return false;
|
273
|
+
// Assume equality for cyclic structures. The algorithm for detecting cyclic
|
274
|
+
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
|
275
|
+
var length = aStack.length;
|
276
|
+
while (length--) {
|
277
|
+
// Linear search. Performance is inversely proportional to the number of
|
278
|
+
// unique nested structures.
|
279
|
+
if (aStack[length] == a) return bStack[length] == b;
|
280
|
+
}
|
281
|
+
// Objects with different constructors are not equivalent, but `Object`s
|
282
|
+
// from different frames are.
|
283
|
+
var aCtor = a.constructor, bCtor = b.constructor;
|
284
|
+
if (aCtor !== bCtor && !(aCtor == Function && (aCtor instanceof aCtor) &&
|
285
|
+
bCtor == Function && (bCtor instanceof bCtor))
|
286
|
+
&& ('constructor' in a && 'constructor' in b)) {
|
287
|
+
return false;
|
288
|
+
}
|
289
|
+
// Add the first object to the stack of traversed objects.
|
290
|
+
aStack.push(a);
|
291
|
+
bStack.push(b);
|
292
|
+
var size = 0, result = true;
|
293
|
+
// Recursively compare objects and arrays.
|
294
|
+
if (className == '[object Array]') {
|
295
|
+
// Compare array lengths to determine if a deep comparison is necessary.
|
296
|
+
size = a.length;
|
297
|
+
result = size == b.length;
|
298
|
+
if (result) {
|
299
|
+
// Deep compare the contents, ignoring non-numeric properties.
|
300
|
+
while (size--) {
|
301
|
+
if (!(result = eq(a[size], b[size], aStack, bStack))) break;
|
302
|
+
}
|
303
|
+
}
|
304
|
+
} else {
|
305
|
+
// Deep compare objects.
|
306
|
+
for (var key in a) {
|
307
|
+
if (a.hasOwnProperty(key)) {
|
308
|
+
// Count the expected number of properties.
|
309
|
+
size++;
|
310
|
+
// Deep compare each member.
|
311
|
+
if (!(result = b.hasOwnProperty(key) && eq(a[key], b[key], aStack, bStack))) break;
|
312
|
+
}
|
313
|
+
}
|
314
|
+
// Ensure that both objects contain the same number of properties.
|
315
|
+
if (result) {
|
316
|
+
for (key in b) {
|
317
|
+
if (b.hasOwnProperty(key) && !(size--)) break;
|
318
|
+
}
|
319
|
+
result = !size;
|
320
|
+
}
|
321
|
+
}
|
322
|
+
// Remove the first object from the stack of traversed objects.
|
323
|
+
aStack.pop();
|
324
|
+
bStack.pop();
|
325
|
+
return result;
|
326
|
+
};
|
327
|
+
return {
|
328
|
+
compare: function(actual, expected) {
|
329
|
+
return {
|
330
|
+
pass: eq(actual, expected, [], []),
|
331
|
+
message: "Expected " + actual + " to deep equal " + expected
|
332
|
+
};
|
333
|
+
}
|
334
|
+
};
|
335
|
+
},
|
336
|
+
|
337
|
+
// jQuery matchers
|
338
|
+
toBeJqueryWrapped: function() {
|
339
|
+
return {
|
340
|
+
compare: function(actual, selector) {
|
341
|
+
return {
|
342
|
+
pass: (selector && actual && actual.selector !== selector) ? false : checkElementExistence(actual),
|
343
|
+
message: "Expected " + actual + " to be a jQuery wrapped element"
|
344
|
+
};
|
345
|
+
}
|
346
|
+
};
|
347
|
+
},
|
348
|
+
|
349
|
+
toHaveClass: function() {
|
350
|
+
return {
|
351
|
+
compare: function(actual, className) {
|
352
|
+
return {
|
353
|
+
pass: actual.hasClass(className),
|
354
|
+
message: "Expected " + actual + " to have class " + className
|
355
|
+
};
|
356
|
+
}
|
357
|
+
};
|
358
|
+
},
|
359
|
+
|
360
|
+
toBeHidden: function() {
|
361
|
+
return {
|
362
|
+
compare: function(actual) {
|
363
|
+
return {
|
364
|
+
pass: !actual.is(":visible"),
|
365
|
+
message: "Expected " + actual + " to be hidden"
|
366
|
+
};
|
367
|
+
}
|
368
|
+
};
|
369
|
+
},
|
370
|
+
|
371
|
+
toBeVisible: function() {
|
372
|
+
return {
|
373
|
+
compare: function(actual) {
|
374
|
+
return {
|
375
|
+
pass: actual.is(":visible"),
|
376
|
+
message: "Expected " + actual + " to be visible"
|
377
|
+
};
|
378
|
+
}
|
379
|
+
};
|
380
|
+
},
|
381
|
+
|
382
|
+
toExist: function() {
|
383
|
+
return {
|
384
|
+
compare: function(actual) {
|
385
|
+
return {
|
386
|
+
pass: actual.length > 0,
|
387
|
+
message: "Expected " + actual + " to exist in the DOM"
|
388
|
+
};
|
389
|
+
}
|
390
|
+
};
|
391
|
+
},
|
392
|
+
|
393
|
+
toHaveText: function() {
|
394
|
+
return {
|
395
|
+
compare: function(actual, text) {
|
396
|
+
return {
|
397
|
+
pass: actual.text().trim() === text,
|
398
|
+
message: "Expected " + actual + " to have text " + '"' + text + '"'
|
399
|
+
};
|
400
|
+
}
|
401
|
+
};
|
402
|
+
},
|
403
|
+
|
404
|
+
toHaveHTML: function() {
|
405
|
+
return {
|
406
|
+
compare: function(actual, html) {
|
407
|
+
return {
|
408
|
+
pass: actual.html().trim() === html,
|
409
|
+
message: "Expected " + actual + " to have HTML " + '"' + html + '"'
|
410
|
+
};
|
411
|
+
}
|
412
|
+
};
|
413
|
+
},
|
414
|
+
|
415
|
+
toBeChecked: function() {
|
416
|
+
return {
|
417
|
+
compare: function(actual) {
|
418
|
+
return {
|
419
|
+
pass: actual.prop("checked"),
|
420
|
+
message: "Expected " + actual + " to be checked"
|
421
|
+
};
|
422
|
+
}
|
423
|
+
};
|
424
|
+
},
|
425
|
+
|
426
|
+
toHaveAttribute: function(attr, value) {
|
427
|
+
return {
|
428
|
+
compare: function(actual, attr, value) {
|
429
|
+
var pass;
|
430
|
+
var message;
|
431
|
+
if (value) {
|
432
|
+
pass = (actual.attr(attr) === value);
|
433
|
+
message = "Expected " + actual + ' to have the "' + attr + '" attribute with a value of "' + value + '"';
|
434
|
+
} else {
|
435
|
+
pass = !!actual.attr(attr);
|
436
|
+
message = "Expected " + actual + ' to have the "' + attr + '" attribute';
|
437
|
+
}
|
438
|
+
return {
|
439
|
+
pass: pass,
|
440
|
+
message: message
|
441
|
+
};
|
442
|
+
}
|
443
|
+
};
|
444
|
+
}
|
445
|
+
});
|
446
|
+
|
447
|
+
// compareConstructor checks an object against a specific type
|
448
|
+
function compareConstructor(a, b) {
|
449
|
+
if (typeof a === "undefined") return false;
|
450
|
+
return a.constructor == b; // double equals is important here, ignore the linter
|
451
|
+
}
|
452
|
+
|
453
|
+
// This function is an exhaustive check for the existence
|
454
|
+
// of a jQuery wrapped element. It requires an element to
|
455
|
+
// be in the DOM and to be jQuery wrapped
|
456
|
+
function checkElementExistence(element) {
|
457
|
+
if (typeof element === "undefined") return false;
|
458
|
+
if (typeof element.selector === "undefined") return false;
|
459
|
+
if (!element.length) return false;
|
460
|
+
return compareConstructor(element, jQuery);
|
461
|
+
}
|
462
|
+
});
|