Skip to content
Newer
Older
100644 403 lines (333 sloc) 13.2 KB
7355d60 @winton First commit (smart_asset)
authored Nov 28, 2010
1 require 'spec_helper'
2
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
3 unless FrameworkFixture.framework
4 describe SmartAsset do
26a5146 @winton Fixing asset_host numbering, adding asset_host_count config option
authored Dec 7, 2010
5
6 include SmartAsset::Helper
7355d60 @winton First commit (smart_asset)
authored Nov 28, 2010
7
8 before(:all) do
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
9 @config = "spec/fixtures/assets.yml"
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
10 @dest = "#{$root}/spec/fixtures/assets/compressed"
11 @files = %w(
12 package.css
13 package.js
14 )
15 @versions = %w(
4931153 @winton More efficient system of hashes for versioning
authored Dec 20, 2010
16 4c0f7deb
6484adb @winton Don't sort timestamps so changes in order will force repackage
authored Dec 20, 2010
17 1042e864
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
18 )
7355d60 @winton First commit (smart_asset)
authored Nov 28, 2010
19 end
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
20
21 describe :load_config do
7355d60 @winton First commit (smart_asset)
authored Nov 28, 2010
22
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
23 before(:all) do
4210530 @winton Making the append_random option configurable by environment
authored Dec 15, 2010
24 SmartAsset.env = 'development'
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
25 SmartAsset.load_config($root, @config)
26 end
27
28 it "should populate @root" do
29 SmartAsset.root.should == $root
30 end
7355d60 @winton First commit (smart_asset)
authored Nov 28, 2010
31
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
32 it "should populate @config" do
357545d @winton Adding asset_host support (picks up from Rails if not specified), spe…
authored Dec 6, 2010
33 SmartAsset.config.should == {
4210530 @winton Making the append_random option configurable by environment
authored Dec 15, 2010
34 "append_random"=>{"development"=>true},
26a5146 @winton Fixing asset_host numbering, adding asset_host_count config option
authored Dec 7, 2010
35 "asset_host_count"=>2,
36 "asset_host"=>{"production"=>"http://assets%d.host.com"},
735bce8 @winton Configurable destination paths
authored Dec 7, 2010
37 "destination"=>{"javascripts"=>"compressed", "stylesheets"=>"compressed"},
e4961d7 @winton Convert from asset packager style syntax
authored Dec 6, 2010
38 "environments"=>["production"],
39 "public"=>"spec/fixtures/assets",
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
40 "sources"=>{"javascripts"=>"javascripts", "stylesheets"=>"stylesheets"},
41 "javascripts"=>
42 {"package"=>["jquery/jquery", "underscore", "does_not_exist"],
7133610 @winton SmartAsset#binary specs
authored Nov 29, 2010
43 "empty_package"=>nil,
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
44 "non_existent_package"=>["does_not_exist"]},
45 "stylesheets"=>
46 {"package"=>["blueprint/blueprint", 960, "does_not_exist"],
7133610 @winton SmartAsset#binary specs
authored Nov 29, 2010
47 "empty_package"=>nil,
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
48 "non_existent_package"=>["does_not_exist"]}}
49 end
735bce8 @winton Configurable destination paths
authored Dec 7, 2010
50
d19b2b2 @winton Adding append_random option, fixing specs
authored Dec 9, 2010
51 it "should populate @append_random" do
4210530 @winton Making the append_random option configurable by environment
authored Dec 15, 2010
52 SmartAsset.append_random.should == true
d19b2b2 @winton Adding append_random option, fixing specs
authored Dec 9, 2010
53 end
54
735bce8 @winton Configurable destination paths
authored Dec 7, 2010
55 it "should populate @asset_host" do
26a5146 @winton Fixing asset_host numbering, adding asset_host_count config option
authored Dec 7, 2010
56 SmartAsset.asset_host.should == {"production"=>"http://assets%d.host.com"}
735bce8 @winton Configurable destination paths
authored Dec 7, 2010
57 end
7355d60 @winton First commit (smart_asset)
authored Nov 28, 2010
58
735bce8 @winton Configurable destination paths
authored Dec 7, 2010
59 it "should populate @dest" do
60 SmartAsset.dest.should == {
61 'javascripts' => "#{$root}/spec/fixtures/assets/compressed",
62 'stylesheets' => "#{$root}/spec/fixtures/assets/compressed"
63 }
64 end
65
66 it "should populate @envs" do
67 SmartAsset.envs.should == ["production"]
68 end
69
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
70 it "should populate @pub" do
71 SmartAsset.pub.should == "#{$root}/spec/fixtures/assets"
72 end
735bce8 @winton Configurable destination paths
authored Dec 7, 2010
73
74 it "should populate @root" do
75 SmartAsset.root.should == $root
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
76 end
77
78 it "should populate @sources" do
79 SmartAsset.sources.should == {"javascripts"=>"javascripts", "stylesheets"=>"stylesheets"}
80 end
7355d60 @winton First commit (smart_asset)
authored Nov 28, 2010
81 end
82
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
83 describe :binary do
84 describe 'no compressed assets' do
7355d60 @winton First commit (smart_asset)
authored Nov 28, 2010
85
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
86 before(:all) do
87 FileUtils.rm_rf(@dest) unless ENV['FAST']
88 @output = capture_stdout do
89 SmartAsset.binary $root, @config
90 end
7133610 @winton SmartAsset#binary specs
authored Nov 29, 2010
91 end
92
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
93 it "should generate correct filenames" do
94 @files.each_with_index do |file, i|
95 File.exists?("#{@dest}/#{@versions[i]}_#{file}").should == true
96 end
bb6d665 @winton Updating packages when config changes, deleting old packages when rem…
authored Dec 10, 2010
97 Dir["#{@dest}/*.{js,css}"].length.should == @files.length
7133610 @winton SmartAsset#binary specs
authored Nov 29, 2010
98 end
99
8baadfa @winton Simplifying scope of project...no longer compressing every file, no l…
authored Dec 8, 2010
100 it "should create package files with content" do
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
101 @files.each_with_index do |file, i|
8baadfa @winton Simplifying scope of project...no longer compressing every file, no l…
authored Dec 8, 2010
102 File.size(path = "#{@dest}/#{@versions[i]}_#{file}").should > 0
103 if i == 0
104 css = File.read(path)
6484adb @winton Don't sort timestamps so changes in order will force repackage
authored Dec 21, 2010
105 css.index('.error').should < css.index('.container_12')
8baadfa @winton Simplifying scope of project...no longer compressing every file, no l…
authored Dec 8, 2010
106 css.include?('.error').should == true
6484adb @winton Don't sort timestamps so changes in order will force repackage
authored Dec 21, 2010
107 css.include?('.container_12').should == true
8baadfa @winton Simplifying scope of project...no longer compressing every file, no l…
authored Dec 8, 2010
108 else
109 js = File.read(path)
6484adb @winton Don't sort timestamps so changes in order will force repackage
authored Dec 21, 2010
110 js.index('jQuery').should < js.index('VERSION')
8baadfa @winton Simplifying scope of project...no longer compressing every file, no l…
authored Dec 8, 2010
111 js.include?('jQuery').should == true
112 js.include?('VERSION').should == true
113 end
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
114 end
7133610 @winton SmartAsset#binary specs
authored Nov 29, 2010
115 end
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
116
117 unless ENV['FAST']
118 it "should run all files through the compressor" do
8baadfa @winton Simplifying scope of project...no longer compressing every file, no l…
authored Dec 8, 2010
119 @files.each do |file|
120 @output.string.include?(file).should == true
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
121 end
122 end
7133610 @winton SmartAsset#binary specs
authored Nov 29, 2010
123 end
8415086 @winton Fixing YUI compression issue, " and (" becomes " and("
authored Dec 10, 2010
124
125 it "should fix YUI compression issue" do
126 File.read("#{@dest}/#{@versions[0]}_#{@files[0]}").include?("screen and (").should == true
127 end
7133610 @winton SmartAsset#binary specs
authored Nov 29, 2010
128 end
4931153 @winton More efficient system of hashes for versioning
authored Dec 21, 2010
129
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
130 describe 'one version out of date' do
4931153 @winton More efficient system of hashes for versioning
authored Dec 21, 2010
131
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
132 before(:all) do
133 unless ENV['FAST']
4931153 @winton More efficient system of hashes for versioning
authored Dec 21, 2010
134 FileUtils.mv "#{@dest}/#{@versions[0]}_#{@files[0]}", "#{@dest}/00000000_#{@files[0]}"
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
135 end
136 @output = capture_stdout do
137 SmartAsset.binary $root, @config
138 end
139 end
4931153 @winton More efficient system of hashes for versioning
authored Dec 21, 2010
140
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
141 it "should generate correct filenames" do
142 @files.each_with_index do |file, i|
143 File.exists?("#{@dest}/#{@versions[i]}_#{file}").should == true
144 end
bb6d665 @winton Updating packages when config changes, deleting old packages when rem…
authored Dec 10, 2010
145 Dir["#{@dest}/*.{js,css}"].length.should == @files.length
7133610 @winton SmartAsset#binary specs
authored Nov 29, 2010
146 end
4931153 @winton More efficient system of hashes for versioning
authored Dec 21, 2010
147
8baadfa @winton Simplifying scope of project...no longer compressing every file, no l…
authored Dec 8, 2010
148 it "should create package files with content" do
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
149 @files.each_with_index do |file, i|
8baadfa @winton Simplifying scope of project...no longer compressing every file, no l…
authored Dec 8, 2010
150 File.size(path = "#{@dest}/#{@versions[i]}_#{file}").should > 0
151 if i == 0
152 css = File.read(path)
6484adb @winton Don't sort timestamps so changes in order will force repackage
authored Dec 21, 2010
153 css.index('.error').should < css.index('.container_12')
8baadfa @winton Simplifying scope of project...no longer compressing every file, no l…
authored Dec 8, 2010
154 css.include?('.error').should == true
6484adb @winton Don't sort timestamps so changes in order will force repackage
authored Dec 21, 2010
155 css.include?('.container_12').should == true
8baadfa @winton Simplifying scope of project...no longer compressing every file, no l…
authored Dec 8, 2010
156 else
157 js = File.read(path)
6484adb @winton Don't sort timestamps so changes in order will force repackage
authored Dec 21, 2010
158 js.index('jQuery').should < js.index('VERSION')
8baadfa @winton Simplifying scope of project...no longer compressing every file, no l…
authored Dec 8, 2010
159 js.include?('jQuery').should == true
160 js.include?('VERSION').should == true
161 end
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
162 end
163 end
164
4931153 @winton More efficient system of hashes for versioning
authored Dec 21, 2010
165 it "should remove old version" do
166 Dir["#{@dest}/*.css"].length.should == 1
167 end
168
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
169 unless ENV['FAST']
170 it "should run updated file through the compressor" do
8baadfa @winton Simplifying scope of project...no longer compressing every file, no l…
authored Dec 8, 2010
171 @files.each_with_index do |file, i|
172 @output.string.include?(file).should == (i == 0 ? true : false)
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
173 end
174 end
7133610 @winton SmartAsset#binary specs
authored Nov 29, 2010
175 end
176 end
bb6d665 @winton Updating packages when config changes, deleting old packages when rem…
authored Dec 10, 2010
177
178 unless ENV['FAST']
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
179 describe 'package changed' do
180
bb6d665 @winton Updating packages when config changes, deleting old packages when rem…
authored Dec 10, 2010
181 before(:all) do
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
182 @package_config = SmartAsset.config['javascripts']['package']
bb6d665 @winton Updating packages when config changes, deleting old packages when rem…
authored Dec 10, 2010
183 @old_package_path = "#{@dest}/#{@versions[1]}_#{@files[1]}"
184 @old_package = File.read(@old_package_path)
185 end
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
186
bb6d665 @winton Updating packages when config changes, deleting old packages when rem…
authored Dec 10, 2010
187 after(:all) do
188 File.open(@old_package_path, 'w') { |f| f.write(@old_package) }
189 end
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
190
191 after(:each) do
192 SmartAsset.config['javascripts']['package'] = @package_config
193 end
194
6484adb @winton Don't sort timestamps so changes in order will force repackage
authored Dec 21, 2010
195 describe 'package order changed' do
196
197 before(:all) do
198 SmartAsset.config['javascripts']['package'].delete 'underscore'
199 SmartAsset.config['javascripts']['package'].unshift 'underscore'
200 @output = capture_stdout do
201 SmartAsset.compress 'javascripts'
202 end
203 end
204
205 it "should rewrite javascript package with underscore code first" do
206 File.size(path = "#{@dest}/91d1e5c5_#{@files[1]}").should > 0
207 js = File.read(path)
208 js.index('jQuery').should > js.index('VERSION')
209 js.include?('jQuery').should == true
210 js.include?('VERSION').should == true
211 end
212
213 it "should run updated file through the compressor" do
214 @files.each_with_index do |file, i|
215 @output.string.include?(file).should == (i == 1 ? true : false)
216 end
217 end
218
219 it "should remove old version" do
220 Dir["#{@dest}/*.js"].length.should == 1
221 end
222 end
223
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
224 describe 'package child removed' do
bb6d665 @winton Updating packages when config changes, deleting old packages when rem…
authored Dec 10, 2010
225
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
226 before(:all) do
227 SmartAsset.config['javascripts']['package'].delete 'underscore'
228 @output = capture_stdout do
229 SmartAsset.compress 'javascripts'
bb6d665 @winton Updating packages when config changes, deleting old packages when rem…
authored Dec 10, 2010
230 end
231 end
232
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
233 it "should rewrite javascript package with only jquery" do
4931153 @winton More efficient system of hashes for versioning
authored Dec 21, 2010
234 File.size(path = "#{@dest}/b00ce510_#{@files[1]}").should > 0
235 js = File.read(path)
236 js.include?('jQuery').should == true
237 js.include?('VERSION').should == false
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
238 end
239
240 it "should run updated file through the compressor" do
241 @files.each_with_index do |file, i|
242 @output.string.include?(file).should == (i == 1 ? true : false)
243 end
bb6d665 @winton Updating packages when config changes, deleting old packages when rem…
authored Dec 10, 2010
244 end
4931153 @winton More efficient system of hashes for versioning
authored Dec 21, 2010
245
246 it "should remove old version" do
247 Dir["#{@dest}/*.js"].length.should == 1
248 end
bb6d665 @winton Updating packages when config changes, deleting old packages when rem…
authored Dec 10, 2010
249 end
250
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
251 describe 'package removed' do
bb6d665 @winton Updating packages when config changes, deleting old packages when rem…
authored Dec 10, 2010
252
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
253 before(:all) do
254 SmartAsset.config['javascripts'].delete 'package'
255 @output = capture_stdout do
256 SmartAsset.compress 'javascripts'
257 end
bb6d665 @winton Updating packages when config changes, deleting old packages when rem…
authored Dec 10, 2010
258 end
259
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
260 it "should delete the javascript package" do
4931153 @winton More efficient system of hashes for versioning
authored Dec 21, 2010
261 Dir["#{@dest}/*.js"].length.should == 0
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
262 end
263 end
264
265 describe 'untracked file' do
266
267 before(:all) do
4931153 @winton More efficient system of hashes for versioning
authored Dec 21, 2010
268 @modified = Time.parse('12-01-2010').utc
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
269 ENV['MODIFIED'] = @modified.to_s
6484adb @winton Don't sort timestamps so changes in order will force repackage
authored Dec 21, 2010
270 @package = "#{@dest}/0fabe271_#{@files[1]}"
4931153 @winton More efficient system of hashes for versioning
authored Dec 21, 2010
271 @untracked = "#{$root}/spec/fixtures/assets/javascripts/untracked.js"
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
272
273 File.open(@untracked, 'w') { |f| f.write("var untracked = true;") }
274 SmartAsset.config['javascripts']['package'] << 'untracked'
275
276 @output = capture_stdout do
277 SmartAsset.compress 'javascripts'
278 end
279 end
280
281 after(:all) do
282 ENV.delete 'MODIFIED'
283 FileUtils.rm @untracked
a237174 @winton Fixing framework specs, adding spec/run to run all specs at once, upd…
authored Dec 23, 2010
284 FileUtils.rm @package
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
285 end
286
287 it "should create package with default modified time" do
4931153 @winton More efficient system of hashes for versioning
authored Dec 21, 2010
288 File.exists?(@package).should == true
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
289 end
290
291 it "should create package with untracked file" do
4931153 @winton More efficient system of hashes for versioning
authored Dec 21, 2010
292 File.read(@package).include?('var untracked').should == true
293 end
294
295 it "should remove old version" do
296 Dir["#{@dest}/*.js"].length.should == 1
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
297 end
bb6d665 @winton Updating packages when config changes, deleting old packages when rem…
authored Dec 10, 2010
298 end
299 end
300 end
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
301 end
302
303 describe :path do
7133610 @winton SmartAsset#binary specs
authored Nov 29, 2010
304
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
305 describe "development" do
306
307 before(:all) do
308 SmartAsset.env = 'development'
d19b2b2 @winton Adding append_random option, fixing specs
authored Dec 9, 2010
309 SmartAsset.load_config($root, @config)
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
310 end
311
312 it "should return development paths" do
313 SmartAsset.paths('javascripts', :package).should == [
314 "/javascripts/jquery/jquery.js",
315 "/javascripts/underscore.js"
316 ]
317 SmartAsset.paths('stylesheets', :package).should == [
318 "/stylesheets/blueprint/blueprint.css",
319 "/stylesheets/960.css"
320 ]
321 end
322
323 it "should leave @cache empty" do
324 SmartAsset.cache.should == {"javascripts"=>{}, "stylesheets"=>{}}
7133610 @winton SmartAsset#binary specs
authored Nov 29, 2010
325 end
326 end
327
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
328 describe "production" do
329
330 before(:all) do
331 SmartAsset.env = 'production'
7133610 @winton SmartAsset#binary specs
authored Nov 29, 2010
332 end
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
333
334 it "should return compressed paths" do
335 SmartAsset.paths('javascripts', :package).should == [
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
336 "/compressed/#{@versions[1]}_#{@files[1]}"
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
337 ]
338 SmartAsset.paths('stylesheets', :package).should == [
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
339 "/compressed/#{@versions[0]}_#{@files[0]}"
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
340 ]
7133610 @winton SmartAsset#binary specs
authored Nov 29, 2010
341 end
342
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
343 it "should populate @cache" do
344 SmartAsset.cache.should == {"javascripts"=>
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
345 {"package"=>["/compressed/#{@versions[1]}_#{@files[1]}"]},
1db5510 @winton Specs passing for Rails 2, Rails 3, Sinatra 1
authored Dec 1, 2010
346 "stylesheets"=>
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
347 {"package"=>["/compressed/#{@versions[0]}_#{@files[0]}"]}}
26a5146 @winton Fixing asset_host numbering, adding asset_host_count config option
authored Dec 7, 2010
348 end
349 end
350 end
351
352 describe :helper do
353 describe "production" do
354
355 before(:all) do
356 SmartAsset.env = 'production'
357 SmartAsset.asset_counter = nil
d19b2b2 @winton Adding append_random option, fixing specs
authored Dec 9, 2010
358 SmartAsset.load_config($root, @config)
26a5146 @winton Fixing asset_host numbering, adding asset_host_count config option
authored Dec 7, 2010
359 end
360
361 before(:each) do
362 SmartAsset.cache = nil
363 end
364
365 it "should output correct script tags" do
8baadfa @winton Simplifying scope of project...no longer compressing every file, no l…
authored Dec 8, 2010
366 javascript_include_merged(:package, :unknown).split("\n").should == [
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
367 "<script src=\"http://assets0.host.com/compressed/#{@versions[1]}_#{@files[1]}\"></script>"
26a5146 @winton Fixing asset_host numbering, adding asset_host_count config option
authored Dec 7, 2010
368 ]
369 end
370
371 it "should output correct style tags" do
8baadfa @winton Simplifying scope of project...no longer compressing every file, no l…
authored Dec 8, 2010
372 stylesheet_link_merged(:package, :unknown).split("\n").should == [
a00caff @winton Adding MODIFIED env variable to set default modified time for untrack…
authored Dec 13, 2010
373 "<link href=\"http://assets1.host.com/compressed/#{@versions[0]}_#{@files[0]}\" media=\"screen\" rel=\"stylesheet\" />"
26a5146 @winton Fixing asset_host numbering, adding asset_host_count config option
authored Dec 7, 2010
374 ]
375 end
376 end
377
378 describe "development" do
379
380 before(:all) do
381 SmartAsset.env = 'development'
d19b2b2 @winton Adding append_random option, fixing specs
authored Dec 9, 2010
382 SmartAsset.load_config($root, @config)
26a5146 @winton Fixing asset_host numbering, adding asset_host_count config option
authored Dec 7, 2010
383 end
384
385 before(:each) do
386 SmartAsset.cache = nil
387 end
388
389 it "should output correct script tags for a package" do
d19b2b2 @winton Adding append_random option, fixing specs
authored Dec 9, 2010
390 js = javascript_include_merged(:package, :unknown).split("\n")
391 js[0].should =~ /<script src="\/javascripts\/jquery\/jquery\.js\?\d+"><\/script>/
392 js[1].should =~ /<script src="\/javascripts\/underscore\.js\?\d+"><\/script>/
26a5146 @winton Fixing asset_host numbering, adding asset_host_count config option
authored Dec 7, 2010
393 end
394
395 it "should output correct style tags" do
d19b2b2 @winton Adding append_random option, fixing specs
authored Dec 9, 2010
396 css = stylesheet_link_merged(:package, :unknown, :media => 'print').split("\n")
397 css[0].should =~ /<link href="\/stylesheets\/blueprint\/blueprint\.css\?\d+" media="print" rel="stylesheet" \/>/
398 css[1].should =~ /<link href="\/stylesheets\/960\.css\?\d+" media="print" rel="stylesheet" \/>/
7133610 @winton SmartAsset#binary specs
authored Nov 29, 2010
399 end
400 end
7355d60 @winton First commit (smart_asset)
authored Nov 28, 2010
401 end
402 end
403 end
Something went wrong with that request. Please try again.