erubis_rails_helper 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. data/README.rdoc +66 -0
  2. data/lib/erubis_rails_helper.rb +17 -0
  3. data/lib/erubis_rails_helper/erubis/generator.rb +100 -0
  4. data/lib/erubis_rails_helper/template_handlers/erubis.rb +258 -0
  5. data/test/abstract_unit.rb +51 -0
  6. data/test/controller/action_pack_assertions_test.rb +516 -0
  7. data/test/controller/addresses_render_test.rb +37 -0
  8. data/test/controller/assert_select_test.rb +734 -0
  9. data/test/controller/base_test.rb +217 -0
  10. data/test/controller/benchmark_test.rb +32 -0
  11. data/test/controller/caching_test.rb +690 -0
  12. data/test/controller/capture_test.rb +66 -0
  13. data/test/controller/content_type_test.rb +168 -0
  14. data/test/controller/controller_fixtures/app/controllers/admin/user_controller.rb +0 -0
  15. data/test/controller/controller_fixtures/app/controllers/user_controller.rb +0 -0
  16. data/test/controller/controller_fixtures/vendor/plugins/bad_plugin/lib/plugin_controller.rb +0 -0
  17. data/test/controller/cookie_test.rb +111 -0
  18. data/test/controller/deprecation/deprecated_base_methods_test.rb +32 -0
  19. data/test/controller/dispatcher_test.rb +103 -0
  20. data/test/controller/fake_controllers.rb +33 -0
  21. data/test/controller/fake_models.rb +19 -0
  22. data/test/controller/filter_params_test.rb +49 -0
  23. data/test/controller/filters_test.rb +885 -0
  24. data/test/controller/flash_test.rb +142 -0
  25. data/test/controller/header_test.rb +14 -0
  26. data/test/controller/helper_test.rb +224 -0
  27. data/test/controller/html-scanner/cdata_node_test.rb +15 -0
  28. data/test/controller/html-scanner/document_test.rb +148 -0
  29. data/test/controller/html-scanner/node_test.rb +89 -0
  30. data/test/controller/html-scanner/sanitizer_test.rb +273 -0
  31. data/test/controller/html-scanner/tag_node_test.rb +238 -0
  32. data/test/controller/html-scanner/text_node_test.rb +50 -0
  33. data/test/controller/html-scanner/tokenizer_test.rb +131 -0
  34. data/test/controller/http_basic_authentication_test.rb +88 -0
  35. data/test/controller/http_digest_authentication_test.rb +178 -0
  36. data/test/controller/integration_test.rb +417 -0
  37. data/test/controller/layout_test.rb +204 -0
  38. data/test/controller/logging_test.rb +46 -0
  39. data/test/controller/middleware_stack_test.rb +90 -0
  40. data/test/controller/mime_responds_test.rb +536 -0
  41. data/test/controller/mime_type_test.rb +93 -0
  42. data/test/controller/polymorphic_routes_test.rb +293 -0
  43. data/test/controller/rack_test.rb +294 -0
  44. data/test/controller/record_identifier_test.rb +139 -0
  45. data/test/controller/redirect_test.rb +282 -0
  46. data/test/controller/render_test.rb +1752 -0
  47. data/test/controller/request/json_params_parsing_test.rb +45 -0
  48. data/test/controller/request/multipart_params_parsing_test.rb +223 -0
  49. data/test/controller/request/query_string_parsing_test.rb +120 -0
  50. data/test/controller/request/url_encoded_params_parsing_test.rb +184 -0
  51. data/test/controller/request/xml_params_parsing_test.rb +88 -0
  52. data/test/controller/request_forgery_protection_test.rb +246 -0
  53. data/test/controller/request_test.rb +407 -0
  54. data/test/controller/rescue_test.rb +536 -0
  55. data/test/controller/resources_test.rb +1341 -0
  56. data/test/controller/routing_test.rb +2557 -0
  57. data/test/controller/selector_test.rb +628 -0
  58. data/test/controller/send_file_test.rb +161 -0
  59. data/test/controller/session/cookie_store_test.rb +239 -0
  60. data/test/controller/session/mem_cache_store_test.rb +127 -0
  61. data/test/controller/session/test_session_test.rb +58 -0
  62. data/test/controller/test_test.rb +692 -0
  63. data/test/controller/translation_test.rb +26 -0
  64. data/test/controller/url_rewriter_test.rb +359 -0
  65. data/test/controller/verification_test.rb +270 -0
  66. data/test/controller/view_paths_test.rb +141 -0
  67. data/test/controller/webservice_test.rb +260 -0
  68. data/test/fixtures/alternate_helpers/foo_helper.rb +3 -0
  69. data/test/fixtures/company.rb +10 -0
  70. data/test/fixtures/developer.rb +9 -0
  71. data/test/fixtures/helpers/abc_helper.rb +5 -0
  72. data/test/fixtures/helpers/fun/games_helper.rb +3 -0
  73. data/test/fixtures/helpers/fun/pdf_helper.rb +3 -0
  74. data/test/fixtures/mascot.rb +3 -0
  75. data/test/fixtures/project.rb +3 -0
  76. data/test/fixtures/reply.rb +7 -0
  77. data/test/fixtures/topic.rb +3 -0
  78. data/test/template/asset_tag_helper_test.rb +713 -0
  79. data/test/template/atom_feed_helper_test.rb +286 -0
  80. data/test/template/benchmark_helper_test.rb +86 -0
  81. data/test/template/compiled_templates_test.rb +203 -0
  82. data/test/template/date_helper_i18n_test.rb +120 -0
  83. data/test/template/date_helper_test.rb +2469 -0
  84. data/test/template/erb_util_test.rb +24 -0
  85. data/test/template/form_helper_test.rb +1176 -0
  86. data/test/template/form_options_helper_test.rb +751 -0
  87. data/test/template/form_tag_helper_test.rb +327 -0
  88. data/test/template/javascript_helper_test.rb +106 -0
  89. data/test/template/number_helper_i18n_test.rb +69 -0
  90. data/test/template/number_helper_test.rb +128 -0
  91. data/test/template/prototype_helper_test.rb +639 -0
  92. data/test/template/record_tag_helper_test.rb +58 -0
  93. data/test/template/render_test.rb +291 -0
  94. data/test/template/sanitize_helper_test.rb +48 -0
  95. data/test/template/scriptaculous_helper_test.rb +90 -0
  96. data/test/template/tag_helper_test.rb +97 -0
  97. data/test/template/test_test.rb +54 -0
  98. data/test/template/text_helper_test.rb +520 -0
  99. data/test/template/translation_helper_test.rb +32 -0
  100. data/test/template/url_helper_test.rb +614 -0
  101. data/test/test_erubis_rails_helper.rb +4 -0
  102. data/test/testing_sandbox.rb +15 -0
  103. data/test/view/test_case_test.rb +8 -0
  104. metadata +293 -0
