magic_lamp 1.5.2 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -14
- data/app/assets/javascripts/magic_lamp/all_fixtures.js.erb +12 -0
- data/app/assets/javascripts/magic_lamp/genie.js +1 -1
- data/app/assets/javascripts/magic_lamp/magic_lamp.js +3 -1
- data/lib/magic_lamp.rb +3 -3
- data/lib/magic_lamp/version.rb +1 -1
- data/lib/tasks/fixture_names.rb +12 -0
- data/lib/tasks/lint.rb +88 -0
- data/spec/controllers/magic_lamp/lint_controller_spec.rb +1 -1
- data/spec/javascripts/genie_spec.js +2 -2
- data/spec/lib/all_fixtures_spec.rb +32 -0
- data/spec/spec_helper.rb +0 -1
- data/spec/tasks/fixture_names_task_spec.rb +1 -1
- data/spec/tasks/lint_task_spec.rb +9 -9
- metadata +7 -4
- data/lib/tasks/fixture_names_task.rb +0 -10
- data/lib/tasks/lint_task.rb +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8bca611448f6cd6086f0a9a17393ffce473d65d
|
4
|
+
data.tar.gz: adfc6d57c0e0a61d4a02c1c36ec8b137c1ca3ed9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8eeab2759a000a30e47eabd000e5c49fcf46c20de833026c9aa464c3647f1d95f85a138450010fab737387f01aab5fa82ee290d942b68747467aaba54cdcd768
|
7
|
+
data.tar.gz: 83aab308b53d110243d0c8132fdb96aa4a83c47e9d6bcd36e6a5dd4c231cfe790af3f483834bb29ed4da0540022d849d8f491925385ef4bee2b75bfeae8eb3cd
|
data/README.md
CHANGED
@@ -6,8 +6,6 @@ Magic Lamp helps you get your Rails templates into your JavaScript tests. This m
|
|
6
6
|
if you change your templates _and_ you don't have to create so many fixtures. Plus, it lets you test your views in JavaScript.
|
7
7
|
All you have to do is set up your data just like you would in a controller.
|
8
8
|
|
9
|
-
It's not required that you use [Teaspoon](https://github.com/modeset/teaspoon) as your JavaScript test runner, but you should.
|
10
|
-
|
11
9
|
Table of Contents
|
12
10
|
-----------------
|
13
11
|
1. [Installation](#installation)
|
@@ -31,12 +29,7 @@ And then execute:
|
|
31
29
|
|
32
30
|
$ bundle install
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
$ gem install magic_lamp
|
37
|
-
|
38
|
-
Then paste `mount MagicLamp::Genie, at: "/magic_lamp" if defined?(MagicLamp)` into your `config/routes.rb`
|
39
|
-
like so:
|
32
|
+
Then paste `mount MagicLamp::Genie, at: "/magic_lamp" if defined?(MagicLamp)` into your `config/routes.rb` like so:
|
40
33
|
```ruby
|
41
34
|
Rails.application.routes.draw do
|
42
35
|
# ...
|
@@ -50,24 +43,29 @@ Then drop this:
|
|
50
43
|
```js
|
51
44
|
//= require magic_lamp
|
52
45
|
```
|
53
|
-
at the top of your `spec_helper.js` (assuming you're using
|
46
|
+
at the top of your `spec_helper.js` (assuming you're using JavaScript spec runner for Rails that allows the use of Sprockets directives).
|
54
47
|
|
55
|
-
|
48
|
+
If your JavaScript doesn't support XHR requests, you can drop this in instead:
|
56
49
|
|
57
|
-
|
50
|
+
```js
|
51
|
+
//= require magic_lamp
|
52
|
+
//= require magic_lamp/all_fixtures
|
53
|
+
```
|
58
54
|
|
59
|
-
|
55
|
+
`//= require magic_lamp/all_fixtures` will load all of your fixtures without making any XHR requests.
|
56
|
+
|
57
|
+
Now you've got the basic setup.
|
60
58
|
|
61
59
|
### Debugging
|
62
60
|
Visit `/magic_lamp/lint` in your browser to lint your fixtures. You can also run `rake magic_lamp:lint` (or `rake mll` for short) to lint your fixtures from the command line.
|
63
61
|
|
64
62
|
### Loading Helpers
|
65
63
|
|
66
|
-
Simply `
|
64
|
+
Simply `load` your helpers in the `magic_lamp_config.rb` file like so:
|
67
65
|
|
68
66
|
```ruby
|
69
67
|
# in magic_lamp_config.rb
|
70
|
-
Dir[Rails.root.join("spec", "support", "magic_lamp_helpers/**/*.rb")].each { |f|
|
68
|
+
Dir[Rails.root.join("spec", "support", "magic_lamp_helpers/**/*.rb")].each { |f| load f }
|
71
69
|
```
|
72
70
|
|
73
71
|
### With Database Cleaner
|
@@ -399,6 +397,7 @@ It requires a block to which it yields the configuration object. Here you can se
|
|
399
397
|
Example:
|
400
398
|
|
401
399
|
```ruby
|
400
|
+
# spec/support/magic_lamp/helpers/auth_stub.rb
|
402
401
|
module AuthStub
|
403
402
|
def current_user
|
404
403
|
@current_user ||= User.create!(
|
@@ -408,8 +407,11 @@ module AuthStub
|
|
408
407
|
end
|
409
408
|
end
|
410
409
|
|
410
|
+
# spec/magic_lamp_config.rb (can be anywhere in /spec)
|
411
411
|
MagicLamp.configure do |config|
|
412
412
|
|
413
|
+
Dir[Rails.root.join("spec", "support", "magic_lamp_helpers/**/*.rb")].each { |f| load f }
|
414
|
+
|
413
415
|
# if you want to require the name parameter for the `fixture` method
|
414
416
|
config.infer_names = false
|
415
417
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<% all_fixtures = MagicLamp.generate_all_fixtures.to_json rescue nil %>
|
2
|
+
|
3
|
+
<% if all_fixtures %>
|
4
|
+
|
5
|
+
MagicLamp.genie.cacheOnly = true;
|
6
|
+
MagicLamp.genie.cache = <%= MagicLamp.generate_all_fixtures.to_json %>;
|
7
|
+
|
8
|
+
<% else %>
|
9
|
+
|
10
|
+
throw new Error(MagicLamp.genericError);
|
11
|
+
|
12
|
+
<% end %>
|
@@ -85,7 +85,7 @@
|
|
85
85
|
if (this.xhrStatus(xhr) === 400) {
|
86
86
|
this.handleError(xhr.responseText);
|
87
87
|
} else if (this.xhrStatus(xhr) > 400) {
|
88
|
-
this.handleError(
|
88
|
+
this.handleError(MagicLamp.genericError);
|
89
89
|
}
|
90
90
|
return xhr;
|
91
91
|
},
|
@@ -17,7 +17,9 @@
|
|
17
17
|
|
18
18
|
preload: function() {
|
19
19
|
this.genie.preload.apply(this.genie, arguments);
|
20
|
-
}
|
20
|
+
},
|
21
|
+
|
22
|
+
genericError: 'Something went wrong, please check the server log, run `rake magic_lamp:lint`, or visit `/magic_lamp/lint` for more information'
|
21
23
|
};
|
22
24
|
|
23
25
|
MagicLamp.clean = function() {
|
data/lib/magic_lamp.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require "
|
1
|
+
require "method_source"
|
2
2
|
|
3
3
|
require "magic_lamp/engine"
|
4
4
|
require "magic_lamp/constants"
|
@@ -9,8 +9,8 @@ require "magic_lamp/defaults_manager"
|
|
9
9
|
require "magic_lamp/fixture_creator"
|
10
10
|
require "magic_lamp/render_catcher"
|
11
11
|
|
12
|
-
require "tasks/
|
13
|
-
require "tasks/
|
12
|
+
require "tasks/lint"
|
13
|
+
require "tasks/fixture_names"
|
14
14
|
|
15
15
|
module MagicLamp
|
16
16
|
class << self
|
data/lib/magic_lamp/version.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
MagicLamp::Genie.rake_tasks do
|
2
|
+
namespace :magic_lamp do
|
3
|
+
desc "Displays all Magic Lamp fixture names"
|
4
|
+
task fixture_names: :environment do
|
5
|
+
MagicLamp.load_lamp_files
|
6
|
+
puts MagicLamp.registered_fixtures.keys.sort
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Displays all Magic Lamp fixture names (alias for `magic_lamp:fixture_names`)"
|
11
|
+
task mlfn: "magic_lamp:fixture_names"
|
12
|
+
end
|
data/lib/tasks/lint.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
MagicLamp::Genie.rake_tasks do
|
2
|
+
namespace :magic_lamp do
|
3
|
+
desc "Generates all Magic Lamp fixtures and displays errors for debugging"
|
4
|
+
task lint: ["magic_lamp:lint:config", "magic_lamp:lint:files", "magic_lamp:lint:fixtures"]
|
5
|
+
|
6
|
+
namespace :lint do
|
7
|
+
desc "Lints your Magic Lamp configuration and reports any errors"
|
8
|
+
task config: :environment do
|
9
|
+
puts "Linting Magic Lamp configuration..."
|
10
|
+
errors = MagicLamp.lint_config
|
11
|
+
if errors.present?
|
12
|
+
if errors[:config_file_load].present?
|
13
|
+
puts "Loading configuration failed with:"
|
14
|
+
puts "\n#{errors[:config_file_load]}"
|
15
|
+
end
|
16
|
+
|
17
|
+
[:before_each, :after_each].each do |callback|
|
18
|
+
if errors[callback].present?
|
19
|
+
puts "Executing #{callback} failed with:"
|
20
|
+
puts "\n#{errors[callback]}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
abort
|
24
|
+
else
|
25
|
+
puts "Configuration looks good!"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Lints your Magic Lamp lamp files and reports any errors"
|
30
|
+
task files: :environment do
|
31
|
+
puts "Linting lamp files..."
|
32
|
+
errors = MagicLamp.lint_fixtures[:files]
|
33
|
+
|
34
|
+
if errors.present?
|
35
|
+
puts "The following files are broken:"
|
36
|
+
puts ""
|
37
|
+
|
38
|
+
errors.each do |path, error|
|
39
|
+
puts "File: #{path}"
|
40
|
+
puts "Error: #{error}"
|
41
|
+
puts ""
|
42
|
+
end
|
43
|
+
abort
|
44
|
+
else
|
45
|
+
puts "Lamp files look good!"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "Lints your Magic Lamp fixtures and reports any errors"
|
50
|
+
task fixtures: :environment do
|
51
|
+
puts "Linting Magic Lamp fixtures..."
|
52
|
+
errors = MagicLamp.lint_fixtures[:fixtures]
|
53
|
+
|
54
|
+
if errors.present?
|
55
|
+
puts "The following fixtures are broken:"
|
56
|
+
puts ""
|
57
|
+
|
58
|
+
errors.each do |name, fixture_info|
|
59
|
+
puts "Name: \"#{name}\""
|
60
|
+
render_block = fixture_info[:render_block]
|
61
|
+
puts "File: #{render_block.source_location.join(':')}"
|
62
|
+
puts "Controller: #{fixture_info[:controller]}"
|
63
|
+
|
64
|
+
if fixture_info[:extend].present?
|
65
|
+
extensions = fixture_info[:extend].join(", ")
|
66
|
+
else
|
67
|
+
extensions = "None"
|
68
|
+
end
|
69
|
+
|
70
|
+
puts "Extensions: #{extensions}"
|
71
|
+
puts ""
|
72
|
+
puts "Source code:"
|
73
|
+
puts render_block.source
|
74
|
+
puts ""
|
75
|
+
puts "Error: #{fixture_info[:error]}"
|
76
|
+
puts ""
|
77
|
+
end
|
78
|
+
abort
|
79
|
+
else
|
80
|
+
puts "Fixtures look good!"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
desc "Generates all Magic Lamp fixtures and displays errors for debugging (alias for `magic_lamp:lint`)"
|
87
|
+
task mll: "magic_lamp:lint"
|
88
|
+
end
|
@@ -308,7 +308,7 @@ describe('Genie', function() {
|
|
308
308
|
stub(subject, 'xhrStatus', 500);
|
309
309
|
var path = '/magic_lamp/foo/bar';
|
310
310
|
subject.xhrRequest(path);
|
311
|
-
expect(subject.handleError).to.have.been.calledWith(
|
311
|
+
expect(subject.handleError).to.have.been.calledWith(MagicLamp.genericError);
|
312
312
|
});
|
313
313
|
|
314
314
|
it('calls handleError with the default error message if the status was 404', function() {
|
@@ -316,7 +316,7 @@ describe('Genie', function() {
|
|
316
316
|
stub(subject, 'xhrStatus', 404);
|
317
317
|
var path = '/magic_lamp/foo/bar';
|
318
318
|
subject.xhrRequest(path);
|
319
|
-
expect(subject.handleError).to.have.been.calledWith(
|
319
|
+
expect(subject.handleError).to.have.been.calledWith(MagicLamp.genericError);
|
320
320
|
});
|
321
321
|
});
|
322
322
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "rails_helper"
|
2
|
+
|
3
|
+
describe "All fixtures js erb" do
|
4
|
+
subject do
|
5
|
+
sprockets_env = Sprockets::Environment.new
|
6
|
+
sprockets_env.append_path("app/assets/javascripts/")
|
7
|
+
sprockets_env["magic_lamp/all_fixtures.js"].to_s
|
8
|
+
end
|
9
|
+
|
10
|
+
it "sets cache only to true" do
|
11
|
+
expect(subject).to match(/MagicLamp.genie.cacheOnly = true/)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "provides all of the fixtures as json in the cache" do
|
15
|
+
excaped_json = Regexp.escape(MagicLamp.generate_all_fixtures.to_json)
|
16
|
+
expect(subject).to match(/MagicLamp.genie.cache = #{excaped_json}/)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "does not throw an error" do
|
20
|
+
expect(subject).to_not match(/throw new Error\(MagicLamp.genericError\)/)
|
21
|
+
end
|
22
|
+
|
23
|
+
context "errors" do
|
24
|
+
before do
|
25
|
+
allow(MagicLamp).to receive(:generate_all_fixtures).and_raise("Some error")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "throws an error" do
|
29
|
+
expect(subject).to match(/throw new Error\(MagicLamp.genericError\)/)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,7 +4,7 @@ describe "magic_lamp:fixture_names" do
|
|
4
4
|
it { is_expected.to depend_on(:environment) }
|
5
5
|
|
6
6
|
it "outputs a sorted list of all the fixture names" do
|
7
|
-
expect(
|
7
|
+
expect(MagicLamp::Genie.instance).to receive(:puts) do |output|
|
8
8
|
fixture_names = MagicLamp.registered_fixtures.keys.sort
|
9
9
|
expect(output).to_not be_empty
|
10
10
|
expect(output).to eq(fixture_names)
|
@@ -34,7 +34,7 @@ describe "magic_lamp:lint:config" do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it "does not abort" do
|
37
|
-
expect(
|
37
|
+
expect(MagicLamp::Genie.instance).to_not receive(:abort)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -42,7 +42,7 @@ describe "magic_lamp:lint:config" do
|
|
42
42
|
let!(:error_proc) { proc { raise "Nope" } }
|
43
43
|
|
44
44
|
before do
|
45
|
-
allow(
|
45
|
+
allow(MagicLamp::Genie.instance).to receive(:abort)
|
46
46
|
end
|
47
47
|
|
48
48
|
it "tells us if the file could be loaded" do
|
@@ -70,7 +70,7 @@ describe "magic_lamp:lint:config" do
|
|
70
70
|
allow(MagicLamp).to receive(:load_config) do
|
71
71
|
load Rails.root.join("error_specs", "config_file_load_error.rb")
|
72
72
|
end
|
73
|
-
expect(
|
73
|
+
expect(MagicLamp::Genie.instance).to receive(:abort)
|
74
74
|
capture_stdout { subject.execute }
|
75
75
|
end
|
76
76
|
end
|
@@ -81,7 +81,7 @@ describe "magic_lamp:lint:files" do
|
|
81
81
|
let(:output) { capture_stdout { subject.execute } }
|
82
82
|
|
83
83
|
before do
|
84
|
-
allow(
|
84
|
+
allow(MagicLamp::Genie.instance).to receive(:abort).and_return(:abort)
|
85
85
|
end
|
86
86
|
|
87
87
|
it { is_expected.to depend_on(:environment) }
|
@@ -93,7 +93,7 @@ describe "magic_lamp:lint:files" do
|
|
93
93
|
end
|
94
94
|
|
95
95
|
it "does not abort" do
|
96
|
-
expect(
|
96
|
+
expect(MagicLamp::Genie.instance).to_not receive(:abort)
|
97
97
|
capture_stdout { subject.execute }
|
98
98
|
end
|
99
99
|
end
|
@@ -120,7 +120,7 @@ describe "magic_lamp:lint:files" do
|
|
120
120
|
|
121
121
|
it "aborts the task" do
|
122
122
|
allow(MagicLamp).to receive(:lamp_files).and_return(lamp_file_paths)
|
123
|
-
expect(
|
123
|
+
expect(MagicLamp::Genie.instance).to receive(:abort)
|
124
124
|
capture_stdout { subject.execute }
|
125
125
|
end
|
126
126
|
end
|
@@ -139,14 +139,14 @@ describe "magic_lamp:lint:fixtures" do
|
|
139
139
|
end
|
140
140
|
|
141
141
|
it "does not abort" do
|
142
|
-
expect(
|
142
|
+
expect(MagicLamp::Genie.instance).to_not receive(:abort)
|
143
143
|
capture_stdout { subject.execute }
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
147
|
context "errors" do
|
148
148
|
before do
|
149
|
-
allow(
|
149
|
+
allow(MagicLamp::Genie.instance).to receive(:abort).and_return(:abort)
|
150
150
|
allow(MagicLamp).to receive(:lamp_files).and_return([Rails.root.join("error_specs", "broken_fixtures.rb").to_s])
|
151
151
|
end
|
152
152
|
|
@@ -181,7 +181,7 @@ describe "magic_lamp:lint:fixtures" do
|
|
181
181
|
end
|
182
182
|
|
183
183
|
it "aborts the task" do
|
184
|
-
expect(
|
184
|
+
expect(MagicLamp::Genie.instance).to receive(:abort)
|
185
185
|
capture_stdout { subject.execute }
|
186
186
|
end
|
187
187
|
end
|
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.
|
4
|
+
version: 1.6.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: 2015-
|
11
|
+
date: 2015-04-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -245,6 +245,7 @@ files:
|
|
245
245
|
- LICENSE
|
246
246
|
- README.md
|
247
247
|
- app/assets/javascripts/magic_lamp.js
|
248
|
+
- app/assets/javascripts/magic_lamp/all_fixtures.js.erb
|
248
249
|
- app/assets/javascripts/magic_lamp/application.js
|
249
250
|
- app/assets/javascripts/magic_lamp/boot.js
|
250
251
|
- app/assets/javascripts/magic_lamp/genie.js
|
@@ -270,8 +271,8 @@ files:
|
|
270
271
|
- lib/magic_lamp/fixture_creator.rb
|
271
272
|
- lib/magic_lamp/render_catcher.rb
|
272
273
|
- lib/magic_lamp/version.rb
|
273
|
-
- lib/tasks/
|
274
|
-
- lib/tasks/
|
274
|
+
- lib/tasks/fixture_names.rb
|
275
|
+
- lib/tasks/lint.rb
|
275
276
|
- spec/controllers/magic_lamp/fixtures_controller_spec.rb
|
276
277
|
- spec/controllers/magic_lamp/lint_controller_spec.rb
|
277
278
|
- spec/dummy/README.rdoc
|
@@ -337,6 +338,7 @@ files:
|
|
337
338
|
- spec/javascripts/support/chai-fuzzy.js
|
338
339
|
- spec/javascripts/support/sinon-chai.js
|
339
340
|
- spec/javascripts/support/underscore-1.6.js
|
341
|
+
- spec/lib/all_fixtures_spec.rb
|
340
342
|
- spec/lib/configuration_spec.rb
|
341
343
|
- spec/lib/defaults_manager_spec.rb
|
342
344
|
- spec/lib/fixture_creator_spec.rb
|
@@ -438,6 +440,7 @@ test_files:
|
|
438
440
|
- spec/javascripts/support/chai-fuzzy.js
|
439
441
|
- spec/javascripts/support/sinon-chai.js
|
440
442
|
- spec/javascripts/support/underscore-1.6.js
|
443
|
+
- spec/lib/all_fixtures_spec.rb
|
441
444
|
- spec/lib/configuration_spec.rb
|
442
445
|
- spec/lib/defaults_manager_spec.rb
|
443
446
|
- spec/lib/fixture_creator_spec.rb
|
@@ -1,10 +0,0 @@
|
|
1
|
-
namespace :magic_lamp do
|
2
|
-
desc "Displays all Magic Lamp fixture names"
|
3
|
-
task fixture_names: :environment do
|
4
|
-
MagicLamp.load_lamp_files
|
5
|
-
puts MagicLamp.registered_fixtures.keys.sort
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
desc "Displays all Magic Lamp fixture names (alias for `magic_lamp:fixture_names`)"
|
10
|
-
task mlfn: "magic_lamp:fixture_names"
|
data/lib/tasks/lint_task.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
require "method_source"
|
2
|
-
|
3
|
-
namespace :magic_lamp do
|
4
|
-
desc "Generates all Magic Lamp fixtures and displays errors for debugging"
|
5
|
-
task lint: ["magic_lamp:lint:config", "magic_lamp:lint:files", "magic_lamp:lint:fixtures"]
|
6
|
-
|
7
|
-
namespace :lint do
|
8
|
-
desc "Lints your Magic Lamp configuration and reports any errors"
|
9
|
-
task config: :environment do
|
10
|
-
puts "Linting Magic Lamp configuration..."
|
11
|
-
errors = MagicLamp.lint_config
|
12
|
-
if errors.present?
|
13
|
-
if errors[:config_file_load].present?
|
14
|
-
puts "Loading configuration failed with:"
|
15
|
-
puts "\n#{errors[:config_file_load]}"
|
16
|
-
end
|
17
|
-
|
18
|
-
[:before_each, :after_each].each do |callback|
|
19
|
-
if errors[callback].present?
|
20
|
-
puts "Executing #{callback} failed with:"
|
21
|
-
puts "\n#{errors[callback]}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
abort
|
25
|
-
else
|
26
|
-
puts "Configuration looks good!"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
desc "Lints your Magic Lamp lamp files and reports any errors"
|
31
|
-
task files: :environment do
|
32
|
-
puts "Linting lamp files..."
|
33
|
-
errors = MagicLamp.lint_fixtures[:files]
|
34
|
-
|
35
|
-
if errors.present?
|
36
|
-
puts "The following files are broken:"
|
37
|
-
puts ""
|
38
|
-
|
39
|
-
errors.each do |path, error|
|
40
|
-
puts "File: #{path}"
|
41
|
-
puts "Error: #{error}"
|
42
|
-
puts ""
|
43
|
-
end
|
44
|
-
abort
|
45
|
-
else
|
46
|
-
puts "Lamp files look good!"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
desc "Lints your Magic Lamp fixtures and reports any errors"
|
51
|
-
task fixtures: :environment do
|
52
|
-
puts "Linting Magic Lamp fixtures..."
|
53
|
-
errors = MagicLamp.lint_fixtures[:fixtures]
|
54
|
-
|
55
|
-
if errors.present?
|
56
|
-
puts "The following fixtures are broken:"
|
57
|
-
puts ""
|
58
|
-
|
59
|
-
errors.each do |name, fixture_info|
|
60
|
-
puts "Name: \"#{name}\""
|
61
|
-
render_block = fixture_info[:render_block]
|
62
|
-
puts "File: #{render_block.source_location.join(':')}"
|
63
|
-
puts "Controller: #{fixture_info[:controller]}"
|
64
|
-
|
65
|
-
if fixture_info[:extend].present?
|
66
|
-
extensions = fixture_info[:extend].join(", ")
|
67
|
-
else
|
68
|
-
extensions = "None"
|
69
|
-
end
|
70
|
-
|
71
|
-
puts "Extensions: #{extensions}"
|
72
|
-
puts ""
|
73
|
-
puts "Source code:"
|
74
|
-
puts render_block.source
|
75
|
-
puts ""
|
76
|
-
puts "Error: #{fixture_info[:error]}"
|
77
|
-
puts ""
|
78
|
-
end
|
79
|
-
abort
|
80
|
-
else
|
81
|
-
puts "Fixtures look good!"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
desc "Generates all Magic Lamp fixtures and displays errors for debugging (alias for `magic_lamp:lint`)"
|
88
|
-
task mll: "magic_lamp:lint"
|