Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

root/branches/1_5/test/testutil.rb

Revision 1794, 1.0 kB (checked in by nahi, 1 year ago)
  • extract common test methods in TestUtil? module.
  • silent require. closes #341.
Line 
1 module TestUtil
2   # MT-unsafe
3   def self.require(dir, *features)
4     begin
5       # avoid 'already initialized constant FizzBuzz' warning
6       silent do
7         Dir.chdir(dir) do
8           features.each do |feature|
9             Kernel.require feature
10           end
11         end
12       end
13     ensure
14       features.each do |feature|
15         $".delete(feature)
16       end
17     end
18   end
19
20   # MT-unsafe
21   def self.silent
22     if $DEBUG
23       yield
24     else
25       back = $VERBOSE
26       $VERBOSE = nil
27       begin
28         yield
29       ensure
30         $VERBOSE = back
31       end
32     end
33   end
34
35   def self.filecompare(expectedfile, actualfile)
36     expected = loadfile(expectedfile)
37     actual = loadfile(actualfile)
38     if expected != actual
39       raise "#{File.basename(actualfile)} is different from #{File.basename(expectedfile)}"
40     end
41   end
42
43   def self.loadfile(file)
44     File.open(file) { |f| f.read }
45   end
46
47   def self.start_server_thread(server)
48     t = Thread.new {
49       Thread.current.abort_on_exception = true
50       server.start
51     }
52     t
53   end
54 end
Note: See TracBrowser for help on using the browser.