-
Notifications
You must be signed in to change notification settings - Fork 53
/
bower.feature
102 lines (81 loc) · 3.06 KB
/
bower.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
Feature: Using assets installed via Bower
Usage with Bower is fairly barebones -- for now we don't do anything fancy to detect which files to link by reading bower.json files. A typical workflow looks something like this:
- create your `ROOT/bower.json` & install via bower to `ROOT/bower_components`
- append `bower_components` to sprockets paths
- either require assets for use, or create a `manifest.js` that links files
Background:
Given a fixture app "base-app"
And a file named "config.rb" with:
"""
activate :sprockets
sprockets.append_path File.join(root, "bower_components")
"""
And a file named "bower_components/underscore/underscore.js" with:
"""
var _ = {};
return _;
"""
And a file named "source/javascripts/application.js" with:
"""
//= require underscore/underscore
"""
Scenario: Sprockets can require underscore from bower
Given the Server is running
Then sprockets paths should include "bower_components"
When I go to "/javascripts/application.js"
Then I should see "return _;"
Scenario: Sprockets can build when requiring underscore from bower
And a successfully built app
When I cd to "build"
Then the following files should exist:
| javascripts/application.js |
And the file "javascripts/application.js" should contain "return _;"
Scenario: Assets can be added to the sitemap by linking them in a manifest
Given a file named "source/javascripts/manifest.js" with:
"""
//= link underscore/underscore
"""
And the Server is running
When I go to "/assets/underscore/underscore.js"
Then I should see "return _;"
Scenario: Assets which haven't been linked aren't added to the sitemap
Given a file named "bower_components/underscore/hello.js" with:
"""
console.log('hello');
"""
And the Server is running
When I go to "/assets/underscore/hello.js"
Then the status code should be "404"
Scenario: Assets have an individual output directory
Given a file named "vendor/assets/lightbox2/hello.js" with:
"""
console.log('hello');
"""
And a file named "config.rb" with:
"""
activate :sprockets
sprockets.append_path File.join(root, "bower_components")
sprockets.append_path File.join(root, "vendor/assets")
"""
And a file named "source/javascripts/manifest.js" with:
"""
//= link underscore/underscore
//= link lightbox2/hello
"""
And the Server is running
When I go to "/assets/underscore/underscore.js"
Then I should see "return _;"
When I go to "/assets/lightbox2/hello.js"
Then I should see "console.log('hello');"
Scenario: Sprockets should not mess with bower.json if it's in source
Given a file named "source/javascripts/bower.json" with:
"""
{
"name": "my-project",
"version": "1.0.0",
"main": "application.js"
}
"""
And the Server is running
When I go to "/javascripts/bower.json"
Then I should see '"name": "my-project",'