~ubuntu-branches/ubuntu/intrepid/ruby1.8/intrepid-updates

« back to all changes in this revision

Viewing changes to test/fileutils/fileasserts.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# $Id: fileasserts.rb 11708 2007-02-12 23:01:19Z shyouhei $
 
2
 
 
3
module Test
 
4
  module Unit
 
5
    module Assertions   # redefine
 
6
 
 
7
      def assert_same_file(from, to)
 
8
        _wrap_assertion {
 
9
          assert_block("file #{from} != #{to}") {
 
10
            File.read(from) == File.read(to)
 
11
          }
 
12
        }
 
13
      end
 
14
 
 
15
      def assert_same_entry(from, to)
 
16
        a = File.stat(from)
 
17
        b = File.stat(to)
 
18
        assert_equal a.mode, b.mode, "mode #{a.mode} != #{b.mode}"
 
19
        #assert_equal a.atime, b.atime
 
20
        assert_equal a.mtime, b.mtime, "mtime #{a.mtime} != #{b.mtime}"
 
21
        assert_equal a.uid, b.uid, "uid #{a.uid} != #{b.uid}"
 
22
        assert_equal a.gid, b.gid, "gid #{a.gid} != #{b.gid}"
 
23
      end
 
24
 
 
25
      def assert_file_exist(path)
 
26
        _wrap_assertion {
 
27
          assert_block("file not exist: #{path}") {
 
28
            File.exist?(path)
 
29
          }
 
30
        }
 
31
      end
 
32
 
 
33
      def assert_file_not_exist(path)
 
34
        _wrap_assertion {
 
35
          assert_block("file not exist: #{path}") {
 
36
            not File.exist?(path)
 
37
          }
 
38
        }
 
39
      end
 
40
 
 
41
      def assert_directory(path)
 
42
        _wrap_assertion {
 
43
          assert_block("is not directory: #{path}") {
 
44
            File.directory?(path)
 
45
          }
 
46
        }
 
47
      end
 
48
 
 
49
      def assert_symlink(path)
 
50
        _wrap_assertion {
 
51
          assert_block("is not a symlink: #{path}") {
 
52
            File.symlink?(path)
 
53
          }
 
54
        }
 
55
      end
 
56
 
 
57
      def assert_not_symlink(path)
 
58
        _wrap_assertion {
 
59
          assert_block("is a symlink: #{path}") {
 
60
            not File.symlink?(path)
 
61
          }
 
62
        }
 
63
      end
 
64
 
 
65
    end
 
66
  end
 
67
end