test/unit/source_file_tests.rb in dassets-0.5.0 vs test/unit/source_file_tests.rb in dassets-0.6.0
- old
+ new
@@ -5,30 +5,30 @@
class Dassets::SourceFile
class BaseTests < Assert::Context
desc "Dassets::SourceFile"
setup do
- @file_path = File.join(Dassets.config.source_path, 'file1.txt')
+ @file_path = TEST_SUPPORT_PATH.join('app/assets/file1.txt').to_s
@source_file = Dassets::SourceFile.new(@file_path)
end
subject{ @source_file }
should have_readers :file_path
- should have_imeths :asset_file, :digest_path
- should have_imeths :compiled, :fingerprint, :exists?, :mtime
+ should have_imeths :source, :asset_file, :digest_path
+ should have_imeths :compiled, :exists?, :mtime
should have_cmeth :find_by_digest_path
should "know its file path" do
- assert_equal @file_path, subject.file_path
+ assert_equal @file_path.to_s, subject.file_path
end
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).httpdate, subject.mtime
+ assert_equal File.mtime(subject.file_path), subject.mtime
end
should "know its digest path" do
assert_equal 'file1.txt', subject.digest_path
end
@@ -36,12 +36,13 @@
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 compiled content fingerprint" do
- assert_equal 'daa05c683a4913b268653f7a7e36a5b4', subject.fingerprint
+ 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 "be findable by its digest path" do
found = Dassets::SourceFile.find_by_digest_path(subject.digest_path)
@@ -60,10 +61,10 @@
end
class EngineTests < BaseTests
desc "compiled against engines"
setup do
- @file_path = File.join(Dassets.config.source_path, 'nested/a-thing.txt.useless.dumb')
+ @file_path = TEST_SUPPORT_PATH.join('app/assets/nested/a-thing.txt.useless.dumb')
@source_file = Dassets::SourceFile.new(@file_path)
end
should "build the digest path appropriately" do
assert_equal 'nested/a-thing.txt.no-use', subject.digest_path