magic_lamp 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +43 -5
  3. data/VERSION +1 -1
  4. data/app/assets/javascripts/magic_lamp/genie.js +24 -8
  5. data/spec/dummy/log/development.log +14358 -0
  6. data/spec/dummy/log/test.log +7745 -0
  7. data/spec/dummy/tmp/cache/assets/development/sprockets/09bc89d8ac4ccacfcf2f4db466e7735f +0 -0
  8. data/spec/dummy/tmp/cache/assets/development/sprockets/18650d8ff9b0a83b32e55b58917ec791 +0 -0
  9. data/spec/dummy/tmp/cache/assets/development/sprockets/2ccef21649a61deac2c84f622753b77b +0 -0
  10. data/spec/dummy/tmp/cache/assets/development/sprockets/5bbf09297502a156801e9c65f4bd3db7 +0 -0
  11. data/spec/dummy/tmp/cache/assets/development/sprockets/759e97d6d411bc4cef7055a778e1bef3 +0 -0
  12. data/spec/dummy/tmp/cache/assets/development/sprockets/88fe64427f1fff8e41ca8ad0170da88a +0 -0
  13. data/spec/dummy/tmp/cache/assets/development/sprockets/8ed4b4f20fb65446181984e6df7d7c9b +0 -0
  14. data/spec/dummy/tmp/cache/assets/development/sprockets/96210dc070e479fcee862294afe5efc1 +0 -0
  15. data/spec/dummy/tmp/cache/assets/development/sprockets/972b6b0bb1fc0b1123077b4b2f4394bd +0 -0
  16. data/spec/dummy/tmp/cache/assets/development/sprockets/bfa154e8a12acdbc85028ad8130d9043 +0 -0
  17. data/spec/dummy/tmp/cache/assets/development/sprockets/cf573b52d944e8aea7f1dc03f9be9b2c +0 -0
  18. data/spec/dummy/tmp/cache/assets/development/sprockets/d98de652252dc6ae11b5b6db5588705b +0 -0
  19. data/spec/dummy/tmp/cache/assets/development/sprockets/f0aa53eb377a5d7cc83657ef33b02d25 +0 -0
  20. data/spec/dummy/tmp/cache/assets/development/sprockets/f5d1b7d2ec1c89dc32cc982b43502dc8 +0 -0
  21. data/spec/dummy/tmp/cache/assets/development/sprockets/f6256b2e4e609981d9eb420aae5bef46 +0 -0
  22. data/spec/javascripts/genie_spec.js +45 -17
  23. data/spec/javascripts/magic_lamp_spec.js +5 -0
  24. metadata +2 -2
