jsus 0.2.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -0
- data/CHANGELOG +4 -1
- data/Gemfile +4 -1
- data/VERSION +1 -1
- data/bin/jsus +30 -9
- data/features/command-line/compression.feature +24 -0
- data/features/command-line/mooforge_compatibility_layer.feature +75 -0
- data/features/data/Compression/Source/Library/Color.js +17 -0
- data/features/data/Compression/Source/Widget/Input/Input.Color.js +21 -0
- data/features/data/Compression/package.yml +9 -0
- data/features/data/MooforgePlugin/Core/Source/Core.js +16 -0
- data/features/data/MooforgePlugin/Core/package.yml +8 -0
- data/features/data/MooforgePlugin/Plugin/Source/plugin-support.js +20 -0
- data/features/data/MooforgePlugin/Plugin/Source/plugin.js +21 -0
- data/features/data/MooforgePlugin/Plugin/package.yml +9 -0
- data/features/data/compression.min.js +1 -0
- data/jsus.gemspec +45 -22
- data/lib/jsus/middleware.rb +178 -0
- data/lib/jsus/package.rb +10 -10
- data/lib/jsus/source_file.rb +58 -30
- data/lib/jsus/tag.rb +18 -10
- data/lib/jsus/util/file_cache.rb +57 -0
- data/lib/jsus/util/inflection.rb +39 -0
- data/lib/jsus/util.rb +2 -0
- data/lib/jsus.rb +2 -0
- data/spec/data/ComplexDependencies/Mootools/Source/Core.js +16 -0
- data/spec/data/ComplexDependencies/Mootools/package.yml +8 -0
- data/spec/data/ComplexDependencies/Output/package.js +70 -0
- data/spec/data/ComplexDependencies/Output/scripts.json +14 -0
- data/spec/data/ComplexDependencies/Output/tree.json +33 -0
- data/spec/data/ComplexDependencies/Source/Library/Color.js +19 -0
- data/spec/data/ComplexDependencies/Source/Widget/Input/Input.Color.js +20 -0
- data/spec/data/ComplexDependencies/Source/Widget/Input.js +16 -0
- data/spec/data/ComplexDependencies/package.yml +10 -0
- data/spec/data/mooforge_quirky_source.js +20 -0
- data/spec/data/unicode_source.js +23 -0
- data/spec/data/unicode_source_with_bom.js +23 -0
- data/spec/jsus/middleware_spec.rb +216 -0
- data/spec/jsus/package_spec.rb +12 -6
- data/spec/jsus/source_file_spec.rb +42 -14
- data/spec/jsus/tag_spec.rb +8 -2
- data/spec/jsus/util/file_cache_spec.rb +67 -0
- data/spec/jsus/util/inflection_spec.rb +42 -0
- metadata +124 -62
- data/Gemfile.lock +0 -79
@@ -0,0 +1,70 @@
|
|
1
|
+
/*
|
2
|
+
---
|
3
|
+
|
4
|
+
script: Input.js
|
5
|
+
|
6
|
+
description: Generic Input
|
7
|
+
|
8
|
+
license: MIT-style license
|
9
|
+
|
10
|
+
authors:
|
11
|
+
- Yaroslaff Fedin
|
12
|
+
|
13
|
+
provides: [Input]
|
14
|
+
|
15
|
+
...
|
16
|
+
*/
|
17
|
+
/*
|
18
|
+
---
|
19
|
+
|
20
|
+
script: Core.js
|
21
|
+
|
22
|
+
description: Mootools fake core
|
23
|
+
|
24
|
+
license: MIT-style license
|
25
|
+
|
26
|
+
authors:
|
27
|
+
- Valerio Proietti
|
28
|
+
|
29
|
+
provides: [Core]
|
30
|
+
|
31
|
+
...
|
32
|
+
*/
|
33
|
+
/*
|
34
|
+
---
|
35
|
+
|
36
|
+
script: Color.js
|
37
|
+
|
38
|
+
description: A library to work with colors
|
39
|
+
|
40
|
+
license: MIT-style license
|
41
|
+
|
42
|
+
authors:
|
43
|
+
- Valerio Proietti
|
44
|
+
|
45
|
+
requires:
|
46
|
+
- Mootools/Core
|
47
|
+
|
48
|
+
provides: [Color]
|
49
|
+
|
50
|
+
...
|
51
|
+
*/
|
52
|
+
/*
|
53
|
+
---
|
54
|
+
|
55
|
+
script: Input.Color.js
|
56
|
+
|
57
|
+
description: Cool colorpicker for everyone to enjoy
|
58
|
+
|
59
|
+
license: MIT-style license
|
60
|
+
|
61
|
+
authors:
|
62
|
+
- Yaroslaff Fedin
|
63
|
+
|
64
|
+
requires:
|
65
|
+
- Color
|
66
|
+
|
67
|
+
provides: [Input.Color]
|
68
|
+
|
69
|
+
...
|
70
|
+
*/
|
@@ -0,0 +1,33 @@
|
|
1
|
+
{
|
2
|
+
"Widget": {
|
3
|
+
"Input": {
|
4
|
+
"Input.Color": {
|
5
|
+
"provides": [
|
6
|
+
"Input.Color"
|
7
|
+
],
|
8
|
+
"requires": [
|
9
|
+
"Color"
|
10
|
+
],
|
11
|
+
"desc": "Cool colorpicker for everyone to enjoy"
|
12
|
+
},
|
13
|
+
"provides": [
|
14
|
+
"Input"
|
15
|
+
],
|
16
|
+
"requires": [
|
17
|
+
|
18
|
+
],
|
19
|
+
"desc": "Generic Input"
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"Library": {
|
23
|
+
"Color": {
|
24
|
+
"provides": [
|
25
|
+
"Color"
|
26
|
+
],
|
27
|
+
"requires": [
|
28
|
+
"Mootools/Core"
|
29
|
+
],
|
30
|
+
"desc": "A library to work with colors"
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/*
|
2
|
+
---
|
3
|
+
|
4
|
+
script: Input.Color.js
|
5
|
+
|
6
|
+
description: Cool colorpicker for everyone to enjoy
|
7
|
+
|
8
|
+
license: MIT-style license
|
9
|
+
|
10
|
+
authors:
|
11
|
+
- Yaroslaff Fedin
|
12
|
+
|
13
|
+
requires:
|
14
|
+
- Color
|
15
|
+
- Input
|
16
|
+
|
17
|
+
provides: [Input.Color]
|
18
|
+
|
19
|
+
...
|
20
|
+
*/
|
@@ -0,0 +1,10 @@
|
|
1
|
+
name: Package
|
2
|
+
filename: package.js
|
3
|
+
web: http://github.com/markiz/jsus
|
4
|
+
description: Jsus package with external dependency
|
5
|
+
license: Public Domain, http://unlicense.org/UNLICENSE
|
6
|
+
authors: Mark Abramov (http://github.com/markiz)
|
7
|
+
sources:
|
8
|
+
- "Source/Library/Color.js"
|
9
|
+
- "Source/Widget/Input/Input.Color.js"
|
10
|
+
- "Source/Widget/Input.js"
|
@@ -0,0 +1,23 @@
|
|
1
|
+
/*
|
2
|
+
---
|
3
|
+
|
4
|
+
script: Array.Extras.js
|
5
|
+
|
6
|
+
name: Array.Extras
|
7
|
+
|
8
|
+
description: Extends the Array native object to include useful methods to work with arrays.
|
9
|
+
|
10
|
+
license: MIT-style license
|
11
|
+
|
12
|
+
authors:
|
13
|
+
- Christoph Pojer
|
14
|
+
- Sebastian Markbåge
|
15
|
+
|
16
|
+
requires:
|
17
|
+
- Core/Array
|
18
|
+
- MooTools.More
|
19
|
+
|
20
|
+
provides: [Array.Extras]
|
21
|
+
|
22
|
+
...
|
23
|
+
*/
|
@@ -0,0 +1,23 @@
|
|
1
|
+
/*
|
2
|
+
---
|
3
|
+
|
4
|
+
script: Array.Extras.js
|
5
|
+
|
6
|
+
name: Array.Extras
|
7
|
+
|
8
|
+
description: Extends the Array native object to include useful methods to work with arrays.
|
9
|
+
|
10
|
+
license: MIT-style license
|
11
|
+
|
12
|
+
authors:
|
13
|
+
- Christoph Pojer
|
14
|
+
- Sebastian Markbåge
|
15
|
+
|
16
|
+
requires:
|
17
|
+
- Core/Array
|
18
|
+
- MooTools.More
|
19
|
+
|
20
|
+
provides: [Array.Extras]
|
21
|
+
|
22
|
+
...
|
23
|
+
*/
|
@@ -0,0 +1,216 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'sinatra/base'
|
3
|
+
require 'rack/test'
|
4
|
+
|
5
|
+
describe Jsus::Middleware do
|
6
|
+
include Rack::Test::Methods
|
7
|
+
def new_server
|
8
|
+
Sinatra.new do
|
9
|
+
use Jsus::Middleware
|
10
|
+
set :port, 4567
|
11
|
+
set :raise_errors, true
|
12
|
+
set :show_exceptions, false
|
13
|
+
get("/") { "Ping" }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def suppress_output
|
18
|
+
old_stdout, old_stderr = $stdout, $stderr
|
19
|
+
$stdout, $stderr = IO.new('/dev/null'), IO.new('/dev/null')
|
20
|
+
yield
|
21
|
+
$stdout, $stderr = old_stdout, old_stderr
|
22
|
+
end
|
23
|
+
|
24
|
+
before(:all) do
|
25
|
+
@server = new_server
|
26
|
+
@server_thread = Thread.new { suppress_output { @server.run! } }
|
27
|
+
end
|
28
|
+
|
29
|
+
after(:all) { @server_thread.kill }
|
30
|
+
|
31
|
+
let(:app) { Rack::Lint.new(@server) }
|
32
|
+
|
33
|
+
it "should not override non-jsus calls" do
|
34
|
+
get("/").body.should == "Ping"
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "settings" do
|
38
|
+
it "should have some defaults" do
|
39
|
+
described_class.settings.should be_a(Hash)
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should merge settings, instead of full overriding on .settings=" do
|
43
|
+
described_class.settings = {:hello => :world}
|
44
|
+
described_class.settings = {:people => :worthless}
|
45
|
+
described_class.settings.should include({:hello => :world, :people => :worthless})
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context "for basic package with an external dependency" do
|
50
|
+
let(:packages_dir) { File.expand_path("spec/data/ComplexDependencies") }
|
51
|
+
before(:each) { described_class.settings = {:packages_dir => packages_dir} }
|
52
|
+
|
53
|
+
describe "/javascripts/jsus/require/Package.js" do
|
54
|
+
let(:path) { "/javascripts/jsus/require/Package.js" }
|
55
|
+
|
56
|
+
it "should be successful" do
|
57
|
+
get(path).should be_successful
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should respond with type text/javascript" do
|
61
|
+
get(path).content_type.should == "text/javascript"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should respond with generated package content" do
|
65
|
+
get(path).body.should include("script: Input.js")
|
66
|
+
get(path).body.should include("script: Color.js")
|
67
|
+
get(path).body.should include("script: Input.Color.js")
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should include dependencies by default" do
|
71
|
+
get(path).body.should include("script: Core.js")
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should preserve correct order" do
|
75
|
+
body = get(path).body
|
76
|
+
body.index("script: Core.js").should < body.index("script: Color.js")
|
77
|
+
body.index("script: Color.js").should < body.index("script: Input.Color.js")
|
78
|
+
body.index("script: Input.js").should < body.index("script: Input.Color.js")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe "using ~Tags" do
|
83
|
+
let(:path) { "/javascripts/jsus/require/Package~Package:Color.js" }
|
84
|
+
|
85
|
+
it "should be successful" do
|
86
|
+
get(path).should be_successful
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should respond with type text/javascript" do
|
90
|
+
get(path).content_type.should == "text/javascript"
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should respond with generated content" do
|
94
|
+
get(path).body.should include("script: Input.Color.js")
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should not include dependencies mentioned in exclude directive" do
|
98
|
+
get(path).body.should_not include("script: Color.js")
|
99
|
+
get(path).body.should_not include("script: Core.js")
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should not fail when used with non-existent tag" do
|
103
|
+
result = get("/javascripts/jsus/require/Package~Package:Colorful.js")
|
104
|
+
result.should be_successful
|
105
|
+
result.body.should include("script: Input.Color.js")
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should be chainable" do
|
109
|
+
result = get("/javascripts/jsus/require/Package~Mootools:Core~Package:Input.js")
|
110
|
+
result.should be_successful
|
111
|
+
result.body.should include("script: Input.Color.js")
|
112
|
+
result.body.should include("script: Color.js")
|
113
|
+
result.body.should_not include("script: Input.js")
|
114
|
+
result.body.should_not include("script: Core.js")
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "using +Tags" do
|
119
|
+
let(:path) { "/javascripts/jsus/require/Package:Color+Package:Input.js" }
|
120
|
+
|
121
|
+
it "should be successful" do
|
122
|
+
get(path).should be_successful
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should respond with type text/javascript" do
|
126
|
+
get(path).content_type.should == "text/javascript"
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should respond with generated content" do
|
130
|
+
get(path).body.should include("script: Color.js")
|
131
|
+
get(path).body.should include("script: Input.js")
|
132
|
+
end
|
133
|
+
|
134
|
+
it "should not include files not mentioned in include directive" do
|
135
|
+
get(path).body.should_not include("script: Input.Color.js")
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should not fail when used with non-existent tag" do
|
139
|
+
result = get("/javascripts/jsus/require/Package:Color+Package:Colorful.js")
|
140
|
+
result.should be_successful
|
141
|
+
result.body.should include("script: Color.js")
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should be chainable" do
|
145
|
+
result = get("/javascripts/jsus/require/Package:Color+Package:Input~Mootools:Core.js")
|
146
|
+
result.should be_successful
|
147
|
+
result.body.should include("script: Input.js")
|
148
|
+
result.body.should include("script: Color.js")
|
149
|
+
result.body.should_not include("script: Input.Color.js")
|
150
|
+
result.body.should_not include("script: Core.js")
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
describe "/javascripts/jsus/require/Package:Input.Color.js" do
|
155
|
+
let(:path) { "/javascripts/jsus/require/Package:Input.Color.js" }
|
156
|
+
|
157
|
+
it "should be successful" do
|
158
|
+
get(path).should be_successful
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should respond with type text/javascript" do
|
162
|
+
get(path).content_type.should == "text/javascript"
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should respond with generated content" do
|
166
|
+
get(path).body.should include("script: Input.Color.js")
|
167
|
+
end
|
168
|
+
|
169
|
+
it "should include dependencies by default" do
|
170
|
+
get(path).body.should include("script: Color.js")
|
171
|
+
get(path).body.should include("script: Core.js")
|
172
|
+
end
|
173
|
+
|
174
|
+
it "should preserve correct order" do
|
175
|
+
body = get(path).body
|
176
|
+
body.index("script: Color.js").should < body.index("script: Input.Color.js")
|
177
|
+
body.index("script: Color.js").should > body.index("script: Core.js")
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
describe "for invalid paths" do
|
183
|
+
describe "when package is non-existent" do
|
184
|
+
let(:path) { "/javascripts/jsus/require/randomshit.js" }
|
185
|
+
it "should return 404" do
|
186
|
+
get(path).should be_not_found
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
describe "when required file is non-existent" do
|
191
|
+
let(:path) { "/javascripts/jsus/require/nonexistent:randomshit.js" }
|
192
|
+
it "should return 404" do
|
193
|
+
get(path).should be_not_found
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
describe "when given random gibberish" do
|
198
|
+
let(:path) { "/javascripts/jsus/require/+++---asda~~:sda_s+__+-dr928213dasasda=d%20%32%13__=_-=--/asa/sd/.asd13/.js" }
|
199
|
+
it "should return 404" do
|
200
|
+
get(path).should be_not_found
|
201
|
+
end
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
describe "caching" do
|
206
|
+
let(:cache_path) { "spec/tmp" }
|
207
|
+
before(:each) { Jsus::Middleware.settings = {:cache => true, :cache_path => cache_path} }
|
208
|
+
after(:each) { FileUtils.rm_rf(cache_path) }
|
209
|
+
let(:path) { "/javascripts/jsus/require/Package.js" }
|
210
|
+
it "should save output of requests to files" do
|
211
|
+
result = get(path).body
|
212
|
+
File.exists?("#{cache_path}/Package.js").should be_true
|
213
|
+
File.read("#{cache_path}/Package.js").should == result
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
data/spec/jsus/package_spec.rb
CHANGED
@@ -31,7 +31,7 @@ describe Jsus::Package do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should set up outside dependencies" do
|
34
|
-
subject.dependencies_names.should == ['
|
34
|
+
subject.dependencies_names.should == ['Core/Class']
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should set directory field" do
|
@@ -61,12 +61,12 @@ describe Jsus::Package do
|
|
61
61
|
required_files = Dir["#{input_dir}/**/*.js"].map {|f| IO.read(f) }
|
62
62
|
required_files.each {|f| compiled_content.should include(f)}
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
context "when given nil" do
|
66
66
|
it "should not raise errors" do
|
67
67
|
lambda { subject.compile(nil) }.should_not raise_error
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
it "should return a string with compiled content" do
|
71
71
|
compiled_content = subject.compile(nil)
|
72
72
|
required_files = Dir["#{input_dir}/**/*.js"].map {|f| IO.read(f) }
|
@@ -84,7 +84,7 @@ describe Jsus::Package do
|
|
84
84
|
info["provides"].should have_exactly(4).items
|
85
85
|
info["provides"].should include("Color", "Widget", "Input", "Input.Color")
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
context "when external dependencies are included" do
|
89
89
|
let(:lib_dir) { "spec/data/ChainDependencies/app/javascripts" }
|
90
90
|
let(:pool) { Jsus::Pool.new(lib_dir) }
|
@@ -122,7 +122,7 @@ describe Jsus::Package do
|
|
122
122
|
tree["Widget"]["Input"]["Input.Color"]["requires"].should include("Input", "Color")
|
123
123
|
tree["Widget"]["Input"]["Input.Color"]["provides"].should == ["Input.Color"]
|
124
124
|
end
|
125
|
-
|
125
|
+
|
126
126
|
it "should allow different filenames" do
|
127
127
|
subject.generate_tree(output_dir, "structure.json")
|
128
128
|
File.exists?("#{output_dir}/structure.json").should be_true
|
@@ -130,7 +130,7 @@ describe Jsus::Package do
|
|
130
130
|
tree["Library"]["Color"]["provides"].should == ["Color"]
|
131
131
|
end
|
132
132
|
end
|
133
|
-
|
133
|
+
|
134
134
|
describe "#required_files" do
|
135
135
|
it "should list required files in correct order" do
|
136
136
|
required_files = subject.required_files
|
@@ -174,4 +174,10 @@ describe Jsus::Package do
|
|
174
174
|
end
|
175
175
|
|
176
176
|
end
|
177
|
+
|
178
|
+
describe "#filename" do
|
179
|
+
it "should convert package name to snake_case" do
|
180
|
+
subject.filename.should == "orwik.js"
|
181
|
+
end
|
182
|
+
end
|
177
183
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: utf-8
|
1
2
|
require 'spec_helper'
|
2
3
|
|
3
4
|
describe Jsus::SourceFile do
|
@@ -34,12 +35,12 @@ describe Jsus::SourceFile do
|
|
34
35
|
lambda { Jsus::SourceFile.from_file('spec/data/non-existant-file.js') }.should raise_error
|
35
36
|
end
|
36
37
|
end
|
37
|
-
|
38
|
+
|
38
39
|
context "when some error happens" do
|
39
40
|
it "should raise error" do
|
40
41
|
YAML.stub!(:load) { raise "Could not parse the file!" }
|
41
42
|
lambda { subject }.should raise_error(RuntimeError, /spec\/data\/test_source_one\.js/)
|
42
|
-
end
|
43
|
+
end
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
@@ -56,6 +57,28 @@ describe Jsus::SourceFile do
|
|
56
57
|
source.header.should == subject.header
|
57
58
|
end
|
58
59
|
|
60
|
+
it "should not break on unicode files" do
|
61
|
+
source = nil
|
62
|
+
lambda { source = Jsus::SourceFile.from_file("spec/data/unicode_source.js") }.should_not raise_error
|
63
|
+
source.header["authors"][1].should == "Sebastian Markbåge"
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should recognize and ignore BOM marker" do
|
67
|
+
source = nil
|
68
|
+
lambda { source = Jsus::SourceFile.from_file("spec/data/unicode_source_with_bom.js") }.should_not raise_error
|
69
|
+
source.header["authors"][1].should == "Sebastian Markbåge"
|
70
|
+
end
|
71
|
+
|
72
|
+
if defined?(Encoding) && Encoding.respond_to?(:default_external)
|
73
|
+
it "should not break on unicode files even when external encoding is set to non-utf" do
|
74
|
+
old_external = Encoding.default_external
|
75
|
+
Encoding.default_external = 'us-ascii'
|
76
|
+
source = nil
|
77
|
+
lambda { source = Jsus::SourceFile.from_file("spec/data/unicode_source.js") }.should_not raise_error
|
78
|
+
source.header["authors"][1].should == "Sebastian Markbåge"
|
79
|
+
Encoding.default_external = old_external
|
80
|
+
end
|
81
|
+
end
|
59
82
|
end
|
60
83
|
|
61
84
|
context "when no package set, " do
|
@@ -79,13 +102,13 @@ describe Jsus::SourceFile do
|
|
79
102
|
subject.dependencies_names(:short => true).should == ["Class"]
|
80
103
|
end
|
81
104
|
end
|
82
|
-
|
105
|
+
|
83
106
|
describe "#external_dependencies" do
|
84
107
|
it "should be empty" do
|
85
108
|
subject.external_dependencies.should be_empty
|
86
109
|
end
|
87
110
|
end
|
88
|
-
|
111
|
+
|
89
112
|
describe "#external_dependencies_names" do
|
90
113
|
it "should be empty" do
|
91
114
|
subject.external_dependencies_names.should be_empty
|
@@ -126,18 +149,18 @@ describe Jsus::SourceFile do
|
|
126
149
|
subject.dependencies_names(:short => true).should include("Class", "Mash/Mash")
|
127
150
|
end
|
128
151
|
end
|
129
|
-
|
152
|
+
|
130
153
|
describe "#external_dependencies" do
|
131
|
-
it "should include external dependencies" do
|
154
|
+
it "should include external dependencies" do
|
132
155
|
subject.should have_exactly(1).external_dependencies
|
133
156
|
subject.external_dependencies.should include(Jsus::Tag["Mash/Mash"])
|
134
157
|
end
|
135
|
-
|
158
|
+
|
136
159
|
it "should not include internal dependencies" do
|
137
160
|
subject.external_dependencies.should_not include(Jsus::Tag["Orwik/Class"])
|
138
161
|
end
|
139
162
|
end
|
140
|
-
|
163
|
+
|
141
164
|
describe "#external_dependencies_names" do
|
142
165
|
it "should include names of external dependencies" do
|
143
166
|
subject.external_dependencies_names.should include("Mash/Mash")
|
@@ -147,7 +170,7 @@ describe Jsus::SourceFile do
|
|
147
170
|
subject.external_dependencies_names.should_not include("Orwik/Class")
|
148
171
|
end
|
149
172
|
end
|
150
|
-
|
173
|
+
|
151
174
|
end
|
152
175
|
|
153
176
|
context "when pool is not set, " do
|
@@ -259,18 +282,23 @@ describe Jsus::SourceFile do
|
|
259
282
|
end
|
260
283
|
end
|
261
284
|
end
|
262
|
-
|
285
|
+
|
286
|
+
it "should allow quirky mooforge dependencies syntax" do
|
287
|
+
subject = described_class.from_file("spec/data/mooforge_quirky_source.js")
|
288
|
+
subject.dependencies_names.should == ["MootoolsCore/Core"]
|
289
|
+
end
|
290
|
+
|
263
291
|
describe "#==, eql, hash" do
|
264
292
|
it "should return true for source files pointing to the same physical file" do
|
265
293
|
subject.should == described_class.from_file(subject.filename)
|
266
294
|
subject.should eql(described_class.from_file(subject.filename))
|
267
295
|
subject.hash.should == described_class.from_file(subject.filename).hash
|
268
296
|
end
|
269
|
-
|
297
|
+
|
270
298
|
it "should return false for source files pointing to different physical files" do
|
271
299
|
subject.should_not == described_class.from_file("spec/data/Extensions/app/javascripts/Orwik/Extensions/Class.js")
|
272
300
|
subject.should_not eql(described_class.from_file("spec/data/Extensions/app/javascripts/Orwik/Extensions/Class.js"))
|
273
301
|
subject.hash.should_not == described_class.from_file("spec/data/Extensions/app/javascripts/Orwik/Extensions/Class.js").hash
|
274
|
-
end
|
275
|
-
end
|
276
|
-
end
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
data/spec/jsus/tag_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Jsus::Tag do
|
4
4
|
subject { Jsus::Tag.new("Wtf") }
|
5
5
|
|
6
|
-
context "initialization" do
|
6
|
+
context "initialization" do
|
7
7
|
it "should set given name" do
|
8
8
|
Jsus::Tag.new("Wtf").name.should == "Wtf"
|
9
9
|
end
|
@@ -45,6 +45,12 @@ describe Jsus::Tag do
|
|
45
45
|
it "should return a given tag if given a tag" do
|
46
46
|
Jsus::Tag.new(subject).should == subject
|
47
47
|
end
|
48
|
+
|
49
|
+
it "should translate mooforge styled names into jsus-styled names" do
|
50
|
+
Jsus::Tag.new("mootools_core/Wtf").should == Jsus::Tag.new("MootoolsCore/Wtf")
|
51
|
+
Jsus::Tag.new("Effects.Fx/Hello.World").should == Jsus::Tag.new("EffectsFx/Hello.World")
|
52
|
+
Jsus::Tag.new("effects.fx/Wtf").should == Jsus::Tag.new("EffectsFx/Wtf")
|
53
|
+
end
|
48
54
|
end
|
49
55
|
|
50
56
|
describe "#name" do
|
@@ -106,7 +112,7 @@ describe Jsus::Tag do
|
|
106
112
|
it "should return true when tag is empty" do
|
107
113
|
Jsus::Tag.new("").should be_empty
|
108
114
|
end
|
109
|
-
|
115
|
+
|
110
116
|
it "should return false when tag is not empty" do
|
111
117
|
Jsus::Tag.new("Core/Mash").should_not be_empty
|
112
118
|
end
|