dassets 0.14.2 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -7
- data/Gemfile +5 -1
- data/README.md +15 -17
- data/dassets.gemspec +14 -9
- data/lib/dassets.rb +51 -13
- data/lib/dassets/asset_file.rb +27 -24
- data/lib/dassets/cache.rb +27 -33
- data/lib/dassets/config.rb +55 -50
- data/lib/dassets/engine.rb +11 -23
- data/lib/dassets/file_store.rb +27 -27
- data/lib/dassets/server.rb +27 -27
- data/lib/dassets/server/request.rb +44 -41
- data/lib/dassets/server/response.rb +101 -80
- data/lib/dassets/source.rb +15 -9
- data/lib/dassets/source_file.rb +103 -82
- data/lib/dassets/source_proxy.rb +36 -20
- data/lib/dassets/version.rb +3 -1
- data/test/helper.rb +31 -25
- data/test/support/app.rb +5 -5
- data/test/support/empty/{.gitkeep → .keep} +0 -0
- data/test/support/factory.rb +3 -2
- data/test/support/{public/nested/file3-d41d8cd98f00b204e9800998ecf8427e.txt → linked_source_files/linked_file.txt} +0 -0
- data/test/support/source_files/linked +1 -0
- data/test/support/source_files/linked_file2.txt +1 -0
- data/test/system/rack_tests.rb +65 -61
- data/test/unit/asset_file_tests.rb +69 -61
- data/test/unit/cache_tests.rb +15 -34
- data/test/unit/config_tests.rb +59 -52
- data/test/unit/dassets_tests.rb +31 -24
- data/test/unit/engine_tests.rb +9 -43
- data/test/unit/file_store_tests.rb +44 -31
- data/test/unit/server/request_tests.rb +57 -59
- data/test/unit/server/response_tests.rb +82 -82
- data/test/unit/server_tests.rb +5 -9
- data/test/unit/source_file_tests.rb +80 -73
- data/test/unit/source_proxy_tests.rb +84 -90
- data/test/unit/source_tests.rb +66 -50
- data/tmp/.gitkeep +0 -0
- metadata +92 -72
- data/.gitignore +0 -19
- data/test/support/public/file2-9bbe1047cffbb590f59e0e5aeff46ae4.txt +0 -1
- data/test/support/public/grumpy_cat-b0d1f399a916f7a25c4c0f693c619013.jpg +0 -0
- data/test/support/public/nested/a-thing.txt-7413d18f2eba9c695a880aff67fde135.no-use +0 -4
data/test/unit/server_tests.rb
CHANGED
@@ -1,17 +1,13 @@
|
|
1
|
-
|
2
|
-
require 'dassets/server'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
3
|
+
require "assert"
|
4
|
+
require "dassets/server"
|
5
5
|
|
6
|
+
class Dassets::Server
|
6
7
|
class UnitTests < Assert::Context
|
7
8
|
desc "Dassets::Server"
|
8
|
-
|
9
|
-
@server = Dassets::Server.new('a rack app goes here')
|
10
|
-
end
|
11
|
-
subject{ @server }
|
9
|
+
subject{ Dassets::Server.new("test rack app") }
|
12
10
|
|
13
11
|
should have_imeths :call, :call!
|
14
|
-
|
15
12
|
end
|
16
|
-
|
17
13
|
end
|
@@ -1,19 +1,20 @@
|
|
1
|
-
|
2
|
-
require 'dassets/source_file'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require 'dassets/source_proxy'
|
3
|
+
require "assert"
|
4
|
+
require "dassets/source_file"
|
7
5
|
|
8
|
-
|
6
|
+
require "dassets/asset_file"
|
7
|
+
require "dassets/cache"
|
8
|
+
require "dassets/source_proxy"
|
9
9
|
|
10
|
+
class Dassets::SourceFile
|
10
11
|
class UnitTests < Assert::Context
|
11
12
|
desc "Dassets::SourceFile"
|
13
|
+
subject{ Dassets::SourceFile.new(@file_path) }
|
14
|
+
|
12
15
|
setup do
|
13
|
-
@file_path = TEST_SUPPORT_PATH.join(
|
14
|
-
@source_file = Dassets::SourceFile.new(@file_path)
|
16
|
+
@file_path = TEST_SUPPORT_PATH.join("app/assets/file1.txt").to_s
|
15
17
|
end
|
16
|
-
subject{ @source_file }
|
17
18
|
|
18
19
|
should have_readers :file_path
|
19
20
|
should have_imeths :source, :asset_file, :digest_path
|
@@ -21,74 +22,98 @@ class Dassets::SourceFile
|
|
21
22
|
should have_cmeth :find_by_digest_path
|
22
23
|
|
23
24
|
should "know its file path" do
|
24
|
-
|
25
|
+
assert_that(subject.file_path).equals(@file_path.to_s)
|
25
26
|
end
|
26
27
|
|
27
28
|
should "know its configured source" do
|
28
|
-
exp_source =
|
29
|
-
|
29
|
+
exp_source =
|
30
|
+
Dassets.config.sources.select{ |s| @file_path.include?(s.path) }.last
|
31
|
+
assert_that(subject.source).equals(exp_source)
|
30
32
|
end
|
31
33
|
|
32
34
|
should "know its asset file" do
|
33
|
-
|
34
|
-
|
35
|
+
assert_that(subject.asset_file).is_kind_of(Dassets::AssetFile)
|
36
|
+
assert_that(subject.asset_file)
|
37
|
+
.equals(Dassets::AssetFile.new(subject.digest_path))
|
35
38
|
end
|
36
39
|
|
37
40
|
should "know its digest path" do
|
38
|
-
|
41
|
+
assert_that(subject.digest_path).equals("file1.txt")
|
39
42
|
end
|
40
43
|
|
41
44
|
should "not memoize its compiled source" do
|
42
45
|
compiled1 = subject.compiled
|
43
46
|
compiled2 = subject.compiled
|
44
|
-
|
47
|
+
assert_that(compiled2).is_not(compiled1)
|
45
48
|
end
|
46
49
|
|
47
50
|
should "know if it exists" do
|
48
|
-
|
51
|
+
assert_that(subject.exists?).is_true
|
49
52
|
end
|
50
53
|
|
51
54
|
should "use the mtime of its file as its mtime" do
|
52
|
-
|
55
|
+
assert_that(subject.mtime).equals(File.mtime(subject.file_path))
|
53
56
|
end
|
54
57
|
|
55
58
|
should "use the response headers of its source as its response headers" do
|
56
|
-
|
59
|
+
assert_that(subject.response_headers).is(subject.source.response_headers)
|
57
60
|
end
|
58
61
|
|
59
62
|
should "be findable by its digest path" do
|
60
63
|
found = Dassets::SourceFile.find_by_digest_path(subject.digest_path)
|
61
64
|
|
62
|
-
|
63
|
-
|
65
|
+
assert_that(found).equals(subject)
|
66
|
+
assert_that(found).is_not(subject)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class EngineTests < UnitTests
|
71
|
+
desc "compiled against engines"
|
72
|
+
|
73
|
+
setup do
|
74
|
+
@file_path =
|
75
|
+
TEST_SUPPORT_PATH.join("app/assets/nested/a-thing.txt.useless.dumb")
|
64
76
|
end
|
65
77
|
|
78
|
+
should "build the digest path appropriately" do
|
79
|
+
assert_that(subject.digest_path).equals("nested/a-thing.txt.no-use")
|
80
|
+
end
|
81
|
+
|
82
|
+
should "compile the source content appropriately" do
|
83
|
+
file_content = File.read(@file_path)
|
84
|
+
exp_compiled_content = [file_content, "DUMB", "USELESS"].join("\n")
|
85
|
+
assert_that(subject.compiled).equals(exp_compiled_content)
|
86
|
+
end
|
66
87
|
end
|
88
|
+
end
|
67
89
|
|
68
|
-
|
90
|
+
class Dassets::NullSourceFile
|
91
|
+
class UnitTests < Assert::Context
|
69
92
|
setup do
|
70
|
-
Dassets.config.combination
|
93
|
+
Dassets.config.combination "file3.txt", ["file1.txt", "file2.txt"]
|
71
94
|
end
|
95
|
+
|
72
96
|
teardown do
|
73
|
-
Dassets.config.combinations.delete(
|
97
|
+
Dassets.config.combinations.delete("file3.txt")
|
74
98
|
end
|
75
99
|
|
76
100
|
should "find a null src file if finding by an unknown digest path" do
|
77
|
-
null_src = Dassets::NullSourceFile.new(
|
78
|
-
found = Dassets::SourceFile.find_by_digest_path(
|
101
|
+
null_src = Dassets::NullSourceFile.new("not/found/digest/path")
|
102
|
+
found = Dassets::SourceFile.find_by_digest_path("not/found/digest/path")
|
79
103
|
|
80
|
-
|
81
|
-
|
104
|
+
assert_that(found).equals(null_src)
|
105
|
+
assert_that(found).is_not(null_src)
|
82
106
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
107
|
+
assert_that(null_src.file_path).equals("")
|
108
|
+
assert_that(null_src.exists?).equals(false)
|
109
|
+
assert_that(null_src.compiled).is_nil
|
110
|
+
assert_that(null_src.mtime).is_nil
|
111
|
+
assert_that(null_src.response_headers).equals({})
|
88
112
|
end
|
89
113
|
|
90
|
-
should "pass options to a null src when finding by an unknown digest
|
91
|
-
|
114
|
+
should "pass options to a null src when finding by an unknown digest "\
|
115
|
+
"path" do
|
116
|
+
null_src = Dassets::NullSourceFile.new("not/found/digest/path")
|
92
117
|
null_src_new_called_with = []
|
93
118
|
Assert.stub(Dassets::NullSourceFile, :new) do |*args|
|
94
119
|
null_src_new_called_with = args
|
@@ -96,26 +121,29 @@ class Dassets::SourceFile
|
|
96
121
|
end
|
97
122
|
|
98
123
|
options = {
|
99
|
-
:
|
100
|
-
:
|
124
|
+
content_cache: Dassets::NoCache.new,
|
125
|
+
fingerprint_cache: Dassets::NoCache.new,
|
101
126
|
}
|
102
|
-
Dassets::SourceFile.find_by_digest_path(
|
127
|
+
Dassets::SourceFile.find_by_digest_path(
|
128
|
+
"not/found/digest/path",
|
129
|
+
**options,
|
130
|
+
)
|
103
131
|
|
104
|
-
exp = [
|
105
|
-
|
132
|
+
exp = ["not/found/digest/path", options]
|
133
|
+
assert_that(null_src_new_called_with).equals(exp)
|
106
134
|
end
|
107
135
|
|
108
|
-
should "
|
109
|
-
src_proxy = Dassets::SourceProxy.new(
|
110
|
-
null_combo_src = Dassets::NullSourceFile.new(
|
136
|
+
should "proxy the digest path if the path is a combination" do
|
137
|
+
src_proxy = Dassets::SourceProxy.new("file3.txt")
|
138
|
+
null_combo_src = Dassets::NullSourceFile.new("file3.txt")
|
111
139
|
|
112
|
-
|
113
|
-
|
114
|
-
|
140
|
+
assert_that(null_combo_src.exists?).equals(src_proxy.exists?)
|
141
|
+
assert_that(null_combo_src.compiled).equals(src_proxy.content)
|
142
|
+
assert_that(null_combo_src.mtime).equals(src_proxy.mtime)
|
115
143
|
end
|
116
144
|
|
117
145
|
should "pass options to its source proxy when the path is a combination" do
|
118
|
-
src_proxy = Dassets::SourceProxy.new(
|
146
|
+
src_proxy = Dassets::SourceProxy.new("file3.txt")
|
119
147
|
src_proxy_new_called_with = []
|
120
148
|
Assert.stub(Dassets::SourceProxy, :new) do |*args|
|
121
149
|
src_proxy_new_called_with = args
|
@@ -123,34 +151,13 @@ class Dassets::SourceFile
|
|
123
151
|
end
|
124
152
|
|
125
153
|
options = {
|
126
|
-
:
|
127
|
-
:
|
154
|
+
content_cache: Dassets::NoCache.new,
|
155
|
+
fingerprint_cache: Dassets::NoCache.new,
|
128
156
|
}
|
129
|
-
Dassets::NullSourceFile.new(
|
157
|
+
Dassets::NullSourceFile.new("file3.txt", **options)
|
130
158
|
|
131
|
-
exp = [
|
132
|
-
|
159
|
+
exp = ["file3.txt", options]
|
160
|
+
assert_that(src_proxy_new_called_with).equals(exp)
|
133
161
|
end
|
134
|
-
|
135
162
|
end
|
136
|
-
|
137
|
-
class EngineTests < UnitTests
|
138
|
-
desc "compiled against engines"
|
139
|
-
setup do
|
140
|
-
@file_path = TEST_SUPPORT_PATH.join('app/assets/nested/a-thing.txt.useless.dumb')
|
141
|
-
@source_file = Dassets::SourceFile.new(@file_path)
|
142
|
-
end
|
143
|
-
|
144
|
-
should "build the digest path appropriately" do
|
145
|
-
assert_equal 'nested/a-thing.txt.no-use', subject.digest_path
|
146
|
-
end
|
147
|
-
|
148
|
-
should "compile the source content appropriately" do
|
149
|
-
file_content = File.read(@file_path)
|
150
|
-
exp_compiled_content = [ file_content, 'DUMB', 'USELESS' ].join("\n")
|
151
|
-
assert_equal exp_compiled_content, subject.compiled
|
152
|
-
end
|
153
|
-
|
154
|
-
end
|
155
|
-
|
156
163
|
end
|
@@ -1,213 +1,207 @@
|
|
1
|
-
|
2
|
-
require 'dassets/source_proxy'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require 'dassets/source_file'
|
7
|
-
require 'dassets/source_proxy'
|
3
|
+
require "assert"
|
4
|
+
require "dassets/source_proxy"
|
8
5
|
|
9
|
-
|
6
|
+
require "digest/md5"
|
7
|
+
require "dassets/cache"
|
8
|
+
require "dassets/source_file"
|
9
|
+
require "dassets/source_proxy"
|
10
10
|
|
11
|
+
class Dassets::SourceProxy
|
11
12
|
class UnitTests < Assert::Context
|
12
13
|
desc "Dassets::SourceProxy"
|
13
|
-
|
14
|
-
@source_proxy = Dassets::SourceProxy.new(Factory.string)
|
15
|
-
end
|
16
|
-
subject{ @source_proxy }
|
14
|
+
subject{ Dassets::SourceProxy.new(Factory.string) }
|
17
15
|
|
18
16
|
should have_readers :digest_path, :content_cache, :fingerprint_cache
|
19
17
|
should have_readers :source_files
|
20
18
|
should have_imeths :key, :content, :fingerprint, :mtime, :response_headers
|
21
19
|
should have_imeths :exists?
|
22
|
-
|
23
20
|
end
|
24
21
|
|
25
22
|
class NotComboTests < UnitTests
|
26
23
|
desc "when the digest path is not a combination"
|
27
|
-
|
28
|
-
@source_proxy = Dassets::SourceProxy.new('file1.txt')
|
29
|
-
end
|
24
|
+
subject{ Dassets::SourceProxy.new("file1.txt") }
|
30
25
|
|
31
26
|
should "know its digest path" do
|
32
|
-
|
27
|
+
assert_that(subject.digest_path).equals("file1.txt")
|
33
28
|
end
|
34
29
|
|
35
30
|
should "use no cache by default" do
|
36
|
-
|
37
|
-
|
31
|
+
assert_that(subject.content_cache).is_kind_of(Dassets::NoCache)
|
32
|
+
assert_that(subject.fingerprint_cache).is_kind_of(Dassets::NoCache)
|
38
33
|
end
|
39
34
|
|
40
35
|
should "have a single source file" do
|
41
|
-
|
42
|
-
exp = Dassets::SourceFile.find_by_digest_path(
|
43
|
-
|
36
|
+
assert_that(subject.source_files.size).equals(1)
|
37
|
+
exp = Dassets::SourceFile.find_by_digest_path("file1.txt")
|
38
|
+
assert_that(subject.source_files.first).equals(exp)
|
44
39
|
end
|
45
40
|
|
46
41
|
should "use its digest path and mtime as its key" do
|
47
42
|
exp = "#{subject.digest_path} -- #{subject.mtime}"
|
48
|
-
|
43
|
+
assert_that(subject.key).equals(exp)
|
49
44
|
end
|
50
45
|
|
51
|
-
should "get its content from the compiled source of the single
|
52
|
-
|
46
|
+
should "get its content from the compiled source of the single "\
|
47
|
+
"source file" do
|
48
|
+
assert_that(subject.content).equals(subject.source_files.first.compiled)
|
53
49
|
end
|
54
50
|
|
55
51
|
should "get its fingerprint by MD5 hashing the content" do
|
56
52
|
exp = Digest::MD5.new.hexdigest(subject.content)
|
57
|
-
|
53
|
+
assert_that(subject.fingerprint).equals(exp)
|
58
54
|
end
|
59
55
|
|
60
56
|
should "use its single source file's max mtime as its mtime" do
|
61
|
-
|
57
|
+
assert_that(subject.mtime).equals(subject.source_files.first.mtime)
|
62
58
|
end
|
63
59
|
|
64
|
-
should "use its single source file's response headers as its resonse
|
65
|
-
|
60
|
+
should "use its single source file's response headers as its resonse "\
|
61
|
+
"headers" do
|
62
|
+
assert_that(subject.response_headers)
|
63
|
+
.equals(subject.source_files.first.response_headers)
|
66
64
|
end
|
67
65
|
|
68
66
|
should "exist if its single source file exists" do
|
69
|
-
|
67
|
+
assert_that(subject.exists?).equals(subject.source_files.first.exists?)
|
70
68
|
end
|
71
|
-
|
72
69
|
end
|
73
70
|
|
74
71
|
class ComboSetupTests < UnitTests
|
75
72
|
setup do
|
76
|
-
Dassets.config.combination
|
77
|
-
Dassets.config.combination
|
78
|
-
Dassets.config.combination
|
73
|
+
Dassets.config.combination "file3.txt", ["file1.txt", "file2.txt"]
|
74
|
+
Dassets.config.combination "file4.txt", []
|
75
|
+
Dassets.config.combination "file5.txt", ["file3.txt", "file4.txt"]
|
79
76
|
end
|
77
|
+
|
80
78
|
teardown do
|
81
|
-
Dassets.config.combinations.delete(
|
82
|
-
Dassets.config.combinations.delete(
|
83
|
-
Dassets.config.combinations.delete(
|
79
|
+
Dassets.config.combinations.delete("file5.txt")
|
80
|
+
Dassets.config.combinations.delete("file4.txt")
|
81
|
+
Dassets.config.combinations.delete("file3.txt")
|
84
82
|
end
|
85
|
-
|
86
83
|
end
|
87
84
|
|
88
85
|
class ComboTests < ComboSetupTests
|
89
86
|
desc "when the digest path is a combination to multiple source files"
|
87
|
+
subject{ Dassets::SourceProxy.new("file3.txt") }
|
88
|
+
|
90
89
|
setup do
|
91
90
|
@exp_source_files = [
|
92
|
-
Dassets::SourceFile.find_by_digest_path(
|
93
|
-
Dassets::SourceFile.find_by_digest_path(
|
91
|
+
Dassets::SourceFile.find_by_digest_path("file1.txt"),
|
92
|
+
Dassets::SourceFile.find_by_digest_path("file2.txt"),
|
94
93
|
]
|
95
|
-
@source_proxy = Dassets::SourceProxy.new('file3.txt')
|
96
94
|
end
|
97
95
|
|
98
96
|
should "know its digest path" do
|
99
|
-
|
97
|
+
assert_that(subject.digest_path).equals("file3.txt")
|
100
98
|
end
|
101
99
|
|
102
100
|
should "know its source files" do
|
103
|
-
|
104
|
-
|
101
|
+
assert_that(subject.source_files.size).equals(2)
|
102
|
+
assert_that(subject.source_files).equals(@exp_source_files)
|
105
103
|
end
|
106
104
|
|
107
105
|
should "get its content from the compiled source of its source files" do
|
108
|
-
exp = subject.source_files.map
|
109
|
-
|
106
|
+
exp = subject.source_files.map(&:compiled).join("\n")
|
107
|
+
assert_that(subject.content).equals(exp)
|
110
108
|
end
|
111
109
|
|
112
110
|
should "use its source files' max mtime as its mtime" do
|
113
|
-
exp = subject.source_files.map
|
114
|
-
|
111
|
+
exp = subject.source_files.map(&:mtime).max
|
112
|
+
assert_that(subject.mtime).equals(exp)
|
115
113
|
end
|
116
114
|
|
117
|
-
should "use its source files' merged response headers as its response
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
115
|
+
should "use its source files' merged response headers as its response "\
|
116
|
+
"headers" do
|
117
|
+
exp =
|
118
|
+
subject.source_files.reduce({}) do |hash, file|
|
119
|
+
hash.merge!(file.response_headers)
|
120
|
+
end
|
121
|
+
assert_that(subject.response_headers).equals(exp)
|
122
122
|
end
|
123
123
|
|
124
124
|
should "exist if its all its source files exist" do
|
125
|
-
exp = subject.source_files.
|
126
|
-
|
125
|
+
exp = subject.source_files.reduce(true){ |res, f| res && f.exists? }
|
126
|
+
assert_that(subject.exists?).equals(exp)
|
127
127
|
end
|
128
|
-
|
129
128
|
end
|
130
129
|
|
131
130
|
class EmptyComboTests < ComboSetupTests
|
132
131
|
desc "when the digest path is an empty combination"
|
133
|
-
|
134
|
-
@source_proxy = Dassets::SourceProxy.new('file4.txt')
|
135
|
-
end
|
132
|
+
subject{ Dassets::SourceProxy.new("file4.txt") }
|
136
133
|
|
137
134
|
should "not have any source files" do
|
138
|
-
|
135
|
+
assert_that(subject.source_files.size).equals(0)
|
139
136
|
end
|
140
137
|
|
141
138
|
should "have empty content" do
|
142
|
-
|
139
|
+
assert_that(subject.content).equals("")
|
143
140
|
end
|
144
141
|
|
145
142
|
should "have no mtime" do
|
146
|
-
|
143
|
+
assert_that(subject.mtime).is_nil
|
147
144
|
end
|
148
145
|
|
149
146
|
should "exist" do
|
150
|
-
|
147
|
+
assert_that(subject.exists?).is_true
|
151
148
|
end
|
152
|
-
|
153
149
|
end
|
154
150
|
|
155
151
|
class ComboWithEmptyComboTests < ComboSetupTests
|
156
|
-
desc "when the digest path is a combination that includes an empty
|
157
|
-
|
158
|
-
|
159
|
-
end
|
152
|
+
desc "when the digest path is a combination that includes an empty "\
|
153
|
+
"combination"
|
154
|
+
subject{ Dassets::SourceProxy.new("file5.txt") }
|
160
155
|
|
161
156
|
should "ignore the mtime of the empty combination" do
|
162
|
-
exp_mtime = subject.source_files.map
|
163
|
-
|
157
|
+
exp_mtime = subject.source_files.map(&:mtime).compact.max
|
158
|
+
assert_that(subject.mtime).equals(exp_mtime)
|
164
159
|
end
|
165
|
-
|
166
160
|
end
|
167
161
|
|
168
162
|
class NoCacheTests < UnitTests
|
169
163
|
desc "with a `NoCache` cache handler"
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
:
|
175
|
-
|
164
|
+
subject do
|
165
|
+
cache = Dassets::NoCache.new
|
166
|
+
Dassets::SourceProxy.new(
|
167
|
+
"file1.txt",
|
168
|
+
content_cache: cache,
|
169
|
+
fingerprint_cache: cache,
|
170
|
+
)
|
176
171
|
end
|
177
172
|
|
178
173
|
should "not cache its source content/fingerprint" do
|
179
174
|
content1 = subject.content
|
180
175
|
content2 = subject.content
|
181
|
-
|
176
|
+
assert_that(content2).is_not(content1)
|
182
177
|
|
183
178
|
finger1 = subject.fingerprint
|
184
179
|
finger2 = subject.fingerprint
|
185
|
-
|
180
|
+
assert_that(finger2).is_not(finger1)
|
186
181
|
end
|
187
|
-
|
188
182
|
end
|
189
183
|
|
190
184
|
class MemCacheTests < UnitTests
|
191
185
|
desc "with a `MemCache` cache handler"
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
186
|
+
subject do
|
187
|
+
content_cache = Dassets::MemCache.new
|
188
|
+
fingerprint_cache = Dassets::MemCache.new
|
189
|
+
|
190
|
+
Dassets::SourceProxy.new(
|
191
|
+
"file1.txt",
|
192
|
+
content_cache: content_cache,
|
193
|
+
fingerprint_cache: fingerprint_cache,
|
194
|
+
)
|
199
195
|
end
|
200
196
|
|
201
197
|
should "cache its source content/fingerprint in memory" do
|
202
198
|
content1 = subject.content
|
203
199
|
content2 = subject.content
|
204
|
-
|
200
|
+
assert_that(content2).is(content1)
|
205
201
|
|
206
202
|
finger1 = subject.fingerprint
|
207
203
|
finger2 = subject.fingerprint
|
208
|
-
|
204
|
+
assert_that(finger2).is(finger1)
|
209
205
|
end
|
210
|
-
|
211
206
|
end
|
212
|
-
|
213
207
|
end
|