File: test_helper.rb

package info (click to toggle)
ruby-haml-rails 2.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 228 kB
  • sloc: ruby: 281; makefile: 4
file content (47 lines) | stat: -rw-r--r-- 1,187 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
38
39
40
41
42
43
44
45
46
47
require 'rubygems'
require 'minitest/autorun'
require 'action_pack'
require 'action_controller'
require 'action_view'
require 'rails'
require 'rails/generators'
require 'rails/generators/test_case'
require 'html2haml'

class TestApp < Rails::Application
  config.root = File.dirname(__FILE__)
  config.eager_load = false
end

module Rails
  def self.root
    @root ||= Pathname.new(File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp', 'rails')))
  end
end

TestApp.initialize!

Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}

module Haml
  module Rails
    module GeneratorTestHelpers
      private

      def copy_routes
        routes = File.join(File.dirname(__FILE__), 'fixtures', 'routes.rb')
        destination = File.join(::Rails.root, "config")
        FileUtils.mkdir_p(destination)
        FileUtils.cp File.expand_path(routes), File.expand_path(destination)
      end
    end
  end
end

::Rails::Generators::TestCase.include Haml::Rails::GeneratorTestHelpers

# Remove tmp directory when test suite is completed
MiniTest.after_run do
  tmp_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp'))
  FileUtils.rm_r(tmp_dir)
end