@@ -50,8 +50,10 @@ describe('Genie', function() {
50
50
 
51
51
  describe('#load', function() {
52
52
  var path;
53
+ var fixtureContent;
53
54
  beforeEach(function() {
54
55
  path = 'orders/foo';
56
+ fixtureContent = 'foo\n';
55
57
  });
56
58
 
57
59
  afterEach(function() {
@@ -59,41 +61,63 @@ describe('Genie', function() {
59
61
  });
60
62
 
61
63
  it('does not double append fixture containers', function() {
62
- subject.cache[path] = 'some template';
64
+ subject.cache[path] = fixtureContent;
63
65
  subject.cacheOnly = true;
64
66
  _(2).times(function() { subject.load(path); });
65
67
  expect(document.getElementsByClassName('magic-lamp').length).to.equal(1);
66
68
  });
67
69
 
70
+ it('appends the fixture container with the fixture to the dom', function() {
71
+ spyOn(subject, 'retrieveFixture');
72
+ expect(testFixtureContainer()).to.be.undefined;
73
+ subject.load(path);
74
+ expect(subject.retrieveFixture).to.have.been.calledWith(path);
75
+ expect(testFixtureContainer().innerHTML).to.equal(fixtureContent);
76
+ });
77
+
78
+ describe('multiple fixtures requested', function() {
79
+ it('appends the fixture container with all of the fixtures to the dom', function() {
80
+ expect(testFixtureContainer()).to.be.undefined;
81
+ subject.load(path, path, path, path);
82
+ var largeFixtureContent = fixtureContent + fixtureContent + fixtureContent + fixtureContent;
83
+ expect(testFixtureContainer().innerHTML).to.equal(largeFixtureContent);
84
+ });
85
+ });
86
+ });
87
+
88
+ describe('#retrieveFixture', function() {
89
+ var path;
90
+ var fixtureContent;
91
+ beforeEach(function() {
92
+ path = 'orders/foo';
93
+ fixtureContent = 'foo\n';
94
+ });
95
+
68
96
  describe('cacheOnly false', function() {
69
97
  it('requests the fixture and adds it to the cache', function() {
70
98
  spyOn(subject, 'xhrRequest');
71
- subject.load(path);
99
+ subject.retrieveFixture(path);
72
100
  expect(subject.xhrRequest).to.have.been.calledOnce;
73
- expect(subject.cache[path]).to.equal('foo\n');
101
+ expect(subject.cache[path]).to.equal(fixtureContent);
74
102
  });
75
103
 
76
- it('appends the fixture container with the fixture to the dom', function() {
77
- expect(testFixtureContainer()).to.be.undefined;
78
- subject.load(path);
79
- expect(testFixtureContainer().innerHTML).to.equal('foo\n');
104
+ it('returns the fixture', function() {
105
+ expect(subject.retrieveFixture(path)).to.equal(fixtureContent);
80
106
  });
81
107
 
82
108
  describe('cached', function() {
83
109
  beforeEach(function() {
84
- subject.cache[path] = 'howdy';
110
+ fixtureContent = subject.cache[path] = 'howdy';
85
111
  });
86
112
 
87
113
  it('does not make a request', function() {
88
114
  spyOn(subject, 'xhrRequest');
89
- subject.load(path);
115
+ subject.retrieveFixture(path);
90
116
  expect(subject.xhrRequest).to.not.have.been.calledOnce;
91
117
  });
92
118
 
93
- it('appends the fixture container to the dom with the cached fixture', function() {
94
- expect(testFixtureContainer()).to.be.undefined;
95
- subject.load(path);
96
- expect(testFixtureContainer().innerHTML).to.equal('howdy');
119
+ it('returns the fixture', function() {
120
+ expect(subject.retrieveFixture(path)).to.equal(fixtureContent);
97
121
  });
98
122
  });
99
123
  });
@@ -105,14 +129,19 @@ describe('Genie', function() {
105
129
 
106
130
  it('does not make a request', function() {
107
131
  spyOn(subject, 'xhrRequest');
108
- subject.cache[path] = 'howdy';
109
- subject.load(path);
132
+ subject.cache[path] = fixtureContent;
133
+ subject.retrieveFixture(path);
110
134
  expect(subject.xhrRequest).to.not.have.been.calledOnce;
111
135
  });
112
136
 
137
+ it('returns the fixture', function() {
138
+ subject.cache[path] = fixtureContent;
139
+ expect(subject.retrieveFixture(path)).to.equal(fixtureContent);
140
+ });
141
+
113
142
  it('throws an error if the fixture is not in the cache', function() {
114
143
  expect(function() {
115
- subject.load(path);
144
+ subject.retrieveFixture(path);
116
145
  }).to.throw(/The fixture "orders\/foo" was not preloaded. Is the fixture registered\? Call `MagicLamp.fixtureNames\(\)` to see what is registered./);
117
146
  });
118
147
  });
@@ -231,7 +260,6 @@ describe('Genie', function() {
231
260
  expect(subject.fixtureContainer).to.be.undefined;
232
261
  });
233
262
  });
234
-
235
263
  });
236
264
 
237
265
  describe('#handleError', function() {
@@ -227,5 +227,10 @@ describe('MagicLamp', function() {
227
227
  subject.load('arbitrary/orders/admin_extending');
228
228
  expect(testFixtureContainer().innerHTML).to.equal('Stevenson\nPaulson\n');
229
229
  });
230
+
231
+ it('can load multiple fixtures', function() {
232
+ subject.load('arbitrary/orders/admin_extending', 'orders/foo');
233
+ expect(testFixtureContainer().innerHTML).to.equal('Stevenson\nPaulson\nfoo\n');
234
+ });
230
235
  });
231
236
  });
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magic_lamp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Crismali
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-19 00:00:00.000000000 Z
11
+ date: 2014-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails