test/unit/file_store_tests.rb in dassets-0.14.5 vs test/unit/file_store_tests.rb in dassets-0.15.0

- old
+ new

@@ -1,65 +1,73 @@ -require 'assert' -require 'dassets/file_store' +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') + @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_rf(@root.to_s) end - subject{ @store } should have_readers :root should have_imeths :save, :store_path should "know its root" do - assert_equal @root.to_s, subject.root + assert_that(subject.root).equals(@root.to_s) end should "build the store path based on a given url path" do - assert_equal @root_path, subject.store_path(@url_path) + 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_not_file_exists @root_path - path = subject.save(@url_path){ content } + assert_that(@root_path).is_not_a_file - assert_equal @root_path, path - assert_file_exists @root_path - assert_equal content, File.read(@root_path) - end + 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 NullStoreTests < UnitTests - desc "NullStore" +class Dassets::NullFileStore + class UnitTests < Assert::Context + desc "Dassets::NullFileStore" + subject { Dassets::NullFileStore.new } + setup do - @store = Dassets::FileStore::NullStore.new + @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 - should "be a kind of FileStore" do - assert_kind_of Dassets::FileStore, subject + 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_equal '', subject.root + assert_that(subject.root).equals("") end 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 + assert_that(subject.save(@url_path)).equals(File.join("", @url_path)) + assert_that(@root_path).is_not_a_file end - end - end