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,314 @@
|
|
1
|
+
describe("MagicCarpet", function() {
|
2
|
+
var subject;
|
3
|
+
|
4
|
+
beforeEach(function() {
|
5
|
+
subject = MagicCarpet;
|
6
|
+
});
|
7
|
+
|
8
|
+
afterEach(function() {
|
9
|
+
$("#magic-carpet").remove();
|
10
|
+
});
|
11
|
+
|
12
|
+
it("has its async property set to false by default", function(){
|
13
|
+
expect(subject.async).toBeFalse();
|
14
|
+
});
|
15
|
+
|
16
|
+
it("has its asyncComplete property set to true by default", function(){
|
17
|
+
expect(subject.asyncComplete).toBeTrue();
|
18
|
+
});
|
19
|
+
|
20
|
+
it("has an object for caching request results", function(){
|
21
|
+
expect(subject.cache).toBeObject();
|
22
|
+
});
|
23
|
+
|
24
|
+
describe("initialize", function() {
|
25
|
+
beforeEach(function() {
|
26
|
+
spyOn(subject, "cacheElements");
|
27
|
+
spyOn(subject, "appendSandbox");
|
28
|
+
spyOn(subject, "bindAll");
|
29
|
+
subject.initialize();
|
30
|
+
});
|
31
|
+
|
32
|
+
it("caches the necessary elements", function() {
|
33
|
+
expect(subject.cacheElements).toHaveBeenCalled();
|
34
|
+
});
|
35
|
+
|
36
|
+
it("appends the sandbox", function(){
|
37
|
+
expect(subject.appendSandbox).toHaveBeenCalled();
|
38
|
+
});
|
39
|
+
|
40
|
+
it("binds all of its functions", function(){
|
41
|
+
expect(subject.bindAll).toHaveBeenCalled();
|
42
|
+
});
|
43
|
+
});
|
44
|
+
|
45
|
+
describe("bindAll", function(){
|
46
|
+
var dummyFunction;
|
47
|
+
beforeEach(function() {
|
48
|
+
subject.dummyOption = false;
|
49
|
+
dummyFunction = function() { this.dummyOption = true; };
|
50
|
+
subject.dummy = dummyFunction;
|
51
|
+
subject.bindAll();
|
52
|
+
});
|
53
|
+
|
54
|
+
afterEach(function() {
|
55
|
+
delete subject.dummy;
|
56
|
+
delete subject.dummyOption;
|
57
|
+
});
|
58
|
+
|
59
|
+
it("binds all methods", function(){
|
60
|
+
expect(subject.dummy).not.toEqual(dummyFunction);
|
61
|
+
subject.dummy();
|
62
|
+
expect(subject.dummyOption).toBeTrue();
|
63
|
+
});
|
64
|
+
});
|
65
|
+
|
66
|
+
describe("bind", function(){
|
67
|
+
it("binds the function to the context", function(){
|
68
|
+
var obj = {};
|
69
|
+
obj.func = function(arg) { this.funcArg = arg; };
|
70
|
+
subject.bind(obj, "func");
|
71
|
+
var func = obj.func;
|
72
|
+
func("arg");
|
73
|
+
expect(obj.funcArg).toEqual("arg");
|
74
|
+
});
|
75
|
+
});
|
76
|
+
|
77
|
+
describe("cacheElements", function() {
|
78
|
+
beforeEach(function() {
|
79
|
+
spyOn(subject, "createSandbox").and.returnValue("sandbox");
|
80
|
+
subject.cacheElements();
|
81
|
+
});
|
82
|
+
|
83
|
+
it("caches a sandbox", function() {
|
84
|
+
expect(subject.sandbox).toEqual("sandbox");
|
85
|
+
});
|
86
|
+
});
|
87
|
+
|
88
|
+
describe("createSandbox", function() {
|
89
|
+
it("returns a div", function() {
|
90
|
+
expect(subject.createSandbox().tagName).toEqual("DIV");
|
91
|
+
});
|
92
|
+
|
93
|
+
it("returns a div with an ID of #magic-carpet", function() {
|
94
|
+
expect(subject.createSandbox().getAttribute("id")).toEqual("magic-carpet");
|
95
|
+
});
|
96
|
+
});
|
97
|
+
|
98
|
+
describe("appendSandbox", function() {
|
99
|
+
beforeEach(function() {
|
100
|
+
subject.cacheElements();
|
101
|
+
subject.appendSandbox();
|
102
|
+
});
|
103
|
+
|
104
|
+
it("appends the sandbox to the body", function() {
|
105
|
+
expect(subject.sandbox).toBeDefined();
|
106
|
+
expect(subject.sandbox).toEqual($("body #magic-carpet")[0]);
|
107
|
+
});
|
108
|
+
});
|
109
|
+
|
110
|
+
describe("emptySandbox", function(){
|
111
|
+
beforeEach(function() {
|
112
|
+
subject.cacheElements();
|
113
|
+
subject.sandbox.innerHTML = '<div id="dummy"></div>';
|
114
|
+
subject.emptySandbox();
|
115
|
+
});
|
116
|
+
|
117
|
+
it("empties the sandbox", function(){
|
118
|
+
expect($("#dummy")[0]).toBeUndefined();
|
119
|
+
expect(subject.sandbox.innerHTML).toEqual("");
|
120
|
+
});
|
121
|
+
});
|
122
|
+
|
123
|
+
describe("request", function(){
|
124
|
+
var requestData;
|
125
|
+
beforeEach(function() {
|
126
|
+
subject.cacheElements();
|
127
|
+
spyOn(subject, "fetch");
|
128
|
+
requestData = { some: "template" };
|
129
|
+
});
|
130
|
+
|
131
|
+
it("fetches the markup if the request isn't cached", function(){
|
132
|
+
subject.cache = {};
|
133
|
+
subject.request(requestData);
|
134
|
+
expect(subject.fetch).toHaveBeenCalledWith(requestData);
|
135
|
+
expect(subject.sandbox.innerHTML).toEqual("");
|
136
|
+
});
|
137
|
+
|
138
|
+
it("puts the markup on the page when it's already cached", function(){
|
139
|
+
subject.cache[$.param(requestData)] = "markup";
|
140
|
+
subject.request(requestData);
|
141
|
+
expect(subject.fetch).not.toHaveBeenCalled();
|
142
|
+
expect(subject.sandbox.innerHTML).toEqual("markup");
|
143
|
+
});
|
144
|
+
});
|
145
|
+
|
146
|
+
describe("fetch", function(){
|
147
|
+
var arg;
|
148
|
+
beforeEach(function() {
|
149
|
+
subject.asyncComplete = true;
|
150
|
+
subject.lastRequest = undefined;
|
151
|
+
spyOn($, "ajax").and.returnValue(promiseStub);
|
152
|
+
subject.async = "default async setting";
|
153
|
+
subject.fetch("data");
|
154
|
+
arg = $.ajax.calls.argsFor(0)[0];
|
155
|
+
});
|
156
|
+
|
157
|
+
it("makes a get request to /magic_carpet", function(){
|
158
|
+
expect(arg.url).toEqual("/magic_carpet");
|
159
|
+
expect(arg.method).toEqual("get");
|
160
|
+
});
|
161
|
+
|
162
|
+
it("uses the global magic carpet async setting", function(){
|
163
|
+
expect(arg.async).toEqual("default async setting");
|
164
|
+
});
|
165
|
+
|
166
|
+
it("passes its argument as data", function(){
|
167
|
+
expect(arg.data).toEqual("data");
|
168
|
+
});
|
169
|
+
|
170
|
+
it("sets asyncComplete to false", function(){
|
171
|
+
expect(subject.asyncComplete).toBeFalse();
|
172
|
+
});
|
173
|
+
|
174
|
+
it("handles success", function(){
|
175
|
+
expect(promiseStub.done).toHaveBeenCalledWith(subject.handleSuccess);
|
176
|
+
});
|
177
|
+
|
178
|
+
it("handles failure", function(){
|
179
|
+
expect(promiseStub.fail).toHaveBeenCalledWith(subject.handleFailure);
|
180
|
+
});
|
181
|
+
|
182
|
+
it("cleans up after itself", function(){
|
183
|
+
expect(promiseStub.always).toHaveBeenCalledWith(subject.afterRequest);
|
184
|
+
});
|
185
|
+
|
186
|
+
it("caches the request object", function(){
|
187
|
+
expect(subject.lastRequest).toEqual("data");
|
188
|
+
});
|
189
|
+
});
|
190
|
+
|
191
|
+
describe("handleSuccess", function(){
|
192
|
+
var lastRequest;
|
193
|
+
var markup;
|
194
|
+
beforeEach(function() {
|
195
|
+
subject.appendSandbox();
|
196
|
+
lastRequest = { some: "template" };
|
197
|
+
subject.lastRequest = lastRequest;
|
198
|
+
subject.cache = {};
|
199
|
+
markup = '<div id="fresh-markup"></div>';
|
200
|
+
subject.handleSuccess(markup);
|
201
|
+
});
|
202
|
+
|
203
|
+
it("puts the markup in the sandbox", function(){
|
204
|
+
expect($("#magic-carpet #fresh-markup")[0]).toBeDefined();
|
205
|
+
});
|
206
|
+
|
207
|
+
it("caches the markup", function(){
|
208
|
+
expect(subject.cache[$.param(lastRequest)]).toEqual(markup);
|
209
|
+
});
|
210
|
+
});
|
211
|
+
|
212
|
+
describe("handleFailure", function(){
|
213
|
+
it("throws an error with a message", function(){
|
214
|
+
var errorObj = { error: "There was a problem" };
|
215
|
+
var response = { responseJSON: errorObj };
|
216
|
+
expect(function() {
|
217
|
+
subject.handleFailure(response);
|
218
|
+
}).toThrow(new Error(errorObj.error));
|
219
|
+
});
|
220
|
+
});
|
221
|
+
|
222
|
+
describe("afterRequest", function(){
|
223
|
+
beforeEach(function() {
|
224
|
+
subject.asyncComplete = false;
|
225
|
+
subject.afterRequest();
|
226
|
+
});
|
227
|
+
|
228
|
+
it("sets asyncComplete to true", function(){
|
229
|
+
expect(subject.asyncComplete).toBeTrue();
|
230
|
+
});
|
231
|
+
});
|
232
|
+
|
233
|
+
describe("integration specs", function(){
|
234
|
+
beforeEach(function() {
|
235
|
+
subject.async = false;
|
236
|
+
subject.initialize();
|
237
|
+
});
|
238
|
+
|
239
|
+
describe("templates", function(){
|
240
|
+
it("renders templates", function(){
|
241
|
+
subject.request({
|
242
|
+
controller_name: "Wishes",
|
243
|
+
template: "plain"
|
244
|
+
});
|
245
|
+
expect($("#magic-carpet h1")[0]).toBeDefined();
|
246
|
+
});
|
247
|
+
|
248
|
+
it("action_name can be used instead of template", function(){
|
249
|
+
subject.request({
|
250
|
+
controller_name: "Wishes",
|
251
|
+
action_name: "plain"
|
252
|
+
});
|
253
|
+
expect($("#magic-carpet h1")[0]).toBeDefined();
|
254
|
+
});
|
255
|
+
|
256
|
+
it("renders partials", function(){
|
257
|
+
subject.request({
|
258
|
+
controller_name: "Wishes",
|
259
|
+
partial: "some_partial"
|
260
|
+
});
|
261
|
+
expect($("#magic-carpet h1")[0]).toBeDefined();
|
262
|
+
});
|
263
|
+
|
264
|
+
it("renders local variables", function(){
|
265
|
+
subject.request({
|
266
|
+
controller_name: "Wishes",
|
267
|
+
partial: "wish_list_item",
|
268
|
+
locals: {
|
269
|
+
wish: { id: 1, model: "Wish", text: "some wish text" }
|
270
|
+
}
|
271
|
+
});
|
272
|
+
expect($("#magic-carpet li")[0]).toBeDefined();
|
273
|
+
});
|
274
|
+
|
275
|
+
it("renders collections (with 'as' option)", function(){
|
276
|
+
subject.request({
|
277
|
+
controller_name: "Wishes",
|
278
|
+
partial: "wish_list_item",
|
279
|
+
collection: [
|
280
|
+
{ id: 1, model: "Wish", text: "wish text" },
|
281
|
+
{ id: 2, model: "Wish", text: "wish text" },
|
282
|
+
{ id: 3, model: "Wish", text: "wish text" }
|
283
|
+
],
|
284
|
+
as: "wish"
|
285
|
+
});
|
286
|
+
expect($("#magic-carpet li").length).toEqual(3);
|
287
|
+
});
|
288
|
+
|
289
|
+
it("renders templates with instance variables", function(){
|
290
|
+
subject.request({
|
291
|
+
controller_name: "Wishes",
|
292
|
+
template: "new",
|
293
|
+
instance_variables: {
|
294
|
+
wish: {
|
295
|
+
model: "Wish"
|
296
|
+
}
|
297
|
+
}
|
298
|
+
});
|
299
|
+
expect($("#magic-carpet #new_wish")[0]).toBeDefined();
|
300
|
+
});
|
301
|
+
|
302
|
+
describe("errors", function(){
|
303
|
+
it("renders missing controller errors", function(){
|
304
|
+
expect(function() {
|
305
|
+
subject.request({
|
306
|
+
controller_name: "blort",
|
307
|
+
action_name: "new"
|
308
|
+
});
|
309
|
+
}).toThrow(new Error("Magic Carpet Error: wrong constant name blortController for 'new' template."));
|
310
|
+
});
|
311
|
+
});
|
312
|
+
});
|
313
|
+
});
|
314
|
+
});
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# path to parent directory of src_files
|
2
|
+
# relative path from Rails.root
|
3
|
+
# defaults to app/assets/javascripts
|
4
|
+
src_dir: "app/assets/javascripts"
|
5
|
+
|
6
|
+
# list of file expressions to include as source files
|
7
|
+
# relative path from src_dir
|
8
|
+
src_files:
|
9
|
+
- "application.js"
|
10
|
+
|
11
|
+
# path to parent directory of spec_files
|
12
|
+
# relative path from Rails.root
|
13
|
+
# defaults to spec/javascripts
|
14
|
+
spec_dir: spec/javascripts
|
15
|
+
|
16
|
+
# list of file expressions to include as helpers into spec runner
|
17
|
+
# relative path from spec_dir
|
18
|
+
helpers:
|
19
|
+
- "helpers/**/*.js"
|
20
|
+
|
21
|
+
# list of file expressions to include as specs into spec runner
|
22
|
+
# relative path from spec_dir
|
23
|
+
spec_files:
|
24
|
+
- "**/*[Ss]pec.js"
|
25
|
+
|
26
|
+
# path to directory of temporary files
|
27
|
+
# (spec runner and asset cache)
|
28
|
+
# defaults to tmp/jasmine
|
29
|
+
tmp_dir: "tmp/jasmine"
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|