Sha256: 861f5440339d529939cb6690029563194fde2b98771335a2473880c279d28186
Contents?: true
Size: 1.86 KB
Versions: 3
Compression:
Stored size: 1.86 KB
Contents
# frozen_string_literal: true require "assert" require "dassets/file_store" class Dassets::FileStore class UnitTests < Assert::Context desc "Dassets::FileStore" subject{ Dassets::FileStore.new(@root.to_s) } setup do @root = TEST_SUPPORT_PATH.join("public") @url_path = Factory.url @root_path = File.join(@root, @url_path).to_s FileUtils.rm_f(@root_path) end teardown do FileUtils.rm_rf(@root.to_s) end should have_readers :root should have_imeths :save, :store_path should "know its root" do assert_that(subject.root).equals(@root.to_s) end should "build the store path based on a given url path" do assert_that(subject.store_path(@url_path)).equals(@root_path) end should "write a file and return the store path on save" do content = Factory.text assert_that(@root_path).is_not_a_file path = subject.save(@url_path){ content } assert_that(path).equals(@root_path) assert_that(@root_path).is_a_file assert_that(File.read(@root_path)).equals(content) end end end class Dassets::NullFileStore class UnitTests < Assert::Context desc "Dassets::NullFileStore" subject{ Dassets::NullFileStore.new } setup do @root = TEST_SUPPORT_PATH.join("public") @url_path = Factory.url @root_path = File.join(@root, @url_path).to_s FileUtils.rm_f(@root_path) end teardown do FileUtils.rm_rf(@root.to_s) end should "be a kind of Dassets::FileStore" do assert_that(subject).is_kind_of(Dassets::FileStore) end should "know its root" do assert_that(subject.root).equals("") end should "return the store path on save but not save a file" do assert_that(subject.save(@url_path)).equals(File.join("", @url_path)) assert_that(@root_path).is_not_a_file end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
dassets-0.15.3 | test/unit/file_store_tests.rb |
dassets-0.15.2 | test/unit/file_store_tests.rb |
dassets-0.15.1 | test/unit/file_store_tests.rb |