File: test_helper.rb

package info (click to toggle)
ruby-httpauth 0.2.1%2Bgh-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 192 kB
  • ctags: 127
  • sloc: ruby: 925; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 691 bytes parent folder | download | duplicates (3)
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 'fileutils'
require 'yaml'

class Test::Unit::TestCase
  def self.key_to_sym(hash)
    hash.inject({}) do |h, p|
      if p[1].kind_of? Hash
        h[p[0].intern] = key_to_sym p[1]
      else
        h[p[0].intern] = p[1]
      end
      h
    end
  end

  def self.fixtures(name)
    dir = File.dirname(__FILE__) + '/fixtures'
    File.open(dir + '/' + name.to_s + '.yml') do |f|
      class_variable_set "@@#{name}", key_to_sym(YAML.load(f.read))
    end
  end

protected

  def tmpdir
    File.expand_path(File.dirname(__FILE__) + '/tmp')
  end

  def create_tmpdir
    FileUtils.mkdir tmpdir
  end

  def remove_tmpdir
    FileUtils.rm_rf [tmpdir]
  end
end