module RSpec::Rails module App def create_empty_tmp *args args.flatten.each do |arg| dir = send :"#{arg}_dir" FileUtils.mkdir_p dir end end def root_dir ::Rails.root end def app_dir File.join(root_dir, 'app') end def config_dir File.join(root_dir, 'config') end def db_dir File.join(root_dir, 'db') end def locale_dir File.join(root_dir, 'public') end def model_dir File.join(app_dir, 'models') end def observer_dir model_dir end def controller_dir File.join(app_dir, 'controllers') end def mailer_dir File.join(app_dir, 'mailers') end def migration_dir File.join(db_dir, 'migrations') end def helper_dir File.join(app_dir, 'helpers') end def view_dir File.join(app_dir, 'views') end def initializer_dir File.join(config_dir, 'initializers') end def migration_dir File.join(db_dir, 'migrations') end def locale_dir File.join(config_dir, 'locales') end def stylesheet_dir File.join(public_dir, 'stylesheets') end def javascript_dir File.join(public_dir, 'javascripts') end def all_files rails_files root_dir end def app_files rails_app_files end def model_files rails_app_files :models end def controller_files rails_app_files :controllers end def mailer_files rails_app_files :mailers, '**/*_mailer.rb' end def helper_files rails_app_files :helpers end def observer_files rails_app_files :models, '**/*_observer.rb' end def view_files rails_app_files :views end def view_files_html rails_app_files :views, '**/*.html*' end def view_files_haml rails_app_files :views, '**/*.haml*' end def initializer_files rails_files initializer_dir end def db_files rails_files db_dir end def migration_files rails_files migration_dir end def locale_files rails_files locale_dir, '**/*.yml' end def javascript_files rails_files javascript_dir, '**/*.js' end def css_files rails_files stylesheet_dir, '**/*.css' end def sass_files rails_files stylesheet_dir, '**/*.sass' end protected RB_FILES = '**/*.rb' def rails_files dir, type=nil, pattern=nil path = case type when nil "#{dir}/#{RB_FILES}" when String "#{dir}/#{type}" when Symbol pattern ? "#{dir}/#{type}/#{pattern}" : "#{dir}/#{type}" end FileList[path] end def rails_app_files type=nil, pattern='**/*.rb' rails_files :app, type, pattern end end end