This repository has been archived by the owner on Jun 13, 2022. It is now read-only.
/
minifier_spec.rb
73 lines (57 loc) · 1.82 KB
/
minifier_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, 'minifier' do
before do
goto_home
set_host
reset_libgems bpm_dir.to_s
start_fake(FakeGemServer.new)
FileUtils.cp_r project_fixture('minitest'), '.'
cd home('minitest')
bpm 'rebuild'
wait
end
subject do
project = BPM::Project.new home('minitest')
BPM::Pipeline.new project, :production
end
it "should wrap bpm_libs.js" do
asset = subject.find_asset 'bpm_libs.js'
expected = <<EOF
/* ===========================================================================
BPM Combined Asset File
MANIFEST: (none)
This file is generated automatically by the bpm (http://www.bpmjs.org)
=========================================================================*/
//MINIFIED START
UGLY DUCK IS UGLYboston
//MINIFIED END
EOF
asset.to_s.should == expected
end
it "should wrap app_package.js" do
asset = subject.find_asset 'minitest/bpm_libs.js'
file_path = home('minitest', 'lib', 'main.js')
expected = <<EOF
/* ===========================================================================
BPM Combined Asset File
MANIFEST: minitest (2.0.0)
This file is generated automatically by the bpm (http://www.bpmjs.org)
=========================================================================*/
//MINIFIED START
UGLY DUCK IS UGLYsanfran
#{File.read(file_path)}
//MINIFIED END
EOF
asset.to_s.should == expected
end
subject do
project = BPM::Project.new home('minitest')
BPM::Pipeline.new project, :production
end
it "should not wrap bpm_libs.js in debug mode" do
project = BPM::Project.new home('minitest')
pipeline = BPM::Pipeline.new project, :debug
asset = pipeline.find_asset 'minitest/app_package.js'
asset.to_s.should_not include('//MINIFIED START')
end
end