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 47 48 49 50 51 52 53 54
|
# remove lib/ from loadpath, added by rspec
$:.delete(File.expand_path("../../lib",__FILE__))
require 'gon'
require 'jbuilder'
require 'rabl'
require 'rabl-rails'
# rabl has a conflict with rabl-rails as rabl-rails causes Rails
# to be defined. In order to run all specs at once, we'll need to
# load/unload rabl and rabl-rails whenever we switch from testing
# one to another.
def ensure_rabl_is_loaded
Object.send(:remove_const, :RablRails) if defined? RablRails
Object.send(:remove_const, :Rails) if defined? Rails
unless defined? Rabl
load 'rabl.rb'
load 'rabl/version.rb'
load 'rabl/helpers.rb'
load 'rabl/partials.rb'
load 'rabl/engine.rb'
load 'rabl/builder.rb'
load 'rabl/configuration.rb'
load 'rabl/renderer.rb'
load 'rabl/cache_engine.rb'
end
end
# Unloads rabl and loads rabl-rails.
def ensure_rabl_rails_is_loaded
Object.send(:remove_const, :Rabl) if defined? Rabl
unless defined? RablRails
load 'rabl-rails/renderer.rb'
load 'rabl-rails/helpers.rb'
load 'rabl-rails/configuration.rb'
load 'rabl-rails/nodes/node.rb'
load 'rabl-rails/nodes/attribute.rb'
load 'rabl-rails/compiler.rb'
load 'rabl-rails/renderers/hash.rb'
load 'rabl-rails/renderers/json.rb'
load 'rabl-rails.rb'
load 'rabl-rails/template.rb'
load 'rabl-rails/library.rb'
end
end
RSpec.configure do |config|
config.before(:each) do
RequestStore.store[:gon] = Gon::Request.new({})
@request = RequestStore.store[:gon]
allow(Gon).to receive(:current_gon).and_return(@request)
end
end
|