-
-
Save bf4/8744473 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include ActiveSupport | |
["app/**/", "lib/**/"].each do |glob| | |
Dir.glob(glob).each do |dir| | |
Dependencies.autoload_paths << File.join(File.dirname(__FILE__), dir) | |
end | |
end |
Or some gobbley gook pastiche of the above
require 'pathname'
require 'rails/railtie'
require 'active_record/railtie'
require 'active_support/railtie'
require 'active_support/all'
# see https://github.com/rails/rails/tree/master/activesupport/lib/active_support/
# require 'active_support/core_ext'
# require 'active_support/inflections'
# require 'active_support/inflector'
require 'active_support/dependencies'
require "bundler/setup"
# Bundler.require
begin
module RailsApp
class Application < Rails::Application
config.secret_token = routes.append {
root to: proc {
[200, {"Content-Type" => "text/html"}, []]
}
}.to_s
config.root = Pathname(File.expand_path('../..', __FILE__))
config.active_support.deprecation = :log
config.eager_load = false
end
end
include ActiveSupport
["app/**/", "lib/**/"].each do |glob|
Dir.glob(glob).each do |dir|
Dependencies.autoload_paths << File.join(File.dirname(__FILE__), dir)
end
end
end unless defined?(RailsApp::Application)
db_config = File.read(Rails.root.join('config/database.yml'))
db_config = ERB.new(db_config).result(binding)
db_settings = YAML::load(db_config)['test']
ActiveRecord::Base.establish_connection(db_settings)
def ensure_model_loaded(model_name, &block)
@tries = 1
begin
block.call
rescue NameError => e
@tries -= 1
if model_path = Rails.configuration.autoload_paths.detect do |path|
filename = path.basename.ext('')
model_name == filename
end
require model_path
retry if @tries.zero?
end
end
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://thegrubbsian.com/post/19332051988/testing-rails-engines-sans-dummy