sprockets-rails 0.0.1 → 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 (48) hide show
  1. data/MIT-LICENSE +1 -1
  2. data/README.rdoc +3 -0
  3. data/Rakefile +15 -31
  4. data/lib/sprockets/rails/bootstrap.rb +41 -0
  5. data/lib/sprockets/rails/compressors.rb +87 -0
  6. data/lib/sprockets/rails/helpers/isolated_helper.rb +15 -0
  7. data/lib/sprockets/rails/helpers/rails_helper.rb +169 -0
  8. data/lib/sprockets/rails/helpers.rb +8 -0
  9. data/lib/sprockets/rails/railtie.rb +64 -0
  10. data/lib/sprockets/rails/static_compiler.rb +64 -0
  11. data/lib/sprockets/rails/version.rb +5 -0
  12. data/lib/sprockets-rails.rb +5 -6
  13. data/lib/tasks/assets.rake +105 -0
  14. data/test/abstract_unit.rb +145 -0
  15. data/test/assets_debugging_test.rb +65 -0
  16. data/test/assets_test.rb +532 -0
  17. data/test/fixtures/alternate/stylesheets/style.css +1 -0
  18. data/{generators/sprockets_rails/templates/application.js → test/fixtures/app/fonts/dir/font.ttf} +0 -0
  19. data/test/fixtures/app/fonts/font.ttf +0 -0
  20. data/test/fixtures/app/images/logo.png +0 -0
  21. data/test/fixtures/app/javascripts/application.js +1 -0
  22. data/test/fixtures/app/javascripts/dir/xmlhr.js +0 -0
  23. data/test/fixtures/app/javascripts/extra.js +0 -0
  24. data/test/fixtures/app/javascripts/xmlhr.js +0 -0
  25. data/test/fixtures/app/stylesheets/application.css +1 -0
  26. data/test/fixtures/app/stylesheets/dir/style.css +0 -0
  27. data/test/fixtures/app/stylesheets/extra.css +0 -0
  28. data/test/fixtures/app/stylesheets/style.css +0 -0
  29. data/test/sprockets_compressors_test.rb +27 -0
  30. data/test/sprockets_helper_test.rb +345 -0
  31. data/test/sprockets_helper_with_routes_test.rb +60 -0
  32. data/test/test_helper.rb +84 -0
  33. metadata +116 -65
  34. data/.gitignore +0 -5
  35. data/README.textile +0 -91
  36. data/VERSION +0 -1
  37. data/config/sprockets.yml +0 -10
  38. data/generators/sprockets_rails/sprockets_rails_generator.rb +0 -13
  39. data/init.rb +0 -1
  40. data/install.rb +0 -13
  41. data/lib/sprocket.rb +0 -74
  42. data/lib/sprockets_application.rb +0 -8
  43. data/lib/sprockets_controller.rb +0 -12
  44. data/lib/sprockets_helper.rb +0 -9
  45. data/recipes/sprockets_tasks.rb +0 -17
  46. data/sprockets-rails.gemspec +0 -60
  47. data/tasks/sprockets_tasks.rake +0 -27
  48. data/test/sprockets_test.rb +0 -8
