magic_lamp 0.9.0 → 0.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +79 -75
- data/app/assets/javascripts/magic_lamp.js +2 -0
- data/app/assets/javascripts/magic_lamp/application.js +14 -0
- data/app/assets/javascripts/magic_lamp/boot.js +1 -0
- data/app/assets/javascripts/magic_lamp/genie.js +97 -0
- data/app/assets/javascripts/magic_lamp/magic_lamp.js +35 -0
- data/app/assets/stylesheets/magic_lamp/application.css +15 -0
- data/app/controllers/magic_lamp/application_controller.rb +4 -0
- data/app/controllers/magic_lamp/fixtures_controller.rb +35 -0
- data/app/helpers/magic_lamp/application_helper.rb +4 -0
- data/app/views/layouts/magic_lamp/application.html.erb +14 -0
- data/config/routes.rb +4 -0
- data/lib/magic_lamp.rb +83 -20
- data/lib/magic_lamp/engine.rb +9 -0
- data/lib/magic_lamp/fixture_creator.rb +2 -10
- data/lib/magic_lamp/render_catcher.rb +15 -0
- data/lib/magic_lamp/version.rb +1 -1
- data/lib/tasks/magic_lamp_tasks.rake +4 -0
- data/spec/controllers/magic_lamp/fixtures_controller_spec.rb +73 -0
- data/spec/dummy/app/views/orders/bar.html.erb +1 -0
- data/spec/dummy/config/application.rb +7 -1
- data/spec/dummy/config/environments/development.rb +1 -0
- data/spec/dummy/config/environments/production.rb +1 -2
- data/spec/dummy/config/initializers/assets.rb +8 -0
- data/spec/dummy/config/routes.rb +2 -54
- data/spec/dummy/config/secrets.yml +2 -2
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/{20140623002513_create_orders.rb → 20140801133550_create_orders.rb} +0 -0
- data/spec/dummy/db/schema.rb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +61270 -0
- data/spec/dummy/log/test.log +25531 -13475
- data/spec/dummy/spec/magical/magic_lamp.rb +12 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/05ecd34d23e110728a2f04ad35ec8834 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/09bc89d8ac4ccacfcf2f4db466e7735f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/0dc7d2551b4cf3f654b16902e208703c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/18650d8ff9b0a83b32e55b58917ec791 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/18a0c4b365b6a030c56ac85e8aa6bd6e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/199574de4a8028cea9307b5e55d8f8be +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1a894d48e2e8089537ae95e3798d49a2 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/24591221375d773f23385966709a900b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2bd1588b3767c789462d94a5fd27df88 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2ccef21649a61deac2c84f622753b77b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/38b32c335f7377670791219def8ce6d7 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/38d787c2adf281dccb80274318dcf538 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3929ae7429411cd81cad5d5ed72b4912 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3c20b64b10f3325ed7f3b6695648fd8d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/480053cec74750ba76acfd86f7ff1051 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5bbf09297502a156801e9c65f4bd3db7 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/5ced43e55c875dddf3aca75fa148ca3e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6284ee4c2b5be7652a79edb6d4705cee +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/68b6ad376fe519ddaf9b84e87c2b077c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/69080d1368510f3bcff08c323a5913a7 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6c1f143bdf6ffea1fb2fa7b967f9a437 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/759e97d6d411bc4cef7055a778e1bef3 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7f7dcf7837dbb7f150b7364ad7920712 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/86023efec2465a88617e5a47a38f1f55 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/87e991f1f72e200b4bded1eb8871ee31 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/88fe64427f1fff8e41ca8ad0170da88a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8d1d9aa6d95fc9c10dfc6e6d49778b2f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8ed4b4f20fb65446181984e6df7d7c9b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8f4a370f455559b7a209ecd758a3bb3d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/96210dc070e479fcee862294afe5efc1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/972b6b0bb1fc0b1123077b4b2f4394bd +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/9825272284630c2926f661645205382a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/9fdefd8efa47bbe9a18f1faff6252e95 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b212d365916d6c2f783d5d73ae451562 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b2a142b210c2cbfe4a58040684b3c33c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b458300066aff956f7af9a6d2ae99abc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b98b0da97c57b492a76eeb1d0faf80d7 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/bceac3272b3e329aba55cb672fa18719 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/bfa154e8a12acdbc85028ad8130d9043 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c5ff389414942659c1c69d2f4f32978c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cf573b52d944e8aea7f1dc03f9be9b2c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d42871ab2eba219379cd7aa9f993c575 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d98de652252dc6ae11b5b6db5588705b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/db0cbe7314816ff20016f88d20dc5569 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ed02174e8f8230d1ff62c67e51f01576 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f0aa53eb377a5d7cc83657ef33b02d25 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f1ffba5065c7038b154a287981b34743 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f5d1b7d2ec1c89dc32cc982b43502dc8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f6256b2e4e609981d9eb420aae5bef46 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/fd3d67db3401095777d74ebf3cb94a01 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/fdc3718e0a84d340a897f87179d95c84 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/2fdee9aa34e89b0182a7523c4484e5f6 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/36a1fb9df9acb7490c5ac1284b2de56b +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/b78b6f63e1fe791ab77083cd45eb5105 +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/e4468469b981ba614a29626880137332 +0 -0
- data/spec/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/pids/server.pid +1 -0
- data/spec/javascripts/genie_spec.js +210 -0
- data/spec/javascripts/magic_lamp_spec.js +185 -0
- data/spec/javascripts/spec_helper.js +109 -0
- data/spec/javascripts/support/sinon-chai.js +126 -0
- data/spec/javascripts/support/underscore-1.6.js +1343 -0
- data/spec/lib/fixture_creator_spec.rb +6 -17
- data/spec/lib/magic_lamp_spec.rb +143 -56
- data/spec/lib/render_catcher_spec.rb +35 -0
- data/spec/rails_helper.rb +3 -13
- data/spec/spec_helper.rb +2 -3
- data/spec/teaspoon_env.rb +186 -0
- metadata +206 -15
- data/lib/tasks/magic_lamp_tasks.rb +0 -44
- data/spec/dummy/spec/magic_lamp.rb +0 -4
- data/spec/dummy/spec/magic_lamp/foo/foo_lamp.rb +0 -1
- data/spec/dummy/spec/magic_lamp/rake/rake_lamp.rb +0 -3
- data/spec/integration/integration_spec.rb +0 -21
- data/spec/tasks/magic_lamp_tasks_spec.rb +0 -34
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
88207
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
describe('Genie', function() {
|
|
2
|
+
var subject;
|
|
3
|
+
beforeEach(function() {
|
|
4
|
+
subject = new MagicLamp.Genie;
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
describe('class', function() {
|
|
8
|
+
it('is a function', function() {
|
|
9
|
+
expect(MagicLamp.Genie).to.be.a('function');
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
describe('cache', function() {
|
|
14
|
+
it('is an object', function() {
|
|
15
|
+
expect(subject.cache).to.be.a('object');
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe('cacheOnly', function() {
|
|
20
|
+
it('is false by default', function() {
|
|
21
|
+
expect(subject.cacheOnly).to.equal(false);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('namespace', function() {
|
|
26
|
+
it('is MagicLamp', function() {
|
|
27
|
+
expect(subject.namespace).to.equal(MagicLamp);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('#load', function() {
|
|
32
|
+
var path;
|
|
33
|
+
beforeEach(function() {
|
|
34
|
+
path = 'orders/foo';
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
afterEach(function() {
|
|
38
|
+
removeNode(subject.fixtureContainer);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('cacheOnly false', function() {
|
|
42
|
+
it('requests the fixture and adds it to the cache', function() {
|
|
43
|
+
spyOn(subject, 'xhrRequest');
|
|
44
|
+
subject.load(path);
|
|
45
|
+
expect(subject.xhrRequest).to.have.been.calledOnce;
|
|
46
|
+
expect(subject.cache[path]).to.equal('foo\n');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('appends the fixture container with the fixture to the dom', function() {
|
|
50
|
+
expect(testFixtureContainer()).to.equal(null);
|
|
51
|
+
subject.load(path);
|
|
52
|
+
expect(testFixtureContainer().innerHTML).to.equal('foo\n');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
describe('cached', function() {
|
|
57
|
+
beforeEach(function() {
|
|
58
|
+
subject.cache[path] = 'howdy';
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('does not make a request', function() {
|
|
62
|
+
spyOn(subject, 'xhrRequest');
|
|
63
|
+
subject.load(path);
|
|
64
|
+
expect(subject.xhrRequest).to.not.have.been.calledOnce;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('appends the fixture container to the dom with the cached fixture', function() {
|
|
68
|
+
expect(testFixtureContainer()).to.equal(null);
|
|
69
|
+
subject.load(path);
|
|
70
|
+
expect(testFixtureContainer().innerHTML).to.equal('howdy');
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('cacheOnly true', function() {
|
|
76
|
+
beforeEach(function() {
|
|
77
|
+
subject.cacheOnly = true;
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('does not make a request', function() {
|
|
81
|
+
spyOn(subject, 'xhrRequest');
|
|
82
|
+
subject.cache[path] = 'howdy';
|
|
83
|
+
subject.load(path);
|
|
84
|
+
expect(subject.xhrRequest).to.not.have.been.calledOnce;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('throws an error if the fixture is not in the cache', function() {
|
|
88
|
+
expect(function() {
|
|
89
|
+
subject.load(path);
|
|
90
|
+
}).to.throw(/The fixture "orders\/foo" was not preloaded. Is the fixture registered\? Such a bummer./);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe('#preload', function() {
|
|
96
|
+
it('requests all of the fixtures and puts them in the cache', function() {
|
|
97
|
+
subject.preload();
|
|
98
|
+
expect(subject.cache).to.have.keys(['orders/foo', 'orders/bar', 'orders/form']);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('sets cacheOnly to true', function() {
|
|
102
|
+
subject.preload();
|
|
103
|
+
expect(subject.cacheOnly).to.equal(true);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('makes a request to the specified path if defined', function() {
|
|
107
|
+
var path = MagicLamp.path = '/normal_lamp';
|
|
108
|
+
stub(subject, 'xhrRequest', { responseText: '{}' });
|
|
109
|
+
subject.preload();
|
|
110
|
+
|
|
111
|
+
delete MagicLamp.path;
|
|
112
|
+
|
|
113
|
+
expect(subject.xhrRequest).to.have.been.calledWith(path);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe('#createFixtureContainer', function() {
|
|
118
|
+
it('creates a div with an id of "magic-lamp" and caches it', function() {
|
|
119
|
+
subject.createFixtureContainer();
|
|
120
|
+
expect(subject.fixtureContainer.tagName).to.equal('DIV');
|
|
121
|
+
expect(subject.fixtureContainer.id).to.equal('magic-lamp');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('creates a div with an id of MagicLamp.id if present', function() {
|
|
125
|
+
var id = MagicLamp.id = 'footastic';
|
|
126
|
+
subject.createFixtureContainer();
|
|
127
|
+
delete MagicLamp.id;
|
|
128
|
+
expect(subject.fixtureContainer.id).to.equal(id);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe('#appendFixtureContainer', function() {
|
|
133
|
+
beforeEach(function() {
|
|
134
|
+
subject.createFixtureContainer();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
afterEach(function() {
|
|
138
|
+
removeNode(subject.fixtureContainer);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('appends the fixtureContainer to the body', function() {
|
|
142
|
+
expect(testFixtureContainer()).to.equal(null);
|
|
143
|
+
subject.appendFixtureContainer();
|
|
144
|
+
expect(testFixtureContainer()).to.equal(subject.fixtureContainer);
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
describe('#removeFixtureContainer', function() {
|
|
149
|
+
beforeEach(function() {
|
|
150
|
+
subject.createFixtureContainer();
|
|
151
|
+
subject.appendFixtureContainer();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
afterEach(function() {
|
|
155
|
+
removeNode(subject.fixtureContainer);
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('removes the fixture container from the dom', function() {
|
|
159
|
+
expect(testFixtureContainer()).to.equal(subject.fixtureContainer);
|
|
160
|
+
subject.removeFixtureContainer();
|
|
161
|
+
expect(testFixtureContainer()).to.equal(null);
|
|
162
|
+
expect(subject.fixtureContainer).to.be.undefined;
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
it('removes the fixture container from the genie instance', function() {
|
|
166
|
+
expect(testFixtureContainer()).to.equal(subject.fixtureContainer);
|
|
167
|
+
subject.removeFixtureContainer();
|
|
168
|
+
expect(subject.fixtureContainer).to.be.undefined;
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
describe('#handleError', function() {
|
|
173
|
+
it('throws an informative error', function() {
|
|
174
|
+
var message = 'something informative';
|
|
175
|
+
|
|
176
|
+
expect(function() {
|
|
177
|
+
subject.handleError(message);
|
|
178
|
+
}).to.throw(message);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
describe('#xhrRequest', function() {
|
|
183
|
+
it('makes an get request to the specified path', function() {
|
|
184
|
+
var xhrProto = XMLHttpRequest.prototype;
|
|
185
|
+
stub(subject, 'handleError', true);
|
|
186
|
+
stub(xhrProto, 'open', true);
|
|
187
|
+
stub(xhrProto, 'send', true);
|
|
188
|
+
var path = '/magic_lamp';
|
|
189
|
+
subject.xhrRequest(path);
|
|
190
|
+
|
|
191
|
+
expect(xhrProto.open).to.have.been.calledWith('GET', path, false);
|
|
192
|
+
expect(xhrProto.send).to.have.been.calledOnce;
|
|
193
|
+
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it('returns the xhr object', function() {
|
|
197
|
+
var path = '/magic_lamp';
|
|
198
|
+
var result = subject.xhrRequest(path);
|
|
199
|
+
|
|
200
|
+
expect(result.constructor).to.equal(XMLHttpRequest);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
it('calls handleError if the status is not 200', function() {
|
|
204
|
+
stub(subject, 'handleError', true);
|
|
205
|
+
var path = '/magic_lamp/foo/bar';
|
|
206
|
+
var xhr = subject.xhrRequest(path);
|
|
207
|
+
expect(subject.handleError).to.have.been.calledWith(xhr.responseText);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
});
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
describe('MagicLamp', function() {
|
|
2
|
+
var subject;
|
|
3
|
+
beforeEach(function() {
|
|
4
|
+
subject = MagicLamp;
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
it('is an object', function() {
|
|
8
|
+
expect(subject).to.be.a('object');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
describe('#initialize', function() {
|
|
12
|
+
beforeEach(function() {
|
|
13
|
+
subject.initialize();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
afterEach(function() {
|
|
17
|
+
delete subject.genie;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('sets genie to a new genie instance', function() {
|
|
21
|
+
expect(subject.genie).to.be.an.instanceof(subject.Genie);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('#globalize', function() {
|
|
26
|
+
beforeEach(function() {
|
|
27
|
+
subject.globalize();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
afterEach(function() {
|
|
31
|
+
_(['load', 'preload', 'clean']).each(function(method) {
|
|
32
|
+
delete window[method];
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('puts #load on window', function() {
|
|
37
|
+
expect(window.load).to.be.a('function');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('binds #load', function() {
|
|
41
|
+
stub(subject, 'load', true);
|
|
42
|
+
load('orders/foo');
|
|
43
|
+
expect(subject.load).to.have.been.calledWith('orders/foo');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('puts #clean on window', function() {
|
|
47
|
+
expect(window.clean).to.be.a('function');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('binds #clean', function() {
|
|
51
|
+
stub(subject, 'clean', true);
|
|
52
|
+
clean();
|
|
53
|
+
expect(subject.clean).to.have.been.calledOnce;
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('#load', function() {
|
|
58
|
+
beforeEach(function() {
|
|
59
|
+
subject.initialize();
|
|
60
|
+
stub(subject.genie, 'load', true);
|
|
61
|
+
subject.load('foo', 'bar', 'baz');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
afterEach(function() {
|
|
65
|
+
delete subject.genie;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('passes through to its genie instance', function() {
|
|
69
|
+
expect(subject.genie.load).to.have.been.calledWith('foo', 'bar', 'baz');
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe('#preload', function() {
|
|
74
|
+
beforeEach(function() {
|
|
75
|
+
subject.initialize();
|
|
76
|
+
stub(subject.genie, 'preload', true);
|
|
77
|
+
subject.preload('foo', 'bar', 'baz');
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
afterEach(function() {
|
|
81
|
+
delete subject.genie;
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('passes through to its genie instance', function() {
|
|
85
|
+
expect(subject.genie.preload).to.have.been.calledWith('foo', 'bar', 'baz');
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('#clean', function() {
|
|
90
|
+
beforeEach(function() {
|
|
91
|
+
subject.initialize();
|
|
92
|
+
stub(subject.genie, 'removeFixtureContainer', true);
|
|
93
|
+
subject.clean();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
afterEach(function() {
|
|
97
|
+
delete subject.genie;
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('calls removeFixtureContainer on its genie instance', function() {
|
|
101
|
+
expect(subject.genie.removeFixtureContainer).to.have.been.calledOnce;
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
describe('aliases', function() {
|
|
106
|
+
it('preload as "massage"', function() {
|
|
107
|
+
expect(subject.massage).to.equal(subject.preload);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('preload as "wishForMoreWishes"', function() {
|
|
111
|
+
expect(subject.wishForMoreWishes).to.equal(subject.preload);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('load as "rub"', function() {
|
|
115
|
+
expect(subject.rub).to.equal(subject.load);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('load as "wish"', function() {
|
|
119
|
+
expect(subject.wish).to.equal(subject.load);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('clean as "polish"', function() {
|
|
123
|
+
expect(subject.polish).to.equal(subject.clean);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
describe('integration', function() {
|
|
128
|
+
beforeEach(function() {
|
|
129
|
+
subject.initialize();
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
afterEach(function() {
|
|
133
|
+
delete subject.genie;
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('can load the foo template and clean up', function() {
|
|
137
|
+
expect(testFixtureContainer()).to.equal(null);
|
|
138
|
+
subject.load('orders/foo');
|
|
139
|
+
expect(testFixtureContainer().innerHTML).to.equal('foo\n');
|
|
140
|
+
subject.clean();
|
|
141
|
+
expect(testFixtureContainer()).to.equal(null);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('can preload the templates and clean up', function() {
|
|
145
|
+
subject.preload();
|
|
146
|
+
expect(testFixtureContainer()).to.equal(null);
|
|
147
|
+
subject.load('orders/foo');
|
|
148
|
+
expect(testFixtureContainer().innerHTML).to.equal('foo\n');
|
|
149
|
+
subject.clean();
|
|
150
|
+
expect(testFixtureContainer()).to.equal(null);
|
|
151
|
+
subject.load('orders/bar');
|
|
152
|
+
expect(testFixtureContainer().innerHTML).to.equal('bar\n');
|
|
153
|
+
subject.clean();
|
|
154
|
+
expect(testFixtureContainer()).to.equal(null);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('can specify the id used for the fixture container', function() {
|
|
158
|
+
var newId = subject.id = 'the-eye';
|
|
159
|
+
subject.load('orders/foo');
|
|
160
|
+
expect(testFixtureContainer()).to.equal(null);
|
|
161
|
+
expect(document.getElementById(newId)).to.exist;
|
|
162
|
+
expect(document.getElementById(newId).innerHTML).to.equal('foo\n');
|
|
163
|
+
subject.clean();
|
|
164
|
+
expect(document.getElementById(newId)).to.not.exist;
|
|
165
|
+
delete subject.id;
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('throws an error when it cannot find the template', function() {
|
|
169
|
+
expect(function() {
|
|
170
|
+
subject.load('not/gonna/happen');
|
|
171
|
+
}).to.throw(/'not\/gonna\/happen' is not a registered fixture$/);
|
|
172
|
+
|
|
173
|
+
expect(testFixtureContainer()).to.equal(null);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('throws an error when it cannot find the preloaded template', function() {
|
|
177
|
+
subject.preload();
|
|
178
|
+
expect(function() {
|
|
179
|
+
subject.load('still/not/gonna/happen');
|
|
180
|
+
}).to.throw();
|
|
181
|
+
|
|
182
|
+
expect(testFixtureContainer()).to.equal(null);
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
});
|