test/unit/source_file_tests.rb in dassets-0.13.0 vs test/unit/source_file_tests.rb in dassets-0.13.1
- old
+ new
@@ -15,52 +15,56 @@
end
subject{ @source_file }
should have_readers :file_path
should have_imeths :source, :asset_file, :digest_path
- should have_imeths :compiled, :exists?, :mtime
+ should have_imeths :compiled, :exists?, :mtime, :response_headers
should have_cmeth :find_by_digest_path
should "know its file path" do
assert_equal @file_path.to_s, subject.file_path
end
- should "know if it exists" do
- assert subject.exists?
+ should "know its configured source" do
+ exp_source = Dassets.config.sources.select{ |s| @file_path.include?(s.path) }.last
+ assert_equal exp_source, subject.source
end
- should "use the mtime of its file as its mtime" do
- assert_equal File.mtime(subject.file_path), subject.mtime
+ should "know its asset file" do
+ assert_kind_of Dassets::AssetFile, subject.asset_file
+ assert_equal Dassets::AssetFile.new(subject.digest_path), subject.asset_file
end
should "know its digest path" do
assert_equal 'file1.txt', subject.digest_path
end
- should "know its asset file" do
- assert_kind_of Dassets::AssetFile, subject.asset_file
- assert_equal Dassets::AssetFile.new(subject.digest_path), subject.asset_file
+ should "not memoize its compiled source" do
+ compiled1 = subject.compiled
+ compiled2 = subject.compiled
+ assert_not_same compiled2, compiled1
end
- should "know its configured source" do
- exp_source = Dassets.config.sources.select{ |s| @file_path.include?(s.path) }.last
- assert_equal exp_source, subject.source
+ should "know if it exists" do
+ assert subject.exists?
end
+ should "use the mtime of its file as its mtime" do
+ assert_equal File.mtime(subject.file_path), subject.mtime
+ end
+
+ should "use the response headers of its source as its response headers" do
+ assert_same subject.source.response_headers, subject.response_headers
+ end
+
should "be findable by its digest path" do
found = Dassets::SourceFile.find_by_digest_path(subject.digest_path)
assert_equal subject, found
assert_not_same subject, found
end
- should "not memoize its compiled source" do
- compiled1 = subject.compiled
- compiled2 = subject.compiled
- assert_not_same compiled2, compiled1
- end
-
end
class NullSourceTests < UnitTests
setup do
Dassets.config.combination 'file3.txt', ['file1.txt', 'file2.txt']
@@ -78,9 +82,10 @@
assert_equal '', null_src.file_path
assert_equal false, null_src.exists?
assert_nil null_src.compiled
assert_nil null_src.mtime
+ assert_equal Hash.new, null_src.response_headers
end
should "pass options to a null src when finding by an unknown digest path" do
null_src = Dassets::NullSourceFile.new('not/found/digest/path')
null_src_new_called_with = []