@@ -0,0 +1,345 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/test_helper")
2
+
3
+ class SprocketsHelperTest < ActiveSupport::TestCase
4
+ include Sprockets::Rails::Helpers::RailsHelper
5
+
6
+ attr_accessor :assets, :controller, :params
7
+
8
+ class MockRequest
9
+ def protocol() 'http://' end
10
+ def ssl?() false end
11
+ def host_with_port() 'localhost' end
12
+ def script_name() nil end
13
+ end
14
+
15
+ def setup
16
+ @controller = BasicController.new
17
+ @controller.request = MockRequest.new
18
+
19
+ @assets = Sprockets::Environment.new
20
+ @assets.append_path(FIXTURES.join("app/javascripts"))
21
+ @assets.append_path(FIXTURES.join("app/stylesheets"))
22
+ @assets.append_path(FIXTURES.join("app/images"))
23
+ @assets.append_path(FIXTURES.join("app/fonts"))
24
+
25
+ application = Struct.new(:config, :assets).new(config, @assets)
26
+ ::Rails.stubs(:application).returns(application)
27
+ @config = config
28
+ @config.perform_caching = true
29
+ @config.assets.digest = true
30
+ @config.assets.compile = true
31
+ @params = {}
32
+ end
33
+
34
+ def url_for(*args)
35
+ "http://www.example.com"
36
+ end
37
+
38
+ def config
39
+ @controller ? @controller.config : @config
40
+ end
41
+
42
+ def compute_host(source, request, options = {})
43
+ raise "Should never get here"
44
+ end
45
+
46
+ test "asset_path" do
47
+ assert_match %r{/assets/logo-[0-9a-f]+.png},
48
+ asset_path("logo.png")
49
+ assert_match %r{/assets/logo-[0-9a-f]+.png},
50
+ asset_path("logo.png", :digest => true)
51
+ assert_match %r{/assets/logo.png},
52
+ asset_path("logo.png", :digest => false)
53
+ end
54
+
55
+ test "custom_asset_path" do
56
+ @config.assets.prefix = '/s'
57
+ assert_match %r{/s/logo-[0-9a-f]+.png},
58
+ asset_path("logo.png")
59
+ assert_match %r{/s/logo-[0-9a-f]+.png},
60
+ asset_path("logo.png", :digest => true)
61
+ assert_match %r{/s/logo.png},
62
+ asset_path("logo.png", :digest => false)
63
+ end
64
+
65
+ test "asset_path with root relative assets" do
66
+ assert_equal "/images/logo",
67
+ asset_path("/images/logo")
68
+ assert_equal "/images/logo.gif",
69
+ asset_path("/images/logo.gif")
70
+
71
+ assert_equal "/dir/audio",
72
+ asset_path("/dir/audio")
73
+ end
74
+
75
+ test "asset_path with absolute urls" do
76
+ assert_equal "http://www.example.com/video/play",
77
+ asset_path("http://www.example.com/video/play")
78
+ assert_equal "http://www.example.com/video/play.mp4",
79
+ asset_path("http://www.example.com/video/play.mp4")
80
+ end
81
+
82
+ test "with a simple asset host the url should default to protocol relative" do
83
+ @controller.config.default_asset_host_protocol = :relative
84
+ @controller.config.asset_host = "assets-%d.example.com"
85
+ assert_match %r{^//assets-\d.example.com/assets/logo-[0-9a-f]+.png},
86
+ asset_path("logo.png")
87
+ end
88
+
89
+ test "with a simple asset host the url can be changed to use the request protocol" do
90
+ @controller.config.asset_host = "assets-%d.example.com"
91
+ @controller.config.default_asset_host_protocol = :request
92
+ assert_match %r{http://assets-\d.example.com/assets/logo-[0-9a-f]+.png},
93
+ asset_path("logo.png")
94
+ end
95
+
96
+ test "With a proc asset host that returns no protocol the url should be protocol relative" do
97
+ @controller.config.default_asset_host_protocol = :relative
98
+ @controller.config.asset_host = Proc.new do |asset|
99
+ "assets-999.example.com"
100
+ end
101
+ assert_match %r{^//assets-999.example.com/assets/logo-[0-9a-f]+.png},
102
+ asset_path("logo.png")
103
+ end
104
+
105
+ test "with a proc asset host that returns a protocol the url use it" do
106
+ @controller.config.asset_host = Proc.new do |asset|
107
+ "http://assets-999.example.com"
108
+ end
109
+ assert_match %r{http://assets-999.example.com/assets/logo-[0-9a-f]+.png},
110
+ asset_path("logo.png")
111
+ end
112
+
113
+ test "stylesheets served with a controller in scope can access the request" do
114
+ config.asset_host = Proc.new do |asset, request|
115
+ assert_not_nil request
116
+ "http://assets-666.example.com"
117
+ end
118
+ assert_match %r{http://assets-666.example.com/assets/logo-[0-9a-f]+.png},
119
+ asset_path("logo.png")
120
+ end
121
+
122
+ test "stylesheets served without a controller in scope cannot access the request" do
123
+ @controller = nil
124
+ @config.asset_host = Proc.new do |asset, request|
125
+ fail "This should not have been called."
126
+ end
127
+ assert_raises ActionController::RoutingError do
128
+ asset_path("logo.png")
129
+ end
130
+ @config.asset_host = method :compute_host
131
+ assert_raises ActionController::RoutingError do
132
+ asset_path("logo.png")
133
+ end
134
+ end
135
+
136
+ test "image_tag" do
137
+ assert_dom_equal '<img alt="Xml" src="/assets/xml.png" />', image_tag("xml.png")
138
+ end
139
+
140
+ test "image_path" do
141
+ assert_match %r{/assets/logo-[0-9a-f]+.png},
142
+ image_path("logo.png")
143
+
144
+ assert_match %r{/assets/logo-[0-9a-f]+.png},
145
+ path_to_image("logo.png")
146
+ end
147
+
148
+ test "font_path" do
149
+ assert_match %r{/assets/font-[0-9a-f]+.ttf},
150
+ font_path("font.ttf")
151
+
152
+ assert_match %r{/assets/font-[0-9a-f]+.ttf},
153
+ path_to_font("font.ttf")
154
+ end
155
+
156
+ test "javascript_path" do
157
+ assert_match %r{/assets/application-[0-9a-f]+.js},
158
+ javascript_path("application")
159
+
160
+ assert_match %r{/assets/application-[0-9a-f]+.js},
161
+ javascript_path("application.js")
162
+
163
+ assert_match %r{/assets/application-[0-9a-f]+.js},
164
+ path_to_javascript("application.js")
165
+ end
166
+
167
+ test "stylesheet_path" do
168
+ assert_match %r{/assets/application-[0-9a-f]+.css},
169
+ stylesheet_path("application")
170
+
171
+ assert_match %r{/assets/application-[0-9a-f]+.css},
172
+ stylesheet_path("application.css")
173
+
174
+ assert_match %r{/assets/application-[0-9a-f]+.css},
175
+ path_to_stylesheet("application.css")
176
+ end
177
+
178
+ test "stylesheets served without a controller in do not use asset hosts when the default protocol is :request" do
179
+ @controller = nil
180
+ @config.asset_host = "assets-%d.example.com"
181
+ @config.default_asset_host_protocol = :request
182
+ @config.perform_caching = true
183
+
184
+ assert_match %r{/assets/logo-[0-9a-f]+.png},
185
+ asset_path("logo.png")
186
+ end
187
+
188
+ test "asset path with relative url root" do
189
+ @controller.config.relative_url_root = "/collaboration/hieraki"
190
+ assert_equal "/collaboration/hieraki/images/logo.gif",
191
+ asset_path("/images/logo.gif")
192
+ end
193
+
194
+ test "asset path with relative url root when controller isn't present but relative_url_root is" do
195
+ @controller = nil
196
+ @config.relative_url_root = "/collaboration/hieraki"
197
+ assert_equal "/collaboration/hieraki/images/logo.gif",
198
+ asset_path("/images/logo.gif")
199
+ end
200
+
201
+ test "font path through asset_path" do
202
+ assert_match %r{/assets/font-[0-9a-f]+.ttf},
203
+ asset_path('font.ttf')
204
+
205
+ assert_match %r{/assets/dir/font-[0-9a-f]+.ttf},
206
+ asset_path("dir/font.ttf")
207
+
208
+ assert_equal "http://www.example.com/fonts/font.ttf",
209
+ asset_path("http://www.example.com/fonts/font.ttf")
210
+ end
211
+
212
+ test "javascript path through asset_path" do
213
+ assert_match %r{/assets/application-[0-9a-f]+.js},
214
+ asset_path(:application, :ext => "js")
215
+
216
+ assert_match %r{/assets/xmlhr-[0-9a-f]+.js},
217
+ asset_path("xmlhr", :ext => "js")
218
+ assert_match %r{/assets/dir/xmlhr-[0-9a-f]+.js},
219
+ asset_path("dir/xmlhr.js", :ext => "js")
220
+
221
+ assert_equal "/dir/xmlhr.js",
222
+ asset_path("/dir/xmlhr", :ext => "js")
223
+
224
+ assert_equal "http://www.example.com/js/xmlhr",
225
+ asset_path("http://www.example.com/js/xmlhr", :ext => "js")
226
+ assert_equal "http://www.example.com/js/xmlhr.js",
227
+ asset_path("http://www.example.com/js/xmlhr.js", :ext => "js")
228
+ end
229
+
230
+ test "javascript include tag" do
231
+ assert_match %r{<script src="/assets/application-[0-9a-f]+.js" type="text/javascript"></script>},
232
+ javascript_include_tag(:application)
233
+ assert_match %r{<script src="/assets/application-[0-9a-f]+.js" type="text/javascript"></script>},
234
+ javascript_include_tag(:application, :digest => true)
235
+ assert_match %r{<script src="/assets/application.js" type="text/javascript"></script>},
236
+ javascript_include_tag(:application, :digest => false)
237
+
238
+ assert_match %r{<script src="/assets/xmlhr-[0-9a-f]+.js" type="text/javascript"></script>},
239
+ javascript_include_tag("xmlhr")
240
+ assert_match %r{<script src="/assets/xmlhr-[0-9a-f]+.js" type="text/javascript"></script>},
241
+ javascript_include_tag("xmlhr.js")
242
+ assert_equal '<script src="http://www.example.com/xmlhr" type="text/javascript"></script>',
243
+ javascript_include_tag("http://www.example.com/xmlhr")
244
+
245
+ assert_match %r{<script src=\"/assets/xmlhr-[0-9a-f]+.js" type=\"text/javascript\"></script>\n<script src=\"/assets/extra-[0-9a-f]+.js" type=\"text/javascript\"></script>},
246
+ javascript_include_tag("xmlhr", "extra")
247
+
248
+ assert_match %r{<script src="/assets/xmlhr-[0-9a-f]+.js\?body=1" type="text/javascript"></script>\n<script src="/assets/application-[0-9a-f]+.js\?body=1" type="text/javascript"></script>},
249
+ javascript_include_tag(:application, :debug => true)
250
+
251
+ assert_match %r{<script src="/assets/jquery.plugin.js" type="text/javascript"></script>},
252
+ javascript_include_tag('jquery.plugin', :digest => false)
253
+
254
+ @config.assets.compile = true
255
+ @config.assets.debug = true
256
+ assert_match %r{<script src="/javascripts/application.js" type="text/javascript"></script>},
257
+ javascript_include_tag('/javascripts/application')
258
+ assert_match %r{<script src="/assets/xmlhr-[0-9a-f]+.js\?body=1" type="text/javascript"></script>\n<script src="/assets/application-[0-9a-f]+.js\?body=1" type="text/javascript"></script>},
259
+ javascript_include_tag(:application)
260
+ end
261
+
262
+ test "stylesheet path through asset_path" do
263
+ assert_match %r{/assets/application-[0-9a-f]+.css}, asset_path(:application, :ext => "css")
264
+
265
+ assert_match %r{/assets/style-[0-9a-f]+.css}, asset_path("style", :ext => "css")
266
+ assert_match %r{/assets/dir/style-[0-9a-f]+.css}, asset_path("dir/style.css", :ext => "css")
267
+ assert_equal "/dir/style.css", asset_path("/dir/style.css", :ext => "css")
268
+
269
+ assert_equal "http://www.example.com/css/style",
270
+ asset_path("http://www.example.com/css/style", :ext => "css")
271
+ assert_equal "http://www.example.com/css/style.css",
272
+ asset_path("http://www.example.com/css/style.css", :ext => "css")
273
+ end
274
+
275
+ test "stylesheet link tag" do
276
+ assert_match %r{<link href="/assets/application-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />},
277
+ stylesheet_link_tag(:application)
278
+ assert_match %r{<link href="/assets/application-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />},
279
+ stylesheet_link_tag(:application, :digest => true)
280
+ assert_match %r{<link href="/assets/application.css" media="screen" rel="stylesheet" type="text/css" />},
281
+ stylesheet_link_tag(:application, :digest => false)
282
+
283
+ assert_match %r{<link href="/assets/style-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />},
284
+ stylesheet_link_tag("style")
285
+ assert_match %r{<link href="/assets/style-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />},
286
+ stylesheet_link_tag("style.css")
287
+
288
+ assert_equal '<link href="http://www.example.com/style.css" media="screen" rel="stylesheet" type="text/css" />',
289
+ stylesheet_link_tag("http://www.example.com/style.css")
290
+ assert_match %r{<link href="/assets/style-[0-9a-f]+.css" media="all" rel="stylesheet" type="text/css" />},
291
+ stylesheet_link_tag("style", :media => "all")
292
+ assert_match %r{<link href="/assets/style-[0-9a-f]+.css" media="print" rel="stylesheet" type="text/css" />},
293
+ stylesheet_link_tag("style", :media => "print")
294
+
295
+ assert_match %r{<link href="/assets/style-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />\n<link href="/assets/extra-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />},
296
+ stylesheet_link_tag("style", "extra")
297
+
298
+ assert_match %r{<link href="/assets/style-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />\n<link href="/assets/application-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />},
299
+ stylesheet_link_tag(:application, :debug => true)
300
+
301
+ @config.assets.compile = true
302
+ @config.assets.debug = true
303
+ assert_match %r{<link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css" />},
304
+ stylesheet_link_tag('/stylesheets/application')
305
+
306
+ assert_match %r{<link href="/assets/style-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />\n<link href="/assets/application-[0-9a-f]+.css\?body=1" media="screen" rel="stylesheet" type="text/css" />},
307
+ stylesheet_link_tag(:application)
308
+
309
+ assert_match %r{<link href="/assets/style-[0-9a-f]+.css\?body=1" media="print" rel="stylesheet" type="text/css" />\n<link href="/assets/application-[0-9a-f]+.css\?body=1" media="print" rel="stylesheet" type="text/css" />},
310
+ stylesheet_link_tag(:application, :media => "print")
311
+ end
312
+
313
+ test "alternate asset prefix" do
314
+ stubs(:asset_prefix).returns("/themes/test")
315
+ assert_match %r{/themes/test/style-[0-9a-f]+.css}, asset_path("style", :ext => "css")
316
+ end
317
+
318
+ test "alternate asset environment" do
319
+ assets = Sprockets::Environment.new
320
+ assets.append_path(FIXTURES.join("alternate/stylesheets"))
321
+ stubs(:asset_environment).returns(assets)
322
+ assert_match %r{/assets/style-[0-9a-f]+.css}, asset_path("style", :ext => "css")
323
+ end
324
+
325
+ test "alternate hash based on environment" do
326
+ assets = Sprockets::Environment.new
327
+ assets.version = 'development'
328
+ assets.append_path(FIXTURES.join("alternate/stylesheets"))
329
+ stubs(:asset_environment).returns(assets)
330
+ dev_path = asset_path("style", :ext => "css")
331
+
332
+ assets.version = 'production'
333
+ prod_path = asset_path("style", :ext => "css")
334
+
335
+ assert_not_equal prod_path, dev_path
336
+ end
337
+
338
+ test "precedence of `config.digest = false` over manifest.yml asset digests" do
339
+ Rails.application.config.assets.digests = {'logo.png' => 'logo-d1g3st.png'}
340
+ @config.assets.digest = false
341
+
342
+ assert_equal '/assets/logo.png',
343
+ asset_path("logo.png")
344
+ end
345
+ end
@@ -0,0 +1,60 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/test_helper")
2
+
3
+ class SprocketsHelperWithRoutesTest < ActiveSupport::TestCase
4
+ include Sprockets::Rails::Helpers::RailsHelper
5
+
6
+ attr_accessor :controller, :params
7
+
8
+ # Let's bring in some named routes to test namespace conflicts with potential *_paths.
9
+ # We have to do this after we bring in the Sprockets RailsHelper so if there are conflicts,
10
+ # they'll fail in the way we expect in a real live Rails app.
11
+ routes = ActionDispatch::Routing::RouteSet.new
12
+ routes.draw do
13
+ resources :assets
14
+ end
15
+ include routes.url_helpers
16
+
17
+ def setup
18
+ @controller = BasicController.new
19
+
20
+ @assets = Sprockets::Environment.new
21
+ @assets.append_path(FIXTURES.join("app/javascripts"))
22
+ @assets.append_path(FIXTURES.join("app/stylesheets"))
23
+ @assets.append_path(FIXTURES.join("app/images"))
24
+
25
+ application = Struct.new(:config, :assets).new(config, @assets)
26
+ ::Rails.stubs(:application).returns(application)
27
+ @config = config
28
+ @config.perform_caching = true
29
+ @config.assets.digest = true
30
+ @config.assets.compile = true
31
+ @params = {}
32
+ end
33
+
34
+ def config
35
+ @controller ? @controller.config : @config
36
+ end
37
+
38
+ test "namespace conflicts on a named route called asset_path" do
39
+ # Testing this for sanity - asset_path is now a named route!
40
+ assert_equal asset_path('test_asset'), '/assets/test_asset'
41
+
42
+ assert_match %r{/assets/logo-[0-9a-f]+.png},
43
+ path_to_asset("logo.png")
44
+ assert_match %r{/assets/logo-[0-9a-f]+.png},
45
+ path_to_asset("logo.png", :digest => true)
46
+ assert_match %r{/assets/logo.png},
47
+ path_to_asset("logo.png", :digest => false)
48
+ end
49
+
50
+ test "javascript_include_tag with a named_route named asset_path" do
51
+ assert_match %r{<script src="/assets/application-[0-9a-f]+.js" type="text/javascript"></script>},
52
+ javascript_include_tag(:application)
53
+ end
54
+
55
+ test "stylesheet_link_tag with a named_route named asset_path" do
56
+ assert_match %r{<link href="/assets/application-[0-9a-f]+.css" media="screen" rel="stylesheet" type="text/css" />},
57
+ stylesheet_link_tag(:application)
58
+ end
59
+
60
+ end
@@ -0,0 +1,84 @@
1
+ lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
2
+ $:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
3
+
4
+ require 'minitest/autorun'
5
+ require 'sprockets-rails'
6
+ require 'action_controller'
7
+ require 'mocha'
8
+ require 'active_support/dependencies'
9
+ require 'action_controller/vendor/html-scanner'
10
+
11
+ FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
12
+ FIXTURES = Pathname.new(FIXTURE_LOAD_PATH)
13
+
14
+ module Rails
15
+ class << self
16
+ def env
17
+ @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "test")
18
+ end
19
+ end
20
+ end
21
+
22
+ ActiveSupport::Dependencies.hook!
23
+
24
+ module SetupOnce
25
+ extend ActiveSupport::Concern
26
+
27
+ included do
28
+ cattr_accessor :setup_once_block
29
+ self.setup_once_block = nil
30
+
31
+ setup :run_setup_once
32
+ end
33
+
34
+ module ClassMethods
35
+ def setup_once(&block)
36
+ self.setup_once_block = block
37
+ end
38
+ end
39
+
40
+ private
41
+ def run_setup_once
42
+ if self.setup_once_block
43
+ self.setup_once_block.call
44
+ self.setup_once_block = nil
45
+ end
46
+ end
47
+ end
48
+
49
+ SharedTestRoutes = ActionDispatch::Routing::RouteSet.new
50
+
51
+ module ActiveSupport
52
+ class TestCase
53
+ include SetupOnce
54
+ # Hold off drawing routes until all the possible controller classes
55
+ # have been loaded.
56
+ setup_once do
57
+ SharedTestRoutes.draw do
58
+ match ':controller(/:action)'
59
+ end
60
+ end
61
+
62
+ def assert_dom_equal(expected, actual, message = "")
63
+ expected_dom = HTML::Document.new(expected).root
64
+ actual_dom = HTML::Document.new(actual).root
65
+ assert_equal expected_dom, actual_dom
66
+ end
67
+ end
68
+ end
69
+
70
+ class BasicController
71
+ attr_accessor :request
72
+
73
+ def config
74
+ @config ||= ActiveSupport::InheritableOptions.new(ActionController::Base.config).tap do |config|
75
+ # VIEW TODO: View tests should not require a controller
76
+ public_dir = File.expand_path("../fixtures/public", __FILE__)
77
+ config.assets_dir = public_dir
78
+ config.javascripts_dir = "#{public_dir}/javascripts"
79
+ config.stylesheets_dir = "#{public_dir}/stylesheets"
80
+ config.assets = ActiveSupport::InheritableOptions.new({ :prefix => "assets" })
81
+ config
82
+ end
83
+ end
84
+ end