class TestPageFiles

Public Instance Methods

setup_files() click to toggle source
# File vendor/qwik/lib/qwik/page-files.rb, line 154
def setup_files
  dir = '.test/'.path
  dir.setup
  files = Qwik::PageFiles.new(dir.to_s, '1')

  d = dir+'.attach'
  d.teardown if d.exist?

  return [dir, files]
end
teardown_files(dir) click to toggle source
# File vendor/qwik/lib/qwik/page-files.rb, line 165
def teardown_files(dir)
  dir.teardown
end
test_fput() click to toggle source
# File vendor/qwik/lib/qwik/page-files.rb, line 209
def test_fput
  dir, files = setup_files

  # test_with_japanese_filename
  files.fput("\202\240.txt", 't')
  ok_eq(["\343\201\202.txt"], files.list)
  ok_eq(true, files.exist?("\202\240.txt"))

  # test_with_japanese_filename_twice
  files.fput("\202\240.txt", 't2')  # with same name.
  ok_eq(["1-\343\201\202.txt", "\343\201\202.txt"], files.list)
  ok_eq(true, files.exist?("1-\202\240.txt"))

  files.delete("\202\240.txt")
  ok_eq(false, files.exist?("\202\240.txt"))
  files.delete("1-\202\240.txt")
  ok_eq(false, files.exist?("1-\202\240.txt"))

  teardown_files(dir)
end
test_page_attach() click to toggle source
# File vendor/qwik/lib/qwik/page-files.rb, line 169
    def test_page_attach
      dir, files = setup_files

      # test_not_exist
      ok_eq(false, files.exist?('t.txt'))

      # test_put
      files.fput('t.txt', 't')
      ok_eq(true, files.exist?('t.txt'))

      # test_load_file
      # FIXME: The path should not be accesible.
#      path = files.path('t.txt')
#      ok_eq('./test/1.files/t.txt', path.to_s)
#      ok_eq('t', path.get)

      # test_get
      ok_eq('t', files.get('t.txt'))

      # test_list
      ok_eq(['t.txt'], files.list)

      # test_each
      files.each {|f|
        ok_eq('t.txt', f)      # Only one file here.
      }

      # test_delete
      files.delete('t.txt')
      ok_eq(false, files.exist?('t.txt'))

      # test_security
#      path = files.path('t/t.txt') # ok
#      assert_raise(Qwik::CanNotAccessParentDirectory) {
#       path = files.path('../t.txt') # bad
#      }

      teardown_files(dir)
    end
test_total() click to toggle source

test file size total

# File vendor/qwik/lib/qwik/page-files.rb, line 231
def test_total
  dir, files = setup_files

  # save file size 1
  files.fput("size1.txt",'1')
  ok_eq(1,files.total)

  # save file size 10
  files.fput("size10.txt",'1'*10)

  # check if total file size is 1 + 10
  ok_eq(11,files.total)

  # delete file, size 1
  files.delete("size1.txt")
  ok_eq(10,files.total)
end