-
Notifications
You must be signed in to change notification settings - Fork 53
/
linked_assets.feature
123 lines (100 loc) · 3.49 KB
/
linked_assets.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
Feature: Linked assets are included in the sitemap
Assets that are linked, either through a `//= link` directive or with an asset url helper (like `asset_path`) will be included in the sitemap & built automatically. The path these assets are placed at is configurable with the `:imported_asset_path` option.
Note that we're taking advantage of the fact that the `assets_gem` is included in the sprockets paths with these examples.
Scenario: Assets linked with a Sprockets directive
Given a fixture app "base-app"
And a file named "config.rb" with:
"""
activate :sprockets
"""
And a file named "source/stylesheets/manifest.js" with:
"""
//= link logo.png
"""
And the Server is running
When I go to "/assets/logo.png"
Then the status code should be "200"
Scenario: Assets linked using a path helper
Given a fixture app "base-app"
And a file named "config.rb" with:
"""
activate :sprockets
"""
And a file named "source/stylesheets/site.css.scss" with:
"""
@import 'import';
"""
And a file named "source/stylesheets/_import.scss" with:
"""
body {
background: image-url('logo.png');
}
"""
And the Server is running
When I go to "/assets/logo.png"
Then the status code should be "200"
When I go to "/stylesheets/site.css"
Then I should see "url(/assets/logo.png)"
Scenario: Linked asset destination is configurable
Given a fixture app "base-app"
And a file named "config.rb" with:
"""
activate :sprockets do |c|
c.imported_asset_path = 'linked'
end
"""
And a file named "source/javascripts/manifest.js" with:
"""
//= link logo.png
"""
And the Server is running
When I go to "/linked/logo.png"
Then the status code should be "200"
Scenario: Linked assets can be rendered
Given a fixture app "base-app"
And a file named "config.rb" with:
"""
activate :sprockets
"""
And a file named "vendor/css/vendored.css.sass" with:
"""
body
color: red
"""
And a file named "vendor/js/vendored.js.coffee" with:
"""
console.log 'hello'
"""
And a file named "source/javascripts/manifest.js" with:
"""
//= link 'vendored.css'
//= link 'vendored.js'
"""
And the Server is running
When I go to "/assets/vendored.css"
Then I should see "color: red;"
When I go to "/assets/vendored.js"
Then I should see "console.log('hello')"
Scenario: Linking to Sprockets assets from Middleman
You can do this, but you need to make sure that the asset is imported into the sitemap. If the asset is linked via a Sprockets directive or path helper no worries -- otherwise you could create a manifest file that contains links to assets you need.
In this test case, remember the `assets_gem` is available.
Given a fixture app "base-app"
And a file named "config.rb" with:
"""
activate :sprockets
"""
And a file named "source/index.html.erb" with:
"""
<%= image_tag('assets/logo.png') %>
"""
And the Server is running
When I go to "/assets/logo.png"
Then the status code should be "404"
And the file "source/javascripts/manifest.js" has the contents
"""
//= link 'logo.png'
"""
When I go to "/assets/logo.png"
Then the status code should be "200"
When I go to "/"
Then I should see '<img src="/assets/logo.png"'