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
/
transport_spec.rb
73 lines (57 loc) · 1.63 KB
/
transport_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
require "spec_helper"
describe BPM::Pipeline, 'transport processor' do
before do
goto_home
set_host
reset_libgems bpm_dir.to_s
start_fake(FakeGemServer.new)
FileUtils.cp_r project_fixture('transporter'), '.'
cd home('transporter')
bpm 'rebuild'
wait
end
subject do
project = BPM::Project.new home('transporter')
BPM::Pipeline.new project
end
it "should wrap the project's main.js" do
asset = subject.find_asset 'transporter/lib/main.js'
exp_path = home('transporter', 'lib', 'main.js')
asset.to_s.should == "define_transport(function() {\n//TRANSPORT\ntransporter();\n//TRANSPORT\n\n}), 'transporter', 'main', '#{exp_path}');"
asset.pathname.to_s.should == File.join(Dir.pwd, 'lib', 'main.js')
end
it "should not wrap transport/main.js" do
asset = subject.find_asset 'transport/lib/main.js'
asset.to_s.should == "// TRANSPORT DEMO\n"
end
end
describe BPM::Pipeline, 'transport processor w/ minifier' do
before do
goto_home
set_host
reset_libgems bpm_dir.to_s
start_fake(FakeGemServer.new)
FileUtils.cp_r project_fixture('minitrans'), '.'
cd home('minitrans')
bpm 'rebuild'
wait
end
subject do
project = BPM::Project.new home('minitrans')
BPM::Pipeline.new project
end
it "should invoke minifier in project" do
asset = subject.find_asset 'bpm_libs.js'
exp_path = home('transporter', 'lib', 'main.js')
expected = <<EOF
(function() { //MINIFIED START
UGLY DUCK IS UGLY
//TRANSPORT
transporter();
//TRANSPORT
//MINIFIED END
})()
EOF
asset.to_s.should include(expected.to_json)
end
end