Skip to content

Instantly share code, notes, and snippets.

@adamhunter
Last active June 10, 2017 05:02
Show Gist options
  • Save adamhunter/5687248 to your computer and use it in GitHub Desktop.
Save adamhunter/5687248 to your computer and use it in GitHub Desktop.
All that is required to bootstrap a basic rails application for a test suite.
# spec/dummy/config/application.rb
ENV['BUNDLE_GEMFILE'] = File.expand_path('../../../../Gemfile', __FILE__)
require 'rubygems'
require 'bundler'
Bundler.setup
$:.unshift File.expand_path('../../../../lib', __FILE__)
# for everything: require "rails/all"
require "action_controller/railtie"
Bundler.require
ApplicationController = Class.new(ActionController::Base)
require 'your_gem'
module Dummy
class Application < ::Rails::Application
config.cache_classes = true
config.active_support.deprecation = :stderr
config.secret_token = 'http://s3-ec.buzzfed.com/static/enhanced/webdr03/2013/5/25/8/anigif_enhanced-buzz-11857-1369483324-0.gif'
end
end
Dummy::Application.initialize!
# spec/dummy/config.ru
require File.expand_path('../config/application', __FILE__)
run Dummy::Application
@adamhunter
Copy link
Author

See gist at revision: https://gist.github.com/adamhunter/5687248/c2e908f5249130c050af74db1c26dfa6a565c980 for Rakefile and script/rails (they'd be in your gem root).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment