Sha256: e502301d295241ca502510fe09c33195737465f77e31f57fb5c8701ebe47b335

Contents?: true

Size: 1.7 KB

Versions: 5

Compression:

Stored size: 1.7 KB

Contents

require 'rubygems'
require 'minitest/autorun'
require 'rails'
require 'rails/test_help'
require 'rails/generators'
require 'rails/generators/test_case'
require 'slim-rails'

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

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

Rails::Generators.configure! Rails.application.config.generators

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

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

def assert_class(klass, content)
  assert content =~ /class #{klass}(\(.+\))?(.*?)\nend/m, "Expected to have class #{klass}"
  yield $2.strip if block_given?
end

def generator_list
  {
    rails: ['scaffold', 'controller', 'mailer'],
    slim: ['scaffold', 'controller', 'mailer']
  }
end

def path_prefix(name)
  case name
  when :rails
    'rails/generators'
  else
    'generators'
  end
end

def require_generators(generator_list)
  generator_list.each do |name, generators|
    generators.each do |generator_name|
      if name.to_s == 'rails' && generator_name.to_s == 'mailer'
        require File.join(path_prefix(name), generator_name.to_s, "#{generator_name}_generator")
      else
        require File.join(path_prefix(name), name.to_s, generator_name.to_s, "#{generator_name}_generator")
      end
    end
  end
end
alias :require_generator :require_generators

require_generators generator_list

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
slim-rails-3.3.0 test/test_helper.rb
slim-rails-3.2.0 test/test_helper.rb
slim-rails-3.1.3 test/test_helper.rb
slim-rails-3.1.2 test/test_helper.rb
slim-rails-3.1.1 test/test_helper.rb