-
Notifications
You must be signed in to change notification settings - Fork 197
Expand file tree
/
Copy pathcommand_line_test.rb
More file actions
35 lines (29 loc) · 1.4 KB
/
command_line_test.rb
File metadata and controls
35 lines (29 loc) · 1.4 KB
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
require 'test_helper'
require 'zlib'
class CommandLineTest < MiniTest::Test
def teardown
begin
FileUtils.rm_r('test/precache')
rescue Errno::ENOENT
end
end
def test_version_and_help_can_run
assert system('bin/jammit -v') && system('bin/jammit -h')
end
def test_jammit_precaching
system('bin/jammit -c test/config/assets.yml -o test/precache -u http://www.example.com')
assert PRECACHED_FILES == glob('test/precache/*')
assert Zlib::GzipReader.open('test/precache/css_test-datauri.css.gz') {|f| f.read } == File.read('test/fixtures/jammed/css_test-datauri.css')
assert Zlib::GzipReader.open('test/precache/jst_test.js.gz') {|f| f.read } == File.read('test/fixtures/jammed/jst_test.js')
assert Zlib::GzipReader.open('test/precache/js_test_with_templates.js.gz') {|f| f.read } == File.read('test/fixtures/jammed/js_test_with_templates.js')
end
def test_lazy_precaching
system('bin/jammit -c test/config/assets.yml -o test/precache -u http://www.example.com')
assert PRECACHED_FILES == glob('test/precache/*')
mtime = File.mtime(PRECACHED_FILES.first)
system('bin/jammit -c test/config/assets.yml -o test/precache -u http://www.example.com')
assert File.mtime(PRECACHED_FILES.first) == mtime
system('bin/jammit -c test/config/assets.yml -o test/precache -u http://www.example.com --force')
assert File.mtime(PRECACHED_FILES.first) > mtime
end
end