File: test_1.rb

package info (click to toggle)
libinotify-ruby 0.0.2-5
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 112 kB
  • ctags: 72
  • sloc: ansic: 236; ruby: 64; makefile: 6
file content (37 lines) | stat: -rw-r--r-- 889 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require 'test/unit'
require './inotify'

class Test1 < Test::Unit::TestCase
	def setup
		@inotify = Inotify.new
	end
	def test1
		assert_equal(Inotify, @inotify.class)
	end
	def test2
		assert(@inotify.add_watch("/tmp", Inotify::CREATE))
	end
	def test3
		wd = @inotify.add_watch("/tmp", Inotify::CREATE)
		assert_equal(Fixnum, wd.class)
		assert(@inotify.rm_watch(wd))
	end
	def test4
		@inotify.add_watch("/tmp", Inotify::CREATE)
		begin 
			File.open(File.join("/tmp", "ruby-inotify-test-4"), 'w')
			@inotify.each_event do |ev|
				assert_equal(ev.class, Inotify::Event)
				assert_equal(ev.inspect, "<Inotify::Event name=ruby-inotify-test-4 mask=256 wd=1>")
				assert_equal(ev.name, "ruby-inotify-test-4")
				assert_equal(ev.mask, Inotify::CREATE)
				break
			end
		ensure
			File.unlink(File.join("/tmp", "ruby-inotify-test-4"))
		end
	end
	def teardown
		@inotify.close
	end
end