This repository has been archived by the owner on Jun 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
pipeline_spec.rb
259 lines (190 loc) · 7.77 KB
/
pipeline_spec.rb
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
require "spec_helper"
describe BPM::Pipeline, "asset_path" do
before do
goto_home
set_host
start_fake(FakeGemServer.new)
FileUtils.cp_r(project_fixture('hello_world'), '.')
cd home('hello_world')
end
subject do
project = BPM::Project.new home('hello_world')
BPM::Pipeline.new project
end
it "should find any asset in the assets directory" do
bpm 'rebuild', '--update' and wait
asset = subject.find_asset 'papa-smurf.jpg'
asset.pathname.should == home('hello_world', 'assets', 'papa-smurf.jpg')
end
it "should find any asset in packages" do
bpm 'fetch' and wait
bpm 'add', 'custom_package' and wait
asset = subject.find_asset 'custom_package/assets/dummy.txt'
asset.pathname.should == home('hello_world', 'vendor', 'custom_package', 'assets', 'dummy.txt')
end
it "should find any asset in installed packages" do
bpm 'fetch' and wait
bpm 'rebuild' and wait
asset = subject.find_asset 'core-test/resources/runner.css'
asset.pathname.should == home('.bpm', 'gems', 'core-test-0.4.9', 'resources', 'runner.css')
end
describe "generated assets" do
before do
bpm 'fetch' and wait
bpm 'add', 'custom_package' and wait
@project = BPM::Project.new home('hello_world')
end
describe "bpm_libs.js" do
subject do
BPM::Pipeline.new(@project).find_asset 'bpm_libs.js'
end
it "should return an asset of type BPM::GeneratedAsset" do
subject.class.should == BPM::GeneratedAsset
end
it "should find the bpm_libs.js" do
subject.pathname.should == home('hello_world', 'assets', 'bpm_libs.js')
end
it "should find bpm_libs as well" do
BPM::Pipeline.new(@project).find_asset('bpm_libs').should == subject
end
it "should have a manifest line" do
# Right now we're including dev deps
subject.to_s.should include('MANIFEST: core-test (0.4.9) custom_generator (1.0) custom_package (2.0.0) ivory (0.0.1) jquery (1.4.3) optparse (1.0.1) rake (0.8.6) spade (0.5.0)')
end
it "should include any required modules in the bpm_package.js" do
subject.to_s.should include(File.read(home('hello_world', 'vendor', 'custom_package', 'lib', 'main.js')))
end
it "should reference package.json directories when resolving modules" do
subject.to_s.should include(File.read(home('hello_world', 'vendor', 'custom_package', 'custom_dir', 'basic-module.js')))
end
end
describe "bpm_styles.css" do
subject do
BPM::Pipeline.new(@project).find_asset 'bpm_styles.css'
end
it "should find bpm_styles.css" do
subject.pathname.should == home('hello_world', 'assets', 'bpm_styles.css')
end
it "should include any required modules in the bpm_styles.css" do
subject.to_s.should include(File.read(home('hello_world', 'vendor', 'custom_package', 'css', 'sample_styles.css')))
end
it "should reference installed package styles as well" do
subject.to_s.should include(File.read(home('.bpm', 'gems', 'core-test-0.4.9', 'resources', 'runner.css')))
end
end
describe "hello_world/bpm_libs.js" do
subject do
BPM::Pipeline.new(@project).find_asset 'hello_world/bpm_libs.js'
end
it "should return an asset of type BPM::GeneratedAsset" do
subject.class.should == BPM::GeneratedAsset
end
it "should find the bpm_libs.js" do
subject.pathname.should == home('hello_world', 'assets', 'hello_world', 'bpm_libs.js')
end
it "should find bpm_libs as well" do
BPM::Pipeline.new(@project).find_asset('hello_world/bpm_libs').should == subject
end
it "should have a manifest line" do
subject.to_s.should include('MANIFEST: hello_world (2.0.0)')
end
it "should include any required modules in the bpm_libs" do
subject.to_s.should include(File.read(home('hello_world', 'lib', 'main.js')))
end
end
describe "hello_world/bpm_styles.css" do
before do
FileUtils.mkdir_p home('hello_world', 'assets', 'hello_world')
FileUtils.touch home('hello_world', 'assets', 'hello_world', 'bpm_styles.css')
end
subject do
BPM::Pipeline.new(@project).find_asset 'hello_world/bpm_styles.css'
end
it "should return an asset of type BPM::GeneratedAsset" do
subject.class.should == BPM::GeneratedAsset
end
it "should find the app_styles.css" do
subject.pathname.should == home('hello_world', 'assets', 'hello_world', 'bpm_styles.css')
end
it "should find bpm_styles as well" do
BPM::Pipeline.new(@project).find_asset('hello_world/bpm_styles').should == subject
end
it "should have a manifest line" do
subject.to_s.should include('MANIFEST: hello_world (2.0.0)')
end
it "should include any required modules in the bpm_styles" do
subject.to_s.should include(File.read(home('hello_world', 'css', 'dummy.css')))
end
end
describe "hello_world/app_tests.js" do
before do
FileUtils.mkdir_p home('hello_world', 'assets', 'hello_world')
FileUtils.touch home('hello_world', 'assets', 'hello_world', 'app_tests.js')
end
subject do
BPM::Pipeline.new(@project).find_asset 'hello_world/bpm_tests.js'
end
it "should return an asset of type BPM::GeneratedAsset" do
subject.class.should == BPM::GeneratedAsset
end
it "should find the app_tests.js" do
subject.pathname.should == home('hello_world', 'assets', 'hello_world', 'bpm_tests.js')
end
it "should find app_tests as well" do
BPM::Pipeline.new(@project).find_asset('hello_world/bpm_tests').should == subject
end
it "should have a manifest line" do
subject.to_s.should include('MANIFEST: hello_world (2.0.0)')
end
it "should include any required modules in the bpm_tests" do
subject.to_s.should include(File.read(home('hello_world', 'tests', 'main-test.js')))
end
end
end
end
describe BPM::Pipeline, "buildable_assets" do
before do
set_host
goto_home
FileUtils.cp_r(project_fixture('hello_world'), '.')
reset_libgems bpm_dir.to_s
start_fake(FakeGemServer.new)
cd home('hello_world')
bpm 'fetch' and wait
bpm 'add', 'custom_package', '--verbose' and wait
@project = BPM::Project.new home('hello_world')
end
subject do
BPM::Pipeline.new(@project).buildable_assets
end
def project(*asset_names)
Pathname.new File.join @project.root_path, *asset_names
end
def find_asset(logical_path)
subject.find { |x| x.logical_path == logical_path }
end
it "should include bpm_libs.js" do
asset = find_asset 'bpm_libs.js'
asset.should_not be_nil
asset.pathname.should == project('assets', 'bpm_libs.js')
end
it "should include bpm_styles.css" do
asset = find_asset 'bpm_styles.css'
asset.should_not be_nil
asset.pathname.should == project('assets', 'bpm_styles.css')
end
it "should include custom_package assets" do
asset = find_asset 'custom_package/assets/dummy.txt'
asset.should_not be_nil
asset.pathname.should == project('vendor', 'custom_package', 'assets', 'dummy.txt')
end
it "should include installed package assets" do
asset = find_asset 'core-test/extras/extra_file.html'
asset.should_not be_nil
asset.pathname.should == home('.bpm', 'gems', 'core-test-0.4.9', 'extras', 'extra_file.html')
end
it "should exclude libs" do
asset = find_asset 'custom_package/assets/lib/main.js'
asset.should be_nil
end
end