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
|
require "rails"
require "jbuilder"
require "active_support"
require "active_support/core_ext/array/access"
require "active_support/cache/memory_store"
require "active_support/json"
require "active_model"
require 'action_controller/railtie'
require 'action_view/railtie'
require "active_support/testing/autorun"
require "mocha/minitest"
ActiveSupport.test_order = :random
ENV["RAILS_ENV"] ||= "test"
class << Rails
def cache
@cache ||= ActiveSupport::Cache::MemoryStore.new
end
end
Jbuilder::CollectionRenderer.collection_cache = Rails.cache
class Post < Struct.new(:id, :body, :author_name)
def cache_key
"post-#{id}"
end
end
class Racer < Struct.new(:id, :name)
extend ActiveModel::Naming
include ActiveModel::Conversion
end
# Instantiate an Application in order to trigger the initializers
Class.new(Rails::Application) do
config.secret_key_base = 'secret'
config.eager_load = false
end.initialize!
# Touch AV::Base in order to trigger :action_view on_load hook before running the tests
ActionView::Base.inspect
|