sys-filesystem 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
metadata.gz.sig CHANGED
Binary file
data/README DELETED
@@ -1,74 +0,0 @@
1
- = Description
2
- A Ruby interface for getting file system information.
3
-
4
- = Installation
5
- gem install sys-filesystem
6
-
7
- = Synopsis
8
- require 'sys/filesystem'
9
- include Sys
10
-
11
- # Display information about a particular filesystem.
12
- p Filesystem.stat('/')
13
-
14
- # Sample output
15
-
16
- #<Sys::Filesystem::Stat:0x517440
17
- @base_type = "ufs",
18
- @flags = 4,
19
- @files_available = 3817457,
20
- @block_size = 8192,
21
- @blocks_available = 19957633,
22
- @blocks = 34349612,
23
- @name_max = 255,
24
- @path = "/",
25
- @filesystem_id = 35651592,
26
- @files = 4135040,
27
- @fragment_size = 1024,
28
- @files_free = 3817457,
29
- @blocks_free = 20301129
30
- >
31
-
32
- # Describe all mount points on the system
33
- Filesystem.mounts{ |mount| p mount }
34
-
35
- # Find the mount point of any particular file
36
- puts Filesystem.mount_point('/home/djberge/some_file.txt') => '/home'
37
-
38
- = Notes
39
- This is a pure Ruby implementation that uses FFI. This means it should work
40
- with JRuby, too.
41
-
42
- = Sample code
43
- Run 'rake example' if you want to see a basic sample run. The actual code
44
- is 'example_stat.rb' in the 'examples' directory. Modify it as you see fit.
45
-
46
- = Known Bugs
47
- None that I'm aware of. Please report bugs on the project page at
48
- https://github.com/djberg96/sys-filesystem
49
-
50
- = Future Plans
51
- Add better 64-bit support for Linux and BSD.
52
- Other suggestions welcome.
53
-
54
- = Acknowledgements
55
- Mike Hall, for ideas and code that I borrowed from his 'filesystem' library.
56
-
57
- Park Heesob, for implementation and API ideas for the MS Windows version.
58
-
59
- Nobuyoshi Miyokawa, for adding the original FreeBSD and OS X support.
60
-
61
- = License
62
- Apache-2.0
63
-
64
- = Copyright
65
- (C) 2003-2019 Daniel J. Berger
66
- All Rights Reserved
67
-
68
- = Warranty
69
- This library is provided "as is" and without any express or
70
- implied warranties, including, without limitation, the implied
71
- warranties of merchantability and fitness for a particular purpose.
72
-
73
- = Author
74
- Daniel J. Berger
@@ -1,7 +0,0 @@
1
- $LOAD_PATH.unshift File.dirname(File.expand_path(__FILE__))
2
-
3
- if File::ALT_SEPARATOR
4
- require 'test_sys_filesystem_windows'
5
- else
6
- require 'test_sys_filesystem_unix'
7
- end
@@ -1,306 +0,0 @@
1
- ####################################################################
2
- # test_sys_filesystem_unix.rb
3
- #
4
- # Test case for the Sys::Filesystem.stat method and related stuff.
5
- # This test suite should be run via the 'rake test' task.
6
- ####################################################################
7
- require 'test-unit'
8
- require 'sys/filesystem'
9
- include Sys
10
-
11
- class TC_Sys_Filesystem_Unix < Test::Unit::TestCase
12
- def self.startup
13
- @@solaris = RbConfig::CONFIG['host_os'] =~ /solaris/i
14
- @@linux = RbConfig::CONFIG['host_os'] =~ /linux/i
15
- @@freebsd = RbConfig::CONFIG['host_os'] =~ /freebsd/i
16
- @@darwin = RbConfig::CONFIG['host_os'] =~ /darwin/i
17
- end
18
-
19
- def setup
20
- @dir = "/"
21
- @stat = Filesystem.stat(@dir)
22
- @mnt = Filesystem.mounts[0]
23
- @size = 58720256
24
- @array = []
25
- end
26
-
27
- def test_version
28
- assert_equal('1.3.0', Filesystem::VERSION)
29
- assert_true(Filesystem::VERSION.frozen?)
30
- end
31
-
32
- def test_stat_path
33
- assert_respond_to(@stat, :path)
34
- assert_equal("/", @stat.path)
35
- end
36
-
37
- def test_stat_block_size
38
- assert_respond_to(@stat, :block_size)
39
- assert_kind_of(Numeric, @stat.block_size)
40
- end
41
-
42
- def test_block_size_is_a_plausible_value
43
- assert_true(@stat.block_size >= 1024)
44
- assert_true(@stat.block_size <= 16384)
45
- end
46
-
47
- def test_stat_fragment_size
48
- assert_respond_to(@stat, :fragment_size)
49
- assert_kind_of(Numeric, @stat.fragment_size)
50
- end
51
-
52
- def test_stat_blocks
53
- assert_respond_to(@stat, :blocks)
54
- assert_kind_of(Numeric, @stat.blocks)
55
- end
56
-
57
- def test_stat_blocks_free
58
- assert_respond_to(@stat, :blocks_free)
59
- assert_kind_of(Numeric, @stat.blocks_free)
60
- end
61
-
62
- def test_stat_blocks_available
63
- assert_respond_to(@stat, :blocks_available)
64
- assert_kind_of(Numeric, @stat.blocks_available)
65
- end
66
-
67
- def test_stat_files
68
- assert_respond_to(@stat, :files)
69
- assert_kind_of(Numeric, @stat.files)
70
- end
71
-
72
- def test_inodes_alias
73
- assert_respond_to(@stat, :inodes)
74
- assert_true(@stat.method(:inodes) == @stat.method(:files))
75
- end
76
-
77
- def test_stat_files_free
78
- assert_respond_to(@stat, :files_free)
79
- assert_kind_of(Numeric, @stat.files_free)
80
- end
81
-
82
- def test_stat_inodes_free_alias
83
- assert_respond_to(@stat, :inodes_free)
84
- assert_true(@stat.method(:inodes_free) == @stat.method(:files_free))
85
- end
86
-
87
- def test_stat_files_available
88
- assert_respond_to(@stat, :files_available)
89
- assert_kind_of(Numeric, @stat.files_available)
90
- end
91
-
92
- def test_stat_inodes_available_alias
93
- assert_respond_to(@stat, :inodes_available)
94
- assert_true(@stat.method(:inodes_available) == @stat.method(:files_available))
95
- end
96
-
97
- def test_stat_filesystem_id
98
- assert_respond_to(@stat, :filesystem_id)
99
- assert_kind_of(Integer, @stat.filesystem_id)
100
- end
101
-
102
- def test_stat_flags
103
- assert_respond_to(@stat, :flags)
104
- assert_kind_of(Numeric, @stat.flags)
105
- end
106
-
107
- def test_stat_name_max
108
- assert_respond_to(@stat, :name_max)
109
- assert_kind_of(Numeric, @stat.name_max)
110
- end
111
-
112
- def test_stat_base_type
113
- omit_unless(@@solaris, "base_type test skipped except on Solaris")
114
-
115
- assert_respond_to(@stat, :base_type)
116
- assert_kind_of(String, @stat.base_type)
117
- end
118
-
119
- def test_stat_constants
120
- assert_not_nil(Filesystem::Stat::RDONLY)
121
- assert_not_nil(Filesystem::Stat::NOSUID)
122
-
123
- omit_unless(@@solaris, "NOTRUNC test skipped except on Solaris")
124
-
125
- assert_not_nil(Filesystem::Stat::NOTRUNC)
126
- end
127
-
128
- def test_stat_bytes_total
129
- assert_respond_to(@stat, :bytes_total)
130
- assert_kind_of(Numeric, @stat.bytes_total)
131
- end
132
-
133
- def test_stat_bytes_free
134
- assert_respond_to(@stat, :bytes_free)
135
- assert_kind_of(Numeric, @stat.bytes_free)
136
- assert_equal(@stat.bytes_free, @stat.blocks_free * @stat.fragment_size)
137
- end
138
-
139
- def test_stat_bytes_available
140
- assert_respond_to(@stat, :bytes_available)
141
- assert_kind_of(Numeric, @stat.bytes_available)
142
- assert_equal(@stat.bytes_available, @stat.blocks_available * @stat.fragment_size)
143
- end
144
-
145
- def test_stat_bytes_used
146
- assert_respond_to(@stat, :bytes_used)
147
- assert_kind_of(Numeric, @stat.bytes_used)
148
- end
149
-
150
- def test_stat_percent_used
151
- assert_respond_to(@stat, :percent_used)
152
- assert_kind_of(Float, @stat.percent_used)
153
- end
154
-
155
- def test_stat_expected_errors
156
- assert_raises(ArgumentError){ Filesystem.stat }
157
- end
158
-
159
- def test_stat_case_insensitive
160
- expected = @@darwin ? true : false
161
- assert_equal(expected, @stat.case_insensitive?)
162
- assert_equal(expected, Filesystem.stat(Dir.home).case_insensitive?)
163
- end
164
-
165
- def test_stat_case_sensitive
166
- expected = @@darwin ? false : true
167
- assert_equal(expected, @stat.case_sensitive?)
168
- assert_equal(expected, Filesystem.stat(Dir.home).case_sensitive?)
169
- end
170
-
171
- def test_numeric_methods_basic
172
- assert_respond_to(@size, :to_kb)
173
- assert_respond_to(@size, :to_mb)
174
- assert_respond_to(@size, :to_gb)
175
- assert_respond_to(@size, :to_tb)
176
- end
177
-
178
- def test_to_kb
179
- assert_equal(57344, @size.to_kb)
180
- end
181
-
182
- def test_to_mb
183
- assert_equal(56, @size.to_mb)
184
- end
185
-
186
- def test_to_gb
187
- assert_equal(0, @size.to_gb)
188
- end
189
-
190
- # Filesystem::Mount tests
191
-
192
- def test_mounts_with_no_block
193
- assert_nothing_raised{ @array = Filesystem.mounts }
194
- assert_kind_of(Filesystem::Mount, @array[0])
195
- end
196
-
197
- def test_mounts_with_block
198
- assert_nothing_raised{ Filesystem.mounts{ |m| @array << m } }
199
- assert_kind_of(Filesystem::Mount, @array[0])
200
- end
201
-
202
- def test_mounts_high_iteration
203
- assert_nothing_raised{ 1000.times{ @array = Filesystem.mounts } }
204
- end
205
-
206
- def test_mount_name
207
- assert_respond_to(@mnt, :name)
208
- assert_kind_of(String, @mnt.name)
209
- end
210
-
211
- def test_fsname_alias
212
- assert_respond_to(@mnt, :fsname)
213
- assert_true(@mnt.method(:fsname) == @mnt.method(:name))
214
- end
215
-
216
- def test_mount_point
217
- assert_respond_to(@mnt, :mount_point)
218
- assert_kind_of(String, @mnt.mount_point)
219
- end
220
-
221
- def test_dir_alias
222
- assert_respond_to(@mnt, :dir)
223
- assert_true(@mnt.method(:dir) == @mnt.method(:mount_point))
224
- end
225
-
226
- def test_mount_type
227
- assert_respond_to(@mnt, :mount_type)
228
- assert_kind_of(String, @mnt.mount_type)
229
- end
230
-
231
- def test_mount_options
232
- assert_respond_to(@mnt, :options)
233
- assert_kind_of(String, @mnt.options)
234
- end
235
-
236
- def test_opts_alias
237
- assert_respond_to(@mnt, :opts)
238
- assert_true(@mnt.method(:opts) == @mnt.method(:options))
239
- end
240
-
241
- def test_mount_time
242
- assert_respond_to(@mnt, :mount_time)
243
-
244
- if @@solaris
245
- assert_kind_of(Time, @mnt.mount_time)
246
- else
247
- assert_nil(@mnt.mount_time)
248
- end
249
- end
250
-
251
- def test_mount_dump_frequency
252
- msg = 'dump_frequency test skipped on this platform'
253
- omit_if(@@solaris || @@freebsd || @@darwin, msg)
254
- assert_respond_to(@mnt, :dump_frequency)
255
- assert_kind_of(Numeric, @mnt.dump_frequency)
256
- end
257
-
258
- def test_freq_alias
259
- assert_respond_to(@mnt, :freq)
260
- assert_true(@mnt.method(:freq) == @mnt.method(:dump_frequency))
261
- end
262
-
263
- def test_mount_pass_number
264
- msg = 'pass_number test skipped on this platform'
265
- omit_if(@@solaris || @@freebsd || @@darwin, msg)
266
- assert_respond_to(@mnt, :pass_number)
267
- assert_kind_of(Numeric, @mnt.pass_number)
268
- end
269
-
270
- def test_passno_alias
271
- assert_respond_to(@mnt, :passno)
272
- assert_true(@mnt.method(:passno) == @mnt.method(:pass_number))
273
- end
274
-
275
- def test_mount_point_singleton
276
- assert_respond_to(Filesystem, :mount_point)
277
- assert_nothing_raised{ Filesystem.mount_point(Dir.pwd) }
278
- assert_kind_of(String, Filesystem.mount_point(Dir.pwd))
279
- end
280
-
281
- def test_ffi_functions_are_private
282
- assert_false(Filesystem.methods.include?('statvfs'))
283
- assert_false(Filesystem.methods.include?('strerror'))
284
- end
285
-
286
- def test_mount_singleton_method
287
- assert_respond_to(Sys::Filesystem, :mount)
288
- end
289
-
290
- def test_umount_singleton_method
291
- assert_respond_to(Sys::Filesystem, :umount)
292
- end
293
-
294
- def teardown
295
- @dir = nil
296
- @stat = nil
297
- @array = nil
298
- end
299
-
300
- def self.shutdown
301
- @@solaris = nil
302
- @@linux = nil
303
- @@freebsd = nil
304
- @@darwin = nil
305
- end
306
- end
@@ -1,303 +0,0 @@
1
- ####################################################################
2
- # test_sys_filesystem_windows.rb
3
- #
4
- # Test case for the Sys::Filesystem.stat method and related stuff.
5
- # This should be run via the 'rake test' task.
6
- ####################################################################
7
- require 'test-unit'
8
- require 'sys/filesystem'
9
- require 'rbconfig'
10
- require 'pathname'
11
- include Sys
12
-
13
- class TC_Sys_Filesystem_Windows < Test::Unit::TestCase
14
- def setup
15
- @dir = 'C:/'
16
- @stat = Filesystem.stat(@dir)
17
- @mount = Filesystem.mounts[0]
18
- @size = 58720256
19
- @array = []
20
- end
21
-
22
- test "version number is set to the expected value" do
23
- assert_equal('1.3.0', Filesystem::VERSION)
24
- assert_true(Filesystem::VERSION.frozen?)
25
- end
26
-
27
- test "stat path works as expected" do
28
- assert_respond_to(@stat, :path)
29
- assert_equal("C:/", @stat.path)
30
- end
31
-
32
- test "stat block_size works as expected" do
33
- assert_respond_to(@stat, :block_size)
34
- assert_kind_of(Numeric, @stat.block_size)
35
- end
36
-
37
- test "stat works with or without trailing slash on standard paths" do
38
- assert_equal("C:/", Filesystem.stat("C:/").path)
39
- assert_equal("C:/Users", Filesystem.stat("C:/Users").path)
40
- assert_equal("C:/Users/", Filesystem.stat("C:/Users/").path)
41
- assert_equal("C:/Users/", Filesystem.stat("C:/Users/").path)
42
- end
43
-
44
- test "stat works with or without trailing slash on UNC paths" do
45
- assert_equal("//127.0.0.1/C$", Filesystem.stat("//127.0.0.1/C$").path)
46
- assert_equal("//127.0.0.1/C$/", Filesystem.stat("//127.0.0.1/C$/").path)
47
- assert_equal("\\\\127.0.0.1\\C$", Filesystem.stat("\\\\127.0.0.1\\C$").path)
48
- assert_equal("\\\\127.0.0.1\\C$\\", Filesystem.stat("\\\\127.0.0.1\\C$\\").path)
49
- end
50
-
51
- test "stat fragment_size works as expected" do
52
- assert_respond_to(@stat, :fragment_size)
53
- assert_nil(@stat.fragment_size)
54
- end
55
-
56
- test "stat blocks works as expected" do
57
- assert_respond_to(@stat, :blocks)
58
- assert_kind_of(Numeric, @stat.blocks)
59
- end
60
-
61
- test "stat blocks_free works as expected" do
62
- assert_respond_to(@stat, :blocks_free)
63
- assert_kind_of(Numeric, @stat.blocks_free)
64
- end
65
-
66
- test "stat blocks_available works as expected" do
67
- assert_respond_to(@stat, :blocks_available)
68
- assert_kind_of(Numeric, @stat.blocks_available)
69
- end
70
-
71
- test "block stats return expected relative values" do
72
- assert_true(@stat.blocks >= @stat.blocks_free)
73
- assert_true(@stat.blocks_free >= @stat.blocks_available)
74
- end
75
-
76
- test "stat files works as expected" do
77
- assert_respond_to(@stat, :files)
78
- assert_nil(@stat.files)
79
- end
80
-
81
- test "stat inodes is an alias for files" do
82
- assert_alias_method(@stat, :inodes, :files)
83
- end
84
-
85
- test "stat files_free works as expected" do
86
- assert_respond_to(@stat, :files_free)
87
- assert_nil(@stat.files_free)
88
- end
89
-
90
- test "stat inodes_free is an alias for files_free" do
91
- assert_respond_to(@stat, :inodes_free)
92
- end
93
-
94
- test "stat files available works as expected" do
95
- assert_respond_to(@stat, :files_available)
96
- assert_nil(@stat.files_available)
97
- end
98
-
99
- test "stat inodes_available is an alias for files_available" do
100
- assert_alias_method(@stat, :inodes_available, :files_available)
101
- end
102
-
103
- test "stat filesystem_id works as expected" do
104
- assert_respond_to(@stat, :filesystem_id)
105
- assert_kind_of(Integer, @stat.filesystem_id)
106
- end
107
-
108
- test "stat flags works as expected" do
109
- assert_respond_to(@stat, :flags)
110
- assert_kind_of(Numeric, @stat.flags)
111
- end
112
-
113
- test "stat name_max works as expected" do
114
- assert_respond_to(@stat, :name_max)
115
- assert_kind_of(Numeric, @stat.name_max)
116
- end
117
-
118
- test "stat base_type works as expected" do
119
- assert_respond_to(@stat, :base_type)
120
- assert_kind_of(String, @stat.base_type)
121
- end
122
-
123
- test "stat bytes_total basic functionality" do
124
- assert_respond_to(@stat, :bytes_total)
125
- assert_kind_of(Numeric, @stat.bytes_total)
126
- end
127
-
128
- test "stat bytes_free basic functionality" do
129
- assert_respond_to(@stat, :bytes_free)
130
- assert_kind_of(Numeric, @stat.bytes_free)
131
- assert_equal(@stat.bytes_free, @stat.blocks_free * @stat.block_size)
132
- end
133
-
134
- test "stat bytes_available basic functionality" do
135
- assert_respond_to(@stat, :bytes_available)
136
- assert_kind_of(Numeric, @stat.bytes_available)
137
- assert_equal(@stat.bytes_available, @stat.blocks_available * @stat.block_size)
138
- end
139
-
140
- test "stat bytes_used basic functionality" do
141
- assert_respond_to(@stat, :bytes_used)
142
- assert_kind_of(Numeric, @stat.bytes_used)
143
- end
144
-
145
- test "stat percent_used basic functionality" do
146
- assert_respond_to(@stat, :percent_used)
147
- assert_kind_of(Float, @stat.percent_used)
148
- end
149
-
150
- test "case_insensitive returns expected result" do
151
- assert_respond_to(@stat, :case_insensitive?)
152
- assert_true(@stat.case_insensitive?)
153
- end
154
-
155
- test "mount_point singleton method basic functionality" do
156
- assert_respond_to(Filesystem, :mount_point)
157
- assert_nothing_raised{ Filesystem.mount_point(Dir.pwd) }
158
- assert_kind_of(String, Filesystem.mount_point(Dir.pwd))
159
- end
160
-
161
- test "mount_point singleton method returns expected value" do
162
- assert_equal("C:\\", Filesystem.mount_point("C:\\Users\\foo"))
163
- assert_equal("\\\\foo\\bar", Filesystem.mount_point("//foo/bar/baz"))
164
- end
165
-
166
- test "mount_point works with Pathname object" do
167
- assert_nothing_raised{ Filesystem.mount_point(Pathname.new("C:/Users/foo")) }
168
- assert_equal("C:\\", Filesystem.mount_point("C:\\Users\\foo"))
169
- assert_equal("\\\\foo\\bar", Filesystem.mount_point("//foo/bar/baz"))
170
- end
171
-
172
- test "filesystem constants are defined" do
173
- assert_not_nil(Filesystem::CASE_SENSITIVE_SEARCH)
174
- assert_not_nil(Filesystem::CASE_PRESERVED_NAMES)
175
- assert_not_nil(Filesystem::UNICODE_ON_DISK)
176
- assert_not_nil(Filesystem::PERSISTENT_ACLS)
177
- assert_not_nil(Filesystem::FILE_COMPRESSION)
178
- assert_not_nil(Filesystem::VOLUME_QUOTAS)
179
- assert_not_nil(Filesystem::SUPPORTS_SPARSE_FILES)
180
- assert_not_nil(Filesystem::SUPPORTS_REPARSE_POINTS)
181
- assert_not_nil(Filesystem::SUPPORTS_REMOTE_STORAGE)
182
- assert_not_nil(Filesystem::VOLUME_IS_COMPRESSED)
183
- assert_not_nil(Filesystem::SUPPORTS_OBJECT_IDS)
184
- assert_not_nil(Filesystem::SUPPORTS_ENCRYPTION)
185
- assert_not_nil(Filesystem::NAMED_STREAMS)
186
- assert_not_nil(Filesystem::READ_ONLY_VOLUME)
187
- end
188
-
189
- test "stat singleton method defaults to root path if proviced" do
190
- assert_nothing_raised{ Filesystem.stat("C://Program Files") }
191
- end
192
-
193
- test "stat singleton method accepts a Pathname object" do
194
- assert_nothing_raised{ Filesystem.stat(Pathname.new("C://Program Files")) }
195
- end
196
-
197
- test "stat singleton method requires a single argument" do
198
- assert_raise(ArgumentError){ Filesystem.stat }
199
- assert_raise(ArgumentError){ Filesystem.stat(Dir.pwd, Dir.pwd) }
200
- end
201
-
202
- test "stat singleton method raises an error if path is not found" do
203
- assert_raise(Errno::ESRCH){ Filesystem.stat("C://Bogus//Dir") }
204
- end
205
-
206
- # Filesystem.mounts
207
-
208
- test "mounts singleton method basic functionality" do
209
- assert_respond_to(Filesystem, :mounts)
210
- assert_nothing_raised{ Filesystem.mounts }
211
- assert_nothing_raised{ Filesystem.mounts{} }
212
- end
213
-
214
- test "mounts singleton method returns the expected value" do
215
- assert_kind_of(Array, Filesystem.mounts)
216
- assert_kind_of(Filesystem::Mount, Filesystem.mounts[0])
217
- end
218
-
219
- test "mounts singleton method works as expected when a block is provided" do
220
- assert_nil(Filesystem.mounts{})
221
- assert_nothing_raised{ Filesystem.mounts{ |mt| @array << mt }}
222
- assert_kind_of(Filesystem::Mount, @array[0])
223
- end
224
-
225
- test "mount name works as expected" do
226
- assert_respond_to(@mount, :name)
227
- assert_kind_of(String, @mount.name)
228
- end
229
-
230
- test "mount time works as expected" do
231
- assert_respond_to(@mount, :mount_time)
232
- assert_kind_of(Time, @mount.mount_time)
233
- end
234
-
235
- test "mount type works as expected" do
236
- assert_respond_to(@mount, :mount_type)
237
- assert_kind_of(String, @mount.mount_type)
238
- end
239
-
240
- test "mount point works as expected" do
241
- assert_respond_to(@mount, :mount_point)
242
- assert_kind_of(String, @mount.mount_point)
243
- end
244
-
245
- test "mount options works as expected" do
246
- assert_respond_to(@mount, :options)
247
- assert_kind_of(String, @mount.options)
248
- end
249
-
250
- test "mount pass_number works as expected" do
251
- assert_respond_to(@mount, :pass_number)
252
- assert_nil(@mount.pass_number)
253
- end
254
-
255
- test "mount frequency works as expected" do
256
- assert_respond_to(@mount, :frequency)
257
- assert_nil(@mount.frequency)
258
- end
259
-
260
- test "mounts singleton method does not accept any arguments" do
261
- assert_raise(ArgumentError){ Filesystem.mounts("C:\\") }
262
- end
263
-
264
- test "custom Numeric#to_kb method works as expected" do
265
- assert_respond_to(@size, :to_kb)
266
- assert_equal(57344, @size.to_kb)
267
- end
268
-
269
- test "custom Numeric#to_mb method works as expected" do
270
- assert_respond_to(@size, :to_mb)
271
- assert_equal(56, @size.to_mb)
272
- end
273
-
274
- test "custom Numeric#to_gb method works as expected" do
275
- assert_respond_to(@size, :to_gb)
276
- assert_equal(0, @size.to_gb)
277
- end
278
-
279
- # Mount and Unmount
280
-
281
- test "mount singleton method exists" do
282
- assert_respond_to(Sys::Filesystem, :mount)
283
- end
284
-
285
- test "umount singleton method exists" do
286
- assert_respond_to(Sys::Filesystem, :umount)
287
- end
288
-
289
- # FFI
290
-
291
- test "internal ffi functions are not public" do
292
- assert_false(Filesystem.methods.include?(:GetVolumeInformationA))
293
- assert_false(Filesystem.instance_methods.include?(:GetVolumeInformationA))
294
- end
295
-
296
- def teardown
297
- @array = nil
298
- @dir = nil
299
- @stat = nil
300
- @size = nil
301
- @mount = nil
302
- end
303
- end