@@ -0,0 +1,66 @@
1
+ = erubis_rails_helper
2
+
3
+ * http://github.com/elkinsware/erubis_rails_helper/tree/master
4
+
5
+ == DESCRIPTION:
6
+
7
+ This is a fix for Erubis integration with Rails 2.3. It is a drop in replacement for the rails helper in the Erubis gem.
8
+
9
+ The code makes a few tweaks to the Erubis 2.6.4 Rails Helper along with the Generator class. The main issue with getting
10
+ Erubis and Rails 2.3 to work together is to replace "_buf" with "@output_buffer" in the generator code. Rails 2.3 relies on
11
+ for "@output_buffer" to be used in the generated code to make helpers like capture_helper.rb work properly.
12
+
13
+ == FEATURES/PROBLEMS:
14
+
15
+ * Drop in replacement for the Erubis Rails Helper in the Erubis gem.
16
+
17
+ * Using the tests from actionpack-2.3, this passes all but two tests currently. The two failures are because
18
+ there are two end of line characters instead of one end of line characters. I think that is none critical for
19
+ the moment.
20
+
21
+ == SYNOPSIS:
22
+
23
+ inside config/environment.rb and the following
24
+ config.gem 'erubis' , :version => '2.6.4'
25
+ config.gem 'elkinsware-erubis_rails_helper', :lib => 'erubis_rails_helper', :source => 'http://gems.github.com'
26
+
27
+ #you can customize some of the options for Erubis still if you want to by
28
+ #add config/initializers/erubis_config.rb
29
+ #Erubis::Helpers::RailsHelper.engine_class = Erubis::Eruby # or Erubis::FastEruby
30
+ #Erubis::Helpers::RailsHelper.init_properties = {}
31
+ Erubis::Helpers::RailsHelper.show_src = false
32
+ Erubis::Helpers::RailsHelper.preprocessing = true
33
+
34
+ == REQUIREMENTS:
35
+
36
+ * Rails 2.3
37
+ * Erubis 2.6.4
38
+
39
+ == INSTALL:
40
+
41
+ * sudo gem install elkinsware-erubis_rails_helper
42
+
43
+ == LICENSE:
44
+
45
+ (The MIT License)
46
+
47
+ Copyright (c) 2009 Dave Elkins (elkinsware)
48
+
49
+ Permission is hereby granted, free of charge, to any person obtaining
50
+ a copy of this software and associated documentation files (the
51
+ 'Software'), to deal in the Software without restriction, including
52
+ without limitation the rights to use, copy, modify, merge, publish,
53
+ distribute, sublicense, and/or sell copies of the Software, and to
54
+ permit persons to whom the Software is furnished to do so, subject to
55
+ the following conditions:
56
+
57
+ The above copyright notice and this permission notice shall be
58
+ included in all copies or substantial portions of the Software.
59
+
60
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
61
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
62
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
63
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
64
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
65
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
66
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ unless defined?(Rails) and defined?(ActionController)
2
+ $stderr.puts %[This erubis_rails requires actionpack 2.2.2 or higher]
3
+ end
4
+
5
+ begin
6
+ require 'erubis'
7
+ require 'erubis/preprocessing'
8
+ rescue LoadError
9
+ $stderr.puts %[This erubis_rails requires erubis 2.6.4\n
10
+ Add "config.gem 'erubis', :version => 2.6.4" to config/environment.rb]
11
+ end
12
+
13
+ require 'erubis_rails_helper/erubis/generator'
14
+ require 'erubis_rails_helper/template_handlers/erubis'
15
+
16
+ ## finish
17
+ $stdout.puts "** Erubis #{::Erubis::VERSION}"
@@ -0,0 +1,100 @@
1
+ ##
2
+ ## This is a copy of the generator.rb from the Erubis 2.6.4 gem
3
+ ## The modification I made was that you can substitute any variable name (i.e. @output_buffer) for _buf.
4
+ ## This is necessary for Erubis to work with Rails 2.3 and 2.2 because ActionView code like CaptureHelper
5
+ ## relies on @output_buffer to be used and not _buf to work correctly.
6
+ ##
7
+
8
+ ##
9
+ ## $Rev: 77 $
10
+ ## $Release: 2.6.4 $
11
+ ## copyright(c) 2006-2009 kuwata-lab.com all rights reserved.
12
+ ##
13
+
14
+ require 'erubis/engine'
15
+ require 'erubis/enhancer'
16
+
17
+
18
+ module Erubis
19
+
20
+
21
+ ##
22
+ ## code generator for Ruby
23
+ ##
24
+ module RubyGenerator
25
+ include Generator
26
+ #include ArrayBufferEnhancer
27
+ include StringBufferEnhancer
28
+
29
+ def init_generator(properties={})
30
+ super
31
+
32
+ @escapefunc ||= "Erubis::XmlHelper.escape_xml"
33
+
34
+ set_eoutvar(properties[:eoutvar] || '_buf')
35
+ end
36
+
37
+ def self.supported_properties() # :nodoc:
38
+ return []
39
+ end
40
+
41
+ def escape_text(text)
42
+ text.gsub(/['\\]/, '\\\\\&') # "'" => "\\'", '\\' => '\\\\'
43
+ end
44
+
45
+ def escaped_expr(code)
46
+ return "#{@escapefunc}(#{code})"
47
+ end
48
+
49
+ #--
50
+ #def add_preamble(src)
51
+ # src << "_buf = [];"
52
+ #end
53
+ #++
54
+
55
+ def add_text(src, text)
56
+ #src << " _buf << '" << escape_text(text) << "';" unless text.empty?
57
+ src << " #{eoutvar} << '" << escape_text(text) << "';" unless text.empty?
58
+ end
59
+
60
+ def add_stmt(src, code)
61
+ #src << code << ';'
62
+ src << code
63
+ src << ';' unless code[-1] == ?\n
64
+ end
65
+
66
+ def add_expr_literal(src, code)
67
+ #src << ' _buf << (' << code << ').to_s;'
68
+ src << " #{eoutvar} << (" << code << ").to_s;"
69
+ end
70
+
71
+ def add_expr_escaped(src, code)
72
+ #src << ' _buf << ' << escaped_expr(code) << ';'
73
+ src << " #{eoutvar} << " << escaped_expr(code) << ';'
74
+ end
75
+
76
+ def add_expr_debug(src, code)
77
+ code.strip!
78
+ s = (code.dump =~ /\A"(.*)"\z/) && $1
79
+ src << ' $stderr.puts("*** debug: ' << s << '=#{(' << code << ').inspect}");'
80
+ end
81
+
82
+ #--
83
+ #def add_postamble(src)
84
+ # src << "\n_buf.join\n"
85
+ #end
86
+ #++
87
+
88
+ private
89
+ ##
90
+ ## Added to set the buffer variable name. defaults to _buf.
91
+ ##
92
+ def set_eoutvar(new_eoutvar = '_buf')
93
+ @eoutvar = new_eoutvar
94
+ end
95
+
96
+ def eoutvar
97
+ @eoutvar || '_buf'
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,258 @@
1
+ module Erubis
2
+ ##
3
+ ## convert "<h1><%=title%></h1>" into "@output_buffer << %Q`<h1>#{title}</h1>`"
4
+ ##
5
+ ## this is only for Eruby.
6
+ ##
7
+ module InterpolationEnhancer
8
+
9
+ def self.desc # :nodoc:
10
+ "convert '<p><%=text%></p>' into '@output_buffer << %Q`<p>\#{text}</p>`'"
11
+ end
12
+
13
+ def convert_input(src, input)
14
+ pat = @pattern
15
+ regexp = pat.nil? || pat == '<% %>' ? Basic::Converter::DEFAULT_REGEXP : pattern_regexp(pat)
16
+ pos = 0
17
+ is_bol = true # is beginning of line
18
+ str = ''
19
+ input.scan(regexp) do |indicator, code, tailch, rspace|
20
+ match = Regexp.last_match()
21
+ len = match.begin(0) - pos
22
+ text = input[pos, len]
23
+ pos = match.end(0)
24
+ ch = indicator ? indicator[0] : nil
25
+ lspace = ch == ?= ? nil : detect_spaces_at_bol(text, is_bol)
26
+ is_bol = rspace ? true : false
27
+ _add_text_to_str(str, text)
28
+ ## * when '<%= %>', do nothing
29
+ ## * when '<% %>' or '<%# %>', delete spaces iff only spaces are around '<% %>'
30
+ if ch == ?= # <%= %>
31
+ rspace = nil if tailch && !tailch.empty?
32
+ str << lspace if lspace
33
+ add_expr(str, code, indicator)
34
+ str << rspace if rspace
35
+ elsif ch == ?\# # <%# %>
36
+ n = code.count("\n") + (rspace ? 1 : 0)
37
+ if @trim && lspace && rspace
38
+ add_text(src, str)
39
+ str = ''
40
+ add_stmt(src, "\n" * n)
41
+ else
42
+ str << lspace if lspace
43
+ add_text(src, str)
44
+ str = ''
45
+ add_stmt(src, "\n" * n)
46
+ str << rspace if rspace
47
+ end
48
+ else # <% %>
49
+ if @trim && lspace && rspace
50
+ add_text(src, str)
51
+ str = ''
52
+ add_stmt(src, "#{lspace}#{code}#{rspace}")
53
+ else
54
+ str << lspace if lspace
55
+ add_text(src, str)
56
+ str = ''
57
+ add_stmt(src, code)
58
+ str << rspace if rspace
59
+ end
60
+ end
61
+ end
62
+ #rest = $' || input # ruby1.8
63
+ rest = pos == 0 ? input : input[pos..-1] # ruby1.9
64
+ _add_text_to_str(str, rest)
65
+ add_text(src, str)
66
+ end
67
+
68
+ def add_text(src, text)
69
+ return if !text || text.empty?
70
+ #src << " _buf << %Q`" << text << "`;"
71
+ if text[-1] == ?\n
72
+ text[-1] = "\\n"
73
+ src << " @output_buffer << %Q`" << text << "`\n"
74
+ else
75
+ src << " @output_buffer << %Q`" << text << "`;"
76
+ end
77
+ end
78
+
79
+ def _add_text_to_str(str, text)
80
+ return if !text || text.empty?
81
+ text.gsub!(/['\#\\]/, '\\\\\&')
82
+ str << text
83
+ end
84
+
85
+ def add_expr_escaped(str, code)
86
+ str << "\#{#{escaped_expr(code)}}"
87
+ end
88
+
89
+ def add_expr_literal(str, code)
90
+ str << "\#{#{code}}"
91
+ end
92
+ end
93
+
94
+ module OutputBufferEnhancer
95
+ def self.desc # :nodoc:
96
+ "set '@output_buffer = _buf = \"\";'"
97
+ end
98
+
99
+ def add_preamble(src)
100
+ src << "@output_buffer = _buf = '';"
101
+ end
102
+
103
+ def add_postamble(src)
104
+ src << "\n" unless src[-1] == ?\n
105
+ src << "@output_buffer.to_s\n"
106
+ end
107
+ end
108
+
109
+ class Eruby
110
+ include ::Erubis::PercentLineEnhancer
111
+ include OutputBufferEnhancer
112
+ end
113
+
114
+ class FastEruby
115
+ include ::Erubis::PercentLineEnhancer
116
+ include OutputBufferEnhancer
117
+ end
118
+
119
+ module Helpers
120
+ ##
121
+ ## helper module for Ruby on Rails
122
+ ##
123
+ ## howto:
124
+ ##
125
+ ## 1. add the folliwng code in your 'config/environment.rb'
126
+ ##
127
+ ## require 'erubis/helpers/rails_helper'
128
+ ## #Erubis::Helpers::RailsHelper.engine_class = Erubis::Eruby # or Erubis::FastEruby
129
+ ## #Erubis::Helpers::RailsHelper.init_properties = {}
130
+ ## #Erubis::Helpers::RailsHelper.show_src = false # set true for debugging
131
+ ## #Erubis::Helpers::RailsHelper.preprocessing = true # set true to enable preprocessing
132
+ ##
133
+ ## 2. restart web server.
134
+ ##
135
+ ## if Erubis::Helper::Rails.show_src is true, Erubis prints converted Ruby code
136
+ ## into log file ('log/development.log' or so). if false, it doesn't.
137
+ ## if nil, Erubis prints converted Ruby code if ENV['RAILS_ENV'] == 'development'.
138
+ ##
139
+ module RailsHelper
140
+ #cattr_accessor :init_properties
141
+ @@engine_class = ::Erubis::Eruby
142
+ #@@engine_class = ::Erubis::FastEruby
143
+ def self.engine_class
144
+ @@engine_class
145
+ end
146
+ def self.engine_class=(klass)
147
+ @@engine_class = klass
148
+ end
149
+
150
+ #cattr_accessor :init_properties
151
+ @@init_properties = {}
152
+ def self.init_properties
153
+ @@init_properties
154
+ end
155
+ def self.init_properties=(hash)
156
+ @@init_properties = hash
157
+ end
158
+
159
+ #cattr_accessor :show_src
160
+ @@show_src = nil
161
+ def self.show_src
162
+ @@show_src
163
+ end
164
+ def self.show_src=(flag)
165
+ @@show_src = flag
166
+ end
167
+
168
+ #cattr_accessor :preprocessing
169
+ @@preprocessing = false
170
+ def self.preprocessing
171
+ @@preprocessing
172
+ end
173
+ def self.preprocessing=(flag)
174
+ @@preprocessing = flag
175
+ end
176
+
177
+ ## define class for backward-compatibility
178
+ class PreprocessingEruby < Erubis::PreprocessingEruby # :nodoc:
179
+ end
180
+
181
+ module TemplateConverter
182
+ def _convert_template(template) # :nodoc:
183
+
184
+ klass = ::Erubis::Helpers::RailsHelper.engine_class
185
+ properties = ::Erubis::Helpers::RailsHelper.init_properties || {}
186
+
187
+ if preprocess?
188
+ preprocessor = _create_preprocessor(template)
189
+ template = preprocessor.evaluate(_preprocessing_context_object())
190
+ end
191
+
192
+ src = klass.new(template, properties.merge(:eoutvar => "@output_buffer")).src
193
+ return src
194
+ end
195
+
196
+ def _create_preprocessor(template)
197
+ return PreprocessingEruby.new(template, :escape=>true)
198
+ end
199
+
200
+ def _preprocessing_context_object
201
+ return self
202
+ end
203
+
204
+ def preprocess?
205
+ ::Erubis::Helpers::RailsHelper.preprocessing
206
+ end
207
+ end
208
+ end
209
+ end
210
+ end
211
+
212
+ class ActionView::Base # :nodoc:
213
+ include ::Erubis::Helpers::RailsHelper::TemplateConverter
214
+ include ::Erubis::PreprocessingHelper
215
+
216
+ private
217
+ # convert template into ruby code
218
+ def convert_template_into_ruby_code(template)
219
+ #ERB.new(template, nil, @@erb_trim_mode).src
220
+ return _convert_template(template)
221
+ end
222
+ end
223
+
224
+ module ActionView
225
+ module TemplateHandlers
226
+ class Erubis < TemplateHandler
227
+ include Compilable
228
+ include ::Erubis::Helpers::RailsHelper::TemplateConverter
229
+ include ::Erubis::PreprocessingHelper
230
+
231
+ def compile(template)
232
+ src = _convert_template("<% __in_erb_template=true %>#{template.source}")
233
+
234
+ if show_source?
235
+ logger.debug("** Erubis: src==<<'END'\n#{src}END\n") if logger
236
+ end
237
+
238
+ # Ruby 1.9 prepends an encoding to the source. However this is
239
+ # useless because you can only set an encoding on the first line
240
+ RUBY_VERSION >= '1.9' ? src.sub(/\A#coding:.*\n/, '') : src
241
+ end
242
+
243
+ protected
244
+ def logger
245
+ @logger ||= ActionController::Base.new.logger
246
+ end
247
+
248
+ def show_source?
249
+ return ::Erubis::Helpers::RailsHelper.show_src if not ::Erubis::Helpers::RailsHelper.show_src.nil?
250
+ ENV['RAILS_ENV'] == 'development' if ::Erubis::Helpers::RailsHelper.show_src.nil?
251
+ end
252
+ end
253
+
254
+ handler_klass = TemplateHandlers::Erubis
255
+ Template.register_default_template_handler(:erb, handler_klass)
256
+ Template.register_template_handler(:rhtml, handler_klass)
257
+ end
258
+ end
@@ -0,0 +1,51 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
2
+ #$:.unshift(File.dirname(__FILE__) + '/../../activesupport/lib')
3
+ $:.unshift(File.dirname(__FILE__) + '/fixtures/helpers')
4
+ $:.unshift(File.dirname(__FILE__) + '/fixtures/alternate_helpers')
5
+
6
+ require 'rubygems'
7
+ require 'yaml'
8
+ require 'stringio'
9
+ require 'test/unit'
10
+
11
+ gem 'mocha', '>= 0.9.5'
12
+ require 'mocha'
13
+
14
+ begin
15
+ require 'ruby-debug'
16
+ Debugger.settings[:autoeval] = true
17
+ Debugger.start
18
+ rescue LoadError
19
+ # Debugging disabled. `gem install ruby-debug` to enable.
20
+ end
21
+
22
+ require 'action_controller'
23
+ require 'action_controller/cgi_ext'
24
+ require 'action_controller/test_process'
25
+ require 'action_view/test_case'
26
+
27
+ #puts "#{File.dirname(__FILE__) + '/../lib/erubis_rails_helper'}\n"
28
+ #require File.dirname(__FILE__) + '/../lib/erubis_rails_helper'
29
+
30
+ require 'erubis'
31
+ require 'erubis_rails_helper'
32
+
33
+ # Show backtraces for deprecated behavior for quicker cleanup.
34
+ ActiveSupport::Deprecation.debug = true
35
+
36
+ ActionController::Base.logger = nil
37
+ ActionController::Routing::Routes.reload rescue nil
38
+
39
+ ActionController::Base.session_store = nil
40
+
41
+ # Register danish language for testing
42
+ I18n.backend.store_translations 'da', {}
43
+ I18n.backend.store_translations 'pt-BR', {}
44
+ ORIGINAL_LOCALES = I18n.available_locales.map(&:to_s).sort
45
+
46
+ FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
47
+ ActionView::Base.cache_template_loading = true
48
+ ActionController::Base.view_paths = FIXTURE_LOAD_PATH
49
+ CACHED_VIEW_PATHS = ActionView::Base.cache_template_loading? ?
50
+ ActionController::Base.view_paths :
51
+ ActionController::Base.view_paths.map {|path| ActionView::Template::EagerPath.new(path.to_s)}