assetify 2.0.0 → 2.0.1
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.
- data/Rakefile +37 -56
- data/lib/assetify/asset.rb +1 -1
- data/lib/assetify/dsl.rb +26 -15
- data/lib/assetify/version.rb +1 -1
- metadata +26 -41
- data/.document +0 -5
- data/.rspec +0 -1
- data/Assetfile +0 -9
- data/Gemfile +0 -14
- data/Gemfile.lock +0 -40
- data/VERSION +0 -1
- data/assetify.gemspec +0 -111
- data/spec/assetify/asset_spec.rb +0 -70
- data/spec/assetify/dsl_spec.rb +0 -181
- data/spec/assetify/helpers_spec.rb +0 -40
- data/spec/assetify/path_spec.rb +0 -83
- data/spec/assetify/pkg_spec.rb +0 -59
- data/spec/assetify_spec.rb +0 -68
- data/spec/fixtures/complex.tgz +0 -0
- data/spec/fixtures/fancy.tgz +0 -0
- data/spec/fixtures/mobile.css +0 -309
- data/spec/fixtures/sassify.css +0 -12
- data/spec/spec_helper.rb +0 -20
data/spec/assetify/asset_spec.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe Asset do
|
4
|
-
|
5
|
-
it "should spawn!" do
|
6
|
-
as = Asset.new :js, "cool", "http://cool.js"
|
7
|
-
as.should be_instance_of Asset
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "Instantiated" do
|
11
|
-
|
12
|
-
let (:as) { Asset.new :js, "sweet", "http://candy.js" }
|
13
|
-
|
14
|
-
it "should have filename" do
|
15
|
-
as.filename.should eql("sweet.js")
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should have fullpath" do
|
19
|
-
as.fullpath.should eql("vendor/assets/javascripts/sweet.js")
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should detect version" do
|
23
|
-
as.instance_variable_set "@data", "/* foo v 1.5.6 */"
|
24
|
-
as.ver[0].should eql("1.5.6")
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should print version" do
|
28
|
-
as.instance_variable_set "@data", "\u001F\x8B\b\u0000\xF5\u0000"
|
29
|
-
as.print_version.should eql("v537c8396f74 ")
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "Namespaced" do
|
35
|
-
|
36
|
-
let (:as) { Asset.new :js, "sweet", "http://candy.js", nil, :ns => "spacemonkey" }
|
37
|
-
|
38
|
-
it "should have name" do
|
39
|
-
as.ns.should eql("spacemonkey")
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "On Package" do
|
45
|
-
|
46
|
-
let (:as) { Asset.new :js, "sweet", "http://candy.js", nil, :pkg => "firefly" }
|
47
|
-
|
48
|
-
it "should have name" do
|
49
|
-
as.pkg.should eql("firefly")
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "Class methods" do
|
55
|
-
|
56
|
-
it "should have all assets on hand" do
|
57
|
-
Asset.all.should have(2).assets
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should find assets" do
|
61
|
-
Asset.filter("color").should have(1).assets
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should find assets by pkg" do
|
65
|
-
Asset.filter("mobile").should have(1).assets
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
data/spec/assetify/dsl_spec.rb
DELETED
@@ -1,181 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe DSL do
|
4
|
-
|
5
|
-
it "should parse js nicely" do
|
6
|
-
a = Assetify::DSL.parse("js 'foo', 'foolink'")[0]
|
7
|
-
a.should be_an Asset
|
8
|
-
a.fullpath.should eql("vendor/assets/javascripts/foo.js")
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should parse css nicely" do
|
12
|
-
a = Assetify::DSL.parse("css 'foo', 'foolink'")[0]
|
13
|
-
a.should be_an Asset
|
14
|
-
a.fullpath.should eql("vendor/assets/stylesheets/foo.css")
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should parse img nicely (gif)" do
|
18
|
-
a = Assetify::DSL.parse("img 'foo.gif', 'foolink'")[0]
|
19
|
-
a.should be_an Asset
|
20
|
-
a.fullpath.should eql("vendor/assets/images/foo.gif")
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should parse img nicely from link (gif)" do
|
24
|
-
a = Assetify::DSL.parse("img 'foo', 'foolink.gif'")[0]
|
25
|
-
a.should be_an Asset
|
26
|
-
a.fullpath.should eql("vendor/assets/images/foo.gif")
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should parse img nicely from link (png)" do
|
30
|
-
a = Assetify::DSL.parse("img 'foo', 'foolink-ra.png'")[0]
|
31
|
-
a.should be_an Asset
|
32
|
-
a.fullpath.should eql("vendor/assets/images/foo.png")
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should parse js with global 'a' keyword" do
|
36
|
-
a = Assetify::DSL.parse("a 'foo', 'foolink.js'")[0]
|
37
|
-
a.should be_an Asset
|
38
|
-
a.fullpath.should eql("vendor/assets/javascripts/foo.js")
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should parse js with global 'asset' alias too" do
|
42
|
-
a = Assetify::DSL.parse("asset 'foo', 'foolink.js'")[0]
|
43
|
-
a.should be_an Asset
|
44
|
-
a.fullpath.should eql("vendor/assets/javascripts/foo.js")
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should parse css with global 'a' keyword" do
|
48
|
-
a = Assetify::DSL.parse("a 'foo', 'http://w.foolink/c/?foo.css'")[0]
|
49
|
-
a.should be_an Asset
|
50
|
-
a.fullpath.should eql("vendor/assets/stylesheets/foo.css")
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should parse img with global 'a' keyword" do
|
54
|
-
a = Assetify::DSL.parse("a 'foo.gif', 'foolink.gif'")[0]
|
55
|
-
a.should be_an Asset
|
56
|
-
a.fullpath.should eql("vendor/assets/images/foo.gif")
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should accept a especific location with :to" do
|
60
|
-
Dir.should_receive(:pwd).and_return("/home/user/git/assetify")
|
61
|
-
a = Assetify::DSL.parse("rb 'foo', 'foolink', :to => 'spec/rock'")[0]
|
62
|
-
a.should be_an Asset
|
63
|
-
a.fullpath.should eql("/home/user/git/assetify/spec/rock/foo.rb")
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should not fail with symbols" do
|
67
|
-
a = Assetify::DSL.parse("js :jnice, 'foolink'")[0]
|
68
|
-
a.should be_an Asset
|
69
|
-
a.name.should eql("jnice")
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "Templates and Pathfixes" do
|
73
|
-
|
74
|
-
it "should parse css to erb nicely" do
|
75
|
-
a = Assetify::DSL.parse("css 'foo', 'foolink', :as => :erb")[0]
|
76
|
-
a.should be_an Asset
|
77
|
-
a.fullpath.should eql("vendor/assets/stylesheets/foo.css.erb")
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should parse css to sass nicely" do
|
81
|
-
a = Assetify::DSL.parse("css 'foo', 'foolink', :as => :sass")[0]
|
82
|
-
a.should be_an Asset
|
83
|
-
a.fullpath.should eql("vendor/assets/stylesheets/foo.css.sass")
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
|
88
|
-
describe "Group Assets" do
|
89
|
-
|
90
|
-
it "should group and use a namespace" do
|
91
|
-
a = Assetify::DSL.parse "group 'common' do; js 'foo', 'foolink'; end"
|
92
|
-
a[0].should be_an Asset
|
93
|
-
a[0].fullpath.should eql("vendor/assets/javascripts/common/foo.js")
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should group and use a namespace 2" do
|
97
|
-
a = Assetify::DSL.parse "group 'common' do; js 'foo', 'foolink'; js 'rock', 'rocklink'; end"
|
98
|
-
a[0].should be_an Asset
|
99
|
-
a[0].fullpath.should eql("vendor/assets/javascripts/common/foo.js")
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should go back to root" do
|
103
|
-
a = Assetify::DSL.parse "group 'common' do; js 'foo', 'foolink'; end; js 'rock', 'rocklink'"
|
104
|
-
a[1].should be_an Asset
|
105
|
-
a[1].fullpath.should eql("vendor/assets/javascripts/rock.js")
|
106
|
-
end
|
107
|
-
|
108
|
-
it "should work with nested namespaces" do
|
109
|
-
a = Assetify::DSL.parse "group 'common' do; group 'nice' do; js 'foo', 'foolink'; end; end"
|
110
|
-
a[0].should be_an Asset
|
111
|
-
a[0].fullpath.should eql("vendor/assets/javascripts/common/nice/foo.js")
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
describe "Pkg Assets" do
|
117
|
-
|
118
|
-
it "should group and use a namespace" do
|
119
|
-
a = Assetify::DSL.parse "pkg 'fancy', 'http://fancy.zip' do; js 'foo', 'foolink'; end"
|
120
|
-
a[0].should be_an Asset
|
121
|
-
a[0].fullpath.should eql("vendor/assets/javascripts/fancy/foo.js")
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should use name as namespace too" do
|
125
|
-
a = Assetify::DSL.parse "pkg 'complex', '/tmp/complex/complex.tgz' do; dir 'images/*'; end"
|
126
|
-
a.should have(3).assets
|
127
|
-
a[0].fullpath.should eql("vendor/assets/images/complex/two.png")
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should accept shallow too" do
|
131
|
-
a = Assetify::DSL.parse "pkg 'fancy', 'http://fancy.zip', :shallow => true do; js 'foo', 'foolink'; end"
|
132
|
-
a[0].should be_an Asset
|
133
|
-
a[0].fullpath.should eql("vendor/assets/javascripts/foo.js")
|
134
|
-
end
|
135
|
-
|
136
|
-
it "should fetch inside archive" do
|
137
|
-
a = Assetify::DSL.parse "pkg 'fancy', 'http://fancy.zip' do; js 'foo', 'foolink'; end"
|
138
|
-
a[0].should be_an Asset
|
139
|
-
a[0].fullpath.should eql("vendor/assets/javascripts/fancy/foo.js")
|
140
|
-
end
|
141
|
-
|
142
|
-
it "should unpack to vendor if no block given" do
|
143
|
-
Pkg.should_receive(:new).with("fancy", "http://fancy.zip").and_return(mp = mock(Pkg))
|
144
|
-
mp.should_receive :unpack_all
|
145
|
-
a = Assetify::DSL.parse "pkg 'fancy', 'http://fancy.zip'"
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
describe "Directories" do
|
150
|
-
|
151
|
-
it "should read from pkg the regex" do
|
152
|
-
Pkg.should_receive(:new).with("fancy", "http://fancy.zip").and_return(mp = mock(Pkg))
|
153
|
-
mp.should_receive(:get).with("images/").and_return([])
|
154
|
-
a = Assetify::DSL.parse "pkg 'fancy', 'http://fancy.zip' do; dir 'images/', :to => 'images/complex/'; end"
|
155
|
-
end
|
156
|
-
|
157
|
-
it "should read from pkg the regex" do
|
158
|
-
Dir.should_receive(:pwd).and_return("/home/user/git/assetify")
|
159
|
-
|
160
|
-
as = Assetify::DSL.parse "pkg 'complex', 'http://complex.tgz' do; dir 'images/', :to => 'images/complex/'; end"
|
161
|
-
as[0].name.should eql("two")
|
162
|
-
as[0].ext.should eql("png")
|
163
|
-
as[0].fullpath.should eql("/home/user/git/assetify/images/complex/two.png")
|
164
|
-
end
|
165
|
-
|
166
|
-
end
|
167
|
-
|
168
|
-
describe "Paths" do
|
169
|
-
|
170
|
-
it "should change js path" do
|
171
|
-
Assetify::DSL.parse "javascripts 'other/foo'"
|
172
|
-
Opt[:javascripts].should eql('other/foo')
|
173
|
-
end
|
174
|
-
|
175
|
-
it "should change css path" do
|
176
|
-
Assetify::DSL.parse "stylesheets 'other/foo'"
|
177
|
-
Opt[:javascripts].should eql('other/foo')
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe Helpers do
|
4
|
-
BINDATA = File.read(File.join(File.dirname(__FILE__), "..", "fixtures", "complex.tgz"))
|
5
|
-
|
6
|
-
include Helpers
|
7
|
-
|
8
|
-
it "should detect text as not binary" do
|
9
|
-
"I'm not a cylon!".should_not be_binary
|
10
|
-
"/*** Comment nice for v1.4.5 ***/".should_not be_binary
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should detect robot talk as binary" do
|
14
|
-
BINDATA.should be_binary
|
15
|
-
"\u001F\x8B\b\u0000\xF5\u0000".should be_binary
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should find from a long version" do
|
19
|
-
find_version("frips 1.5.7.786").should eql(["1.5.7.786", 1, 5, 7, 786])
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should find version from text" do
|
23
|
-
find_version("Foo v 1.5.6").should eql(["1.5.6", 1, 5, 6])
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should find version from text" do
|
27
|
-
find_version("/*!\n * jQuery JavaScript Library v1.6\n * http://jquery.com/\n *\n * Copyright 2011, John Resig\n * Date: Mon May 2 13:50:00 2011 -0400").
|
28
|
-
should eql(["1.6", 1, 6])
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should find version from binary" do
|
32
|
-
find_version(BINDATA).should eql("c29b335e572251b1b79b88bf8c2847ec")
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should rescue fine if there isn`t version" do
|
36
|
-
find_version("/* -------------------------------------------------------------- reset.css * Resets default browser CSS.").
|
37
|
-
should eql("d356b6a91b0d16e456c7b4f79302d051")
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
data/spec/assetify/path_spec.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe Pathfix do
|
4
|
-
|
5
|
-
it "should spawn!" do
|
6
|
-
f = Pathfix.new "fu"
|
7
|
-
f.should be_instance_of Assetify::Pathfix
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "Simple test ERB" do
|
11
|
-
|
12
|
-
let (:f) { Pathfix.new ".tipsy { padding: 5px; background-image: url(../images/tipsy.gif); }" }
|
13
|
-
|
14
|
-
it "should detect images" do
|
15
|
-
f.images.should eql(["../images/tipsy.gif"])
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should change css" do
|
19
|
-
f.fix.should eql ".tipsy { padding: 5px; background-image: url('<%= image_path('tipsy.gif') %>'); }"
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "Simple test namespaced ERB" do
|
25
|
-
|
26
|
-
let (:f) { Pathfix.new ".tipsy { padding: 5px; background-image: url(../images/tipsy.gif); }", :erb, :nicelib }
|
27
|
-
|
28
|
-
it "should detect images" do
|
29
|
-
f.images.should eql(["../images/tipsy.gif"])
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should change css" do
|
33
|
-
f.fix.should eql ".tipsy { padding: 5px; background-image: url('<%= image_path('nicelib/tipsy.gif') %>'); }"
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
describe "Multiple assets test sass" do
|
40
|
-
|
41
|
-
let (:f) { Pathfix.new "div.rating-cancel,div.rating-cancel a{background:url(delete.gif) no-repeat 0 -16px}
|
42
|
-
div.star-rating,div.star-rating a{background:url(star.gif) no-repeat 0 0px}", :sass }
|
43
|
-
|
44
|
-
it "should detect images" do
|
45
|
-
f.images.should eql(["delete.gif", "star.gif"])
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should change css" do
|
49
|
-
f.fix.should eql "div\n &.rating-cancel\n background: image-url(\"delete.gif\") no-repeat 0 -16px\n a\n background: image-url(\"delete.gif\") no-repeat 0 -16px\n &.star-rating\n background: image-url(\"star.gif\") no-repeat 0 0px\n a\n background: image-url(\"star.gif\") no-repeat 0 0px\n"
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "Multiple assets test scss" do
|
55
|
-
|
56
|
-
let (:f) { Pathfix.new "div.rating-cancel,div.rating-cancel a{background:url(delete.gif) no-repeat 0 -16px}
|
57
|
-
div.star-rating,div.star-rating a{background:url(star.gif) no-repeat 0 0px}", :scss }
|
58
|
-
|
59
|
-
it "should detect images" do
|
60
|
-
f.images.should eql(["delete.gif", "star.gif"])
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should change css" do
|
64
|
-
f.fix.should eql "div {\n &.rating-cancel {\n background: image-url(\"delete.gif\") no-repeat 0 -16px;\n a {\n background: image-url(\"delete.gif\") no-repeat 0 -16px; } }\n &.star-rating {\n background: image-url(\"star.gif\") no-repeat 0 0px;\n a {\n background: image-url(\"star.gif\") no-repeat 0 0px; } } }\n"
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
describe "Multiple assets test big css minified file" do
|
70
|
-
|
71
|
-
let (:f) { Pathfix.new File.read("#{File.dirname(__FILE__)}/../fixtures/mobile.css"), :scss }
|
72
|
-
|
73
|
-
it "should detect images" do
|
74
|
-
f.images.should eql(["images/icons-18-white.png", "images/icons-18-black.png", "images/icons-36-white.png", "images/icons-36-black.png", "images/ajax-loader.png"])
|
75
|
-
end
|
76
|
-
|
77
|
-
# it "should change css" do
|
78
|
-
# f.fix.should match "background-image: image-url(\"images/icons-36-white.png\")"
|
79
|
-
# end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
data/spec/assetify/pkg_spec.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
describe Pkg do
|
4
|
-
|
5
|
-
|
6
|
-
before do
|
7
|
-
[:fancy, :complex].each do |ns|
|
8
|
-
`mkdir /tmp/#{ns}` unless Dir.exists? "/tmp/#{ns}"
|
9
|
-
`cp spec/fixtures/#{ns}.tgz /tmp/#{ns}/`
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should spawn!" do
|
14
|
-
stub_request(:get, "http://cool.js/fancy.tgz").to_return(:body => "Hi")
|
15
|
-
as = Pkg.new "cool", "http://cool.js/fancy.tgz"
|
16
|
-
as.should be_instance_of Pkg
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should spawn!" do
|
20
|
-
as = Pkg.new "cool", "http://cool.js"
|
21
|
-
as.should be_instance_of Pkg
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should get file from unpack" do
|
25
|
-
as = Pkg.new "fancy", "/tmp/fancy/fancy.tgz"
|
26
|
-
as.get("fancy/fancy.css").should eql("fancy/fancy.css" => "// Fancy css!\n\n#foo {\n padding: 10px;\n}\n")
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should get file without path from unpack" do
|
30
|
-
as = Pkg.new "fancy", "/tmp/fancy/fancy.tgz"
|
31
|
-
as.get("fancy.css").should eql("fancy/fancy.css" => "// Fancy css!\n\n#foo {\n padding: 10px;\n}\n")
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should get file from part of the name" do
|
35
|
-
as = Pkg.new "fancy", "/tmp/fancy/fancy.tgz"
|
36
|
-
as.get("cy.css").should eql("fancy/fancy.css" => "// Fancy css!\n\n#foo {\n padding: 10px;\n}\n")
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should read all assets within pkg" do
|
40
|
-
as = Pkg.new "complex", "/tmp/complex/complex.tgz"
|
41
|
-
as.read_from_pkg.should be_a Hash #(hash_including "complex/images/3.png"=>"Im a png image..3\n")
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should unpack all to vendor" do
|
45
|
-
as = Pkg.new "complex", "/tmp/complex/complex.tgz"
|
46
|
-
as.unpack_all #.should be_a Hash #(hash_including "complex/images/3.png"=>"Im a png image..3\n")
|
47
|
-
File.exists?("public/vendor/complex/src/main.js").should be_true
|
48
|
-
`rm -rf vendor/assets/vendor`
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should download pkg only once" do
|
52
|
-
as = Pkg.new "fancy", "/tmp/fancy/fancy.tgz"
|
53
|
-
|
54
|
-
as.should_not_receive(:write)
|
55
|
-
|
56
|
-
as.get("fancy/fancy.css")
|
57
|
-
as.get("fancy/fancy.css")
|
58
|
-
end
|
59
|
-
end
|
data/spec/assetify_spec.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
|
3
|
-
describe Assetify do
|
4
|
-
|
5
|
-
it "shoud read_assetfile" do
|
6
|
-
mock_assetfile
|
7
|
-
Assetfile.read.should have(1).asset
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should skip comments" do
|
11
|
-
mock_assetfile("#\n# Oi\n#\n")
|
12
|
-
Assetfile.read.should be_nil
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should work with versions url" do
|
16
|
-
mock_assetfile("#\n# Oi\n#\njs 'down', 'http://js.com/down-{VERSION}.js', '1.6'")
|
17
|
-
Assetfile.read.first.url.should eql("http://js.com/down-1.6.js")
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "read css" do
|
21
|
-
before do
|
22
|
-
mock_assetfile("#\n# CSS\n#\ncss 'grid', 'http://grid.com/down'")
|
23
|
-
end
|
24
|
-
let(:asset) { Assetfile.read[0] }
|
25
|
-
|
26
|
-
it "should read css" do
|
27
|
-
Assetfile.read.should have(1).asset
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should read css" do
|
31
|
-
Assetfile.read.first.type.should eql(:css)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should have fullpath" do
|
35
|
-
asset.fullpath.should eql("vendor/assets/stylesheets/grid.css")
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "readjs" do
|
41
|
-
|
42
|
-
let(:asset) { mock_assetfile; Assetfile.read[0] }
|
43
|
-
|
44
|
-
it "should be an asset" do
|
45
|
-
asset.should be_an Assetify::Asset
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should be a js file" do
|
49
|
-
asset.type.should eql(:js)
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should have an url" do
|
53
|
-
asset.url.should eql("http://cool.js/down")
|
54
|
-
end
|
55
|
-
|
56
|
-
it "should have a name" do
|
57
|
-
asset.name.should eql("cool")
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should have fullpath" do
|
61
|
-
asset.fullpath.should eql("vendor/assets/javascripts/cool.js")
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
end
|