test/unit/dassets_tests.rb in dassets-0.5.0 vs test/unit/dassets_tests.rb in dassets-0.6.0
- old
+ new
@@ -7,11 +7,11 @@
class BaseTests < Assert::Context
desc "Dassets"
subject{ Dassets }
should have_imeths :config, :configure, :init, :[]
- should have_imeths :digest_source_files
+ should have_imeths :source_list, :digest_source_files
should "return a `Config` instance with the `config` method" do
assert_kind_of Config, subject.config
end
@@ -21,57 +21,17 @@
assert_kind_of Dassets::AssetFile, file
assert_equal 'nested/file3.txt', file.digest_path
assert_equal 'd41d8cd98f00b204e9800998ecf8427e', file.fingerprint
end
- should "return an asset file with unknown source if digest path not found" do
+ should "return an asset file that doesn't exist if digest path not found" do
file = subject['path/not/found.txt']
-
- assert_kind_of Dassets::SourceCache, file.source_cache
- assert_kind_of Dassets::NullSourceFile, file.source_cache.source_file
- assert_not file.source_cache.exists?
+ assert_not file.exists?
end
- should "complain if trying to init without setting the root path" do
- orig_root = Dassets.config.root_path
-
- Dassets.config.root_path = nil
- assert_raises(RuntimeError){ Dassets.init }
-
- Dassets.config.root_path = orig_root
- end
-
- end
-
- class SourceListTests < BaseTests
- desc "source list"
-
- 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 "run the supplied source filter on the paths" do
- config = Dassets::Config.new
- config.source_path = "source_files" # test/support/source_files
- config.source_filter = proc do |paths|
- paths.reject{ |path| File.basename(path) =~ /^_/ }
- end
- exp_list = [
- 'test1.txt', 'nested/test2.txt'
- ].map{ |p| File.expand_path(p, config.source_path) }.sort
-
- assert_equal exp_list, Dassets::SourceList.new(config)
-
- config.source "source_files" do |paths|
- paths.reject{ |path| File.basename(path) =~ /^_/ }
- end
- assert_equal exp_list, Dassets::SourceList.new(config)
+ should "know its list of configured source files" do
+ exp_configured_list = Dassets::SourceList.new(Dassets.config.sources)
+ assert_equal exp_configured_list, subject.source_list
end
end
end