test/unit/file_store_tests.rb in dassets-0.14.2 vs test/unit/file_store_tests.rb in dassets-0.14.3

- old
+ new

@@ -4,39 +4,41 @@ class Dassets::FileStore class UnitTests < Assert::Context desc "Dassets::FileStore" setup do - @root = TEST_SUPPORT_PATH.join('public') - @url = 'some/url' - @url_path = @root.join(@url).to_s - FileUtils.rm_f(@url_path) + @root = TEST_SUPPORT_PATH.join('public') + @url_path = Factory.url + @root_path = File.join(@root, @url_path).to_s + FileUtils.rm_f(@root_path) @store = Dassets::FileStore.new(@root.to_s) end teardown do - FileUtils.rm_f(@url_path) + FileUtils.rm_rf(@root.to_s) end subject{ @store } should have_readers :root should have_imeths :save, :store_path - should "know its root path" do + should "know its root" do assert_equal @root.to_s, subject.root end - should "build the store path based on a given url" do - assert_equal @url_path, subject.store_path(@url) + should "build the store path based on a given url path" do + assert_equal @root_path, subject.store_path(@url_path) end - should "return write a file and return the store path on save" do - assert_not_file_exists @url_path - path = subject.save(@url){ 'some contents' } + should "write a file and return the store path on save" do + content = Factory.text + assert_not_file_exists @root_path + path = subject.save(@url_path){ content } - assert_equal @url_path, path - assert_file_exists @url_path + assert_equal @root_path, path + assert_file_exists @root_path + assert_equal content, File.read(@root_path) end end class NullStoreTests < UnitTests @@ -47,15 +49,16 @@ should "be a kind of FileStore" do assert_kind_of Dassets::FileStore, subject end - should "know its root path" do + should "know its root" do assert_equal '', subject.root end - should "return the store path on save" do - assert_equal "/#{@url}", subject.save(@url) + should "return the store path on save but not save a file" do + assert_equal File.join('', @url_path), subject.save(@url_path) + assert_not_file_exists @root_path end end end