public
Description:
Homepage:
Clone URL: git://github.com/robertkrimen/file-assets.git
file-assets / t / 401-filter-caching.t
100644 81 lines (53 sloc) 2.01 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
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
#!perl -w
 
use strict;
 
use Test::More qw/no_plan/;
use t::Test;
my $assets = t::Test->assets(output_path => [ [ qw/* %n%-l.%e/ ] ]);
my $scratch = t::Test->scratch;
 
$assets->include("css/apple.css");
$assets->include("css/banana.css");
$assets->include("css/grape.css");
 
my $path = "static/assets.css";
ok(my $filter = $assets->filter([ "Concat" ]));
compare($assets->export, "http://example.com/$path");
 
is($scratch->read($path), <<_END_);
/* Test file: static/css/apple.css */
 
/* Test file: static/css/banana.css */
 
/* This is grape.css */
_END_
 
ok(my $mtime = $scratch->file($path)->stat->mtime);
 
sleep 2;
 
ok($assets->export);
is($scratch->file($path)->stat->mtime, $mtime, "Nothing changed, so $path should have an mtime of $mtime");
 
sleep 2;
 
$scratch->write("static/css/custom.css", <<_END_);
/* This is custom.css */
_END_
 
ok($assets->include("css/custom.css"));
ok($assets->export);
isnt($scratch->file($path)->stat->mtime, $mtime, "Included a new file, so $path should not have an mtime of $mtime");
is($scratch->read($path), <<_END_);
/* Test file: static/css/apple.css */
 
/* Test file: static/css/banana.css */
 
/* This is grape.css */
 
/* This is custom.css */
_END_
 
ok($mtime = $scratch->file($path)->stat->mtime);
 
sleep 2;
 
ok($assets->export);
is($scratch->file($path)->stat->mtime, $mtime, "Again, nothing changed, so $path should have an mtime $mtime");
 
sleep 2;
 
$scratch->write("static/css/custom.css", <<_END_);
/* This is a different custom.css */
_END_
 
ok($assets->export);
isnt($scratch->file($path)->stat->mtime, $mtime, "Changed the contents of custom.css, so $path should not have an mtime $mtime");
is($scratch->read($path), <<_END_);
/* Test file: static/css/apple.css */
 
/* Test file: static/css/banana.css */
 
/* This is grape.css */
 
/* This is a different custom.css */
_END_
 
ok($mtime = $scratch->file($path)->stat->mtime);
 
ok($assets->export);
is($scratch->file($path)->stat->mtime, $mtime, "Again, nothing changed, so $path should have an mtime $mtime");