test/unit/dassets_tests.rb in dassets-0.3.0 vs test/unit/dassets_tests.rb in dassets-0.4.0

- old
+ new

@@ -6,54 +6,31 @@ class BaseTests < Assert::Context desc "Dassets" subject{ Dassets } - should have_imeths :config, :sources, :digests - should have_imeths :configure, :reset, :init, :[] + should have_imeths :config, :configure, :init, :[] should have_imeths :digest_source_files should "return a `Config` instance with the `config` method" do assert_kind_of Config, subject.config end - should "read the source list on init" do - subject.reset - assert_empty subject.sources - - subject.init - assert_not_empty subject.sources - end - - should "read/parse the digests on init" do - subject.reset - assert_empty subject.digests.paths - - subject.init - assert_not_empty subject.digests.paths - end - - should "return asset files given a their path using the index operator" do - subject.init + should "return asset files given a their digest path using the index operator" do file = subject['nested/file3.txt'] assert_kind_of Dassets::AssetFile, file - assert_equal 'nested/file3.txt', file.path - assert_equal 'd41d8cd98f00b204e9800998ecf8427e', file.md5 - - subject.reset + assert_equal 'nested/file3.txt', file.digest_path + assert_equal 'd41d8cd98f00b204e9800998ecf8427e', file.fingerprint end - should "return an asset file with no fingerprint if path not in digests" do + should "return an asset file with unknown source if digest path not found" do file = subject['path/not/found.txt'] - assert_equal '', file.md5 - subject.init - file = subject['path/not/found.txt'] - assert_equal '', file.md5 - - subject.reset + assert_kind_of Dassets::SourceCache, file.source_cache + assert_kind_of Dassets::NullSourceFile, file.source_cache.source_file + assert_not file.source_cache.exists? end end class SourceListTests < BaseTests @@ -62,20 +39,9 @@ should "build from the configured source path and filter proc" do config = Dassets::Config.new config.source_path = "source_files" # test/support/source_files exp_list = [ 'test1.txt', '_ignored.txt', 'nested/test2.txt', 'nested/_nested_ignored.txt' - ].map{ |p| File.expand_path(p, config.source_path) }.sort - - assert_equal exp_list, Dassets::SourceList.new(config) - end - - should "filter out any paths in the output path" do - config = Dassets::Config.new - config.source_path = "source_files" # test/support/source_files - config.output_path = "source_files/nested" - exp_list = [ - 'test1.txt', '_ignored.txt' ].map{ |p| File.expand_path(p, config.source_path) }.sort assert_equal exp_list, Dassets::SourceList.new(config) end