file_mode 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,43 @@
1
+
2
+ require 'test/unit'
3
+ require 'file_mode'
4
+
5
+ class TestFileMode < Test::Unit::TestCase #:nodoc:
6
+
7
+ class TestClass #:nodoc:
8
+
9
+ include FileMode
10
+
11
+ attr_accessor :mode
12
+
13
+ def initialize(mode)
14
+ @mode = mode
15
+ end
16
+
17
+ end # TestClass
18
+
19
+ def test_class_methods
20
+ assert(FileMode.setuid?(0o4000))
21
+ assert(FileMode.user_executable?(0o0700))
22
+ assert(!FileMode.user_executable?(0o0600))
23
+ end
24
+
25
+ def test_instance_methods
26
+ foo = TestClass.new(0o2755)
27
+ assert(foo.mode == 0o2755)
28
+ assert(foo.user_executable?)
29
+ assert(foo.group_executable?)
30
+ assert(foo.other_executable?)
31
+ assert(foo.user_writable?)
32
+ assert(!foo.group_writable?)
33
+ assert(!foo.other_writable?)
34
+ assert(foo.user_readable?)
35
+ assert(foo.group_readable?)
36
+ assert(foo.other_readable?)
37
+ assert(!foo.setuid?)
38
+ assert(foo.setgid?)
39
+ assert(!foo.sticky?)
40
+ end
41
+
42
+ end # TestFileMode
43
+