-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_helper.rb
76 lines (63 loc) · 1.53 KB
/
test_helper.rb
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
require 'rubygems'
require 'rspec'
require 'active_support/all'
require 'action_pack'
require 'action_controller'
require 'test/unit'
require 'redgreen'
$LOAD_PATH << 'lib'
require 'init'
class ActionView::Base
def debug(*args)
args.inspect
end
include ActionView::Helpers::AssetTagHelper
include ActionView::Helpers::TagHelper
end
silence_warnings do
ActionView::Helpers::AssetTagHelper::ASSETS_DIR = 'test/public'
end
if ActionPack::VERSION::MAJOR > 2
require 'action_dispatch/testing/test_process'
# fake checks
require 'ostruct'
module ActionController::UrlFor
def _routes
helpers = OpenStruct.new
helpers.url_helpers = Module.new
helpers
end
end
ROUTES = ActionDispatch::Routing::RouteSet.new
ROUTES.draw do
match ':controller(/:action(/:id(.:format)))'
end
ROUTES.finalize!
# funky patch to get @routes working, in 'setup' did not work
module ActionController::TestCase::Behavior
def process_with_routes(*args)
@routes = ROUTES
process_without_routes(*args)
end
alias_method_chain :process, :routes
end
class ActionController::Base
self.view_paths = 'test/views'
def self._routes
ROUTES
end
def url_for(*args)
'xxx'
end
end
else
require 'action_controller/test_process'
ActionController::Routing::Routes.reload rescue nil
ActionController::Base.cache_store = :memory_store
class ActionController::Base
before_filter :set_view_paths
def set_view_paths
@template.view_paths = 'test/views'
end
end
end