-
Notifications
You must be signed in to change notification settings - Fork 53
/
imported_asset_processor.feature
89 lines (79 loc) · 2.81 KB
/
imported_asset_processor.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Feature: Imported assets can be placed in paths determined by a processor
Background:
Given a fixture app "base-app"
And a file named "config.rb" with:
"""
config[:images_dir] = "images"
config[:fonts_dir] = "fonts"
class ImportedAssetPathProcessor
attr_reader :app
def initialize(app)
@app = app
end
def call(sprockets_asset)
directory = case sprockets_asset.logical_path
when /^images\// then app.config[:images_dir]
when /^fonts\// then app.config[:fonts_dir]
else
"imported"
end
relative_path = sprockets_asset.logical_path.sub(/^#{directory}/, '')
File.join(directory, relative_path)
end
end
activate :sprockets do |config|
config.imported_asset_path = ImportedAssetPathProcessor.new(app)
end
sprockets.append_path File.join(root, 'vendor')
"""
And a file named "vendor/fonts/webfont-vendor.eot" with:
"""
"""
And a file named "vendor/images/vendor-image.jpg" with:
"""
"""
And a file named "vendor/foo/bar.jpg" with:
"""
"""
And a file named "source/fonts/webfont-source.eot" with:
"""
"""
And a file named "source/images/source-image.jpg" with:
"""
"""
Scenario: Assets built by being linked (fully resolved) are built in the custom path
Given a file named "source/stylesheets/manifest.css" with:
"""
//= link 'webfont-vendor.eot'
//= link 'vendor-image.jpg'
//= link 'foo/bar.jpg'
"""
And the Server is running
When I go to "/fonts/webfont-vendor.eot"
Then the status code should be "200"
When I go to "/fonts/webfont-source.eot"
Then the status code should be "200"
When I go to "/images/vendor-image.jpg"
Then the status code should be "200"
When I go to "/images/source-image.jpg"
Then the status code should be "200"
When I go to "/imported/foo/bar.jpg"
Then the status code should be "200"
Scenario: Assets built by being linked (minimally resolved) are built in the custom path
Given a file named "source/stylesheets/manifest.css" with:
"""
//= link 'fonts/webfont-vendor.eot'
//= link 'images/vendor-image.jpg'
//= link 'foo/bar.jpg'
"""
And the Server is running
When I go to "/fonts/webfont-vendor.eot"
Then the status code should be "200"
When I go to "/fonts/webfont-source.eot"
Then the status code should be "200"
When I go to "/images/vendor-image.jpg"
Then the status code should be "200"
When I go to "/images/source-image.jpg"
Then the status code should be "200"
When I go to "/imported/foo/bar.jpg"
Then the status code should be "200"