turbo-sprockets-rails3 0.1.4 → 0.1.5

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.
@@ -0,0 +1,358 @@
1
+ # bust gem prelude
2
+ require 'rubygems' unless defined? Gem
3
+ require 'bundler'
4
+ Bundler.setup
5
+
6
+ lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
7
+ $:.unshift(lib) unless $:.include?('lib') || $:.include?(lib)
8
+
9
+ activemodel_path = File.expand_path('../../../activemodel/lib', __FILE__)
10
+ $:.unshift(activemodel_path) if File.directory?(activemodel_path) && !$:.include?(activemodel_path)
11
+
12
+ $:.unshift(File.dirname(__FILE__) + '/lib')
13
+ $:.unshift(File.dirname(__FILE__) + '/fixtures/helpers')
14
+ $:.unshift(File.dirname(__FILE__) + '/fixtures/alternate_helpers')
15
+
16
+ ENV['TMPDIR'] = File.join(File.dirname(__FILE__), 'tmp')
17
+
18
+ require 'active_support/core_ext/kernel/reporting'
19
+
20
+ require 'active_support/core_ext/string/encoding'
21
+ if "ruby".encoding_aware?
22
+ # These are the normal settings that will be set up by Railties
23
+ # TODO: Have these tests support other combinations of these values
24
+ silence_warnings do
25
+ Encoding.default_internal = "UTF-8"
26
+ Encoding.default_external = "UTF-8"
27
+ end
28
+ end
29
+
30
+ require 'test/unit'
31
+ require 'abstract_controller'
32
+ require 'action_controller'
33
+ require 'action_view'
34
+ require 'action_view/testing/resolvers'
35
+ require 'action_dispatch'
36
+ require 'active_support/dependencies'
37
+ require 'active_model'
38
+ require 'active_record'
39
+ require 'action_controller/caching'
40
+ require 'action_controller/caching/sweeping'
41
+
42
+ require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late
43
+
44
+ module Rails
45
+ class << self
46
+ def env
47
+ @_env ||= ActiveSupport::StringInquirer.new(ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "test")
48
+ end
49
+ end
50
+ end
51
+
52
+ ActiveSupport::Dependencies.hook!
53
+
54
+ # Show backtraces for deprecated behavior for quicker cleanup.
55
+ ActiveSupport::Deprecation.debug = true
56
+
57
+ # Register danish language for testing
58
+ I18n.backend.store_translations 'da', {}
59
+ I18n.backend.store_translations 'pt-BR', {}
60
+ ORIGINAL_LOCALES = I18n.available_locales.map {|locale| locale.to_s }.sort
61
+
62
+ FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
63
+ FIXTURES = Pathname.new(FIXTURE_LOAD_PATH)
64
+
65
+ module RackTestUtils
66
+ def body_to_string(body)
67
+ if body.respond_to?(:each)
68
+ str = ""
69
+ body.each {|s| str << s }
70
+ str
71
+ else
72
+ body
73
+ end
74
+ end
75
+ extend self
76
+ end
77
+
78
+ module RenderERBUtils
79
+ def view
80
+ @view ||= begin
81
+ path = ActionView::FileSystemResolver.new(FIXTURE_LOAD_PATH)
82
+ view_paths = ActionView::PathSet.new([path])
83
+ ActionView::Base.new(view_paths)
84
+ end
85
+ end
86
+
87
+ def render_erb(string)
88
+ @virtual_path = nil
89
+
90
+ template = ActionView::Template.new(
91
+ string.strip,
92
+ "test template",
93
+ ActionView::Template::Handlers::ERB,
94
+ {})
95
+
96
+ template.render(self, {}).strip
97
+ end
98
+ end
99
+
100
+ module SetupOnce
101
+ extend ActiveSupport::Concern
102
+
103
+ included do
104
+ cattr_accessor :setup_once_block
105
+ self.setup_once_block = nil
106
+
107
+ setup :run_setup_once
108
+ end
109
+
110
+ module ClassMethods
111
+ def setup_once(&block)
112
+ self.setup_once_block = block
113
+ end
114
+ end
115
+
116
+ private
117
+ def run_setup_once
118
+ if self.setup_once_block
119
+ self.setup_once_block.call
120
+ self.setup_once_block = nil
121
+ end
122
+ end
123
+ end
124
+
125
+ SharedTestRoutes = ActionDispatch::Routing::RouteSet.new
126
+
127
+ module ActiveSupport
128
+ class TestCase
129
+ include SetupOnce
130
+ # Hold off drawing routes until all the possible controller classes
131
+ # have been loaded.
132
+ setup_once do
133
+ SharedTestRoutes.draw do
134
+ match ':controller(/:action)'
135
+ end
136
+
137
+ ActionDispatch::IntegrationTest.app.routes.draw do
138
+ match ':controller(/:action)'
139
+ end
140
+ end
141
+ end
142
+ end
143
+
144
+ class RoutedRackApp
145
+ attr_reader :routes
146
+
147
+ def initialize(routes, &blk)
148
+ @routes = routes
149
+ @stack = ActionDispatch::MiddlewareStack.new(&blk).build(@routes)
150
+ end
151
+
152
+ def call(env)
153
+ @stack.call(env)
154
+ end
155
+ end
156
+
157
+ class BasicController
158
+ attr_accessor :request
159
+
160
+ def config
161
+ @config ||= ActiveSupport::InheritableOptions.new(ActionController::Base.config).tap do |config|
162
+ # VIEW TODO: View tests should not require a controller
163
+ fixtures_dir = File.expand_path("../fixtures", __FILE__)
164
+ config.assets_dir = fixtures_dir
165
+ config.javascripts_dir = "#{fixtures_dir}/javascripts"
166
+ config.stylesheets_dir = "#{fixtures_dir}/stylesheets"
167
+ config.assets = ActiveSupport::InheritableOptions.new({ :prefix => "assets" })
168
+ config
169
+ end
170
+ end
171
+ end
172
+
173
+ class ActionDispatch::IntegrationTest < ActiveSupport::TestCase
174
+ setup do
175
+ @routes = SharedTestRoutes
176
+ end
177
+
178
+ def self.build_app(routes = nil)
179
+ RoutedRackApp.new(routes || ActionDispatch::Routing::RouteSet.new) do |middleware|
180
+ middleware.use "ActionDispatch::ShowExceptions", ActionDispatch::PublicExceptions.new("#{FIXTURE_LOAD_PATH}/public")
181
+ middleware.use "ActionDispatch::DebugExceptions"
182
+ middleware.use "ActionDispatch::Callbacks"
183
+ middleware.use "ActionDispatch::ParamsParser"
184
+ middleware.use "ActionDispatch::Cookies"
185
+ middleware.use "ActionDispatch::Flash"
186
+ middleware.use "ActionDispatch::Head"
187
+ yield(middleware) if block_given?
188
+ end
189
+ end
190
+
191
+ self.app = build_app
192
+
193
+ # Stub Rails dispatcher so it does not get controller references and
194
+ # simply return the controller#action as Rack::Body.
195
+ class StubDispatcher < ::ActionDispatch::Routing::RouteSet::Dispatcher
196
+ protected
197
+ def controller_reference(controller_param)
198
+ controller_param
199
+ end
200
+
201
+ def dispatch(controller, action, env)
202
+ [200, {'Content-Type' => 'text/html'}, ["#{controller}##{action}"]]
203
+ end
204
+ end
205
+
206
+ def self.stub_controllers
207
+ old_dispatcher = ActionDispatch::Routing::RouteSet::Dispatcher
208
+ ActionDispatch::Routing::RouteSet.module_eval { remove_const :Dispatcher }
209
+ ActionDispatch::Routing::RouteSet.module_eval { const_set :Dispatcher, StubDispatcher }
210
+ yield ActionDispatch::Routing::RouteSet.new
211
+ ensure
212
+ ActionDispatch::Routing::RouteSet.module_eval { remove_const :Dispatcher }
213
+ ActionDispatch::Routing::RouteSet.module_eval { const_set :Dispatcher, old_dispatcher }
214
+ end
215
+
216
+ def with_routing(&block)
217
+ temporary_routes = ActionDispatch::Routing::RouteSet.new
218
+ old_app, self.class.app = self.class.app, self.class.build_app(temporary_routes)
219
+ old_routes = SharedTestRoutes
220
+ silence_warnings { Object.const_set(:SharedTestRoutes, temporary_routes) }
221
+
222
+ yield temporary_routes
223
+ ensure
224
+ self.class.app = old_app
225
+ silence_warnings { Object.const_set(:SharedTestRoutes, old_routes) }
226
+ end
227
+
228
+ def with_autoload_path(path)
229
+ path = File.join(File.dirname(__FILE__), "fixtures", path)
230
+ if ActiveSupport::Dependencies.autoload_paths.include?(path)
231
+ yield
232
+ else
233
+ begin
234
+ ActiveSupport::Dependencies.autoload_paths << path
235
+ yield
236
+ ensure
237
+ ActiveSupport::Dependencies.autoload_paths.reject! {|p| p == path}
238
+ ActiveSupport::Dependencies.clear
239
+ end
240
+ end
241
+ end
242
+ end
243
+
244
+ # Temporary base class
245
+ class Rack::TestCase < ActionDispatch::IntegrationTest
246
+ def self.testing(klass = nil)
247
+ if klass
248
+ @testing = "/#{klass.name.underscore}".sub!(/_controller$/, '')
249
+ else
250
+ @testing
251
+ end
252
+ end
253
+
254
+ def get(thing, *args)
255
+ if thing.is_a?(Symbol)
256
+ super("#{self.class.testing}/#{thing}", *args)
257
+ else
258
+ super
259
+ end
260
+ end
261
+
262
+ def assert_body(body)
263
+ assert_equal body, Array.wrap(response.body).join
264
+ end
265
+
266
+ def assert_status(code)
267
+ assert_equal code, response.status
268
+ end
269
+
270
+ def assert_response(body, status = 200, headers = {})
271
+ assert_body body
272
+ assert_status status
273
+ headers.each do |header, value|
274
+ assert_header header, value
275
+ end
276
+ end
277
+
278
+ def assert_content_type(type)
279
+ assert_equal type, response.headers["Content-Type"]
280
+ end
281
+
282
+ def assert_header(name, value)
283
+ assert_equal value, response.headers[name]
284
+ end
285
+ end
286
+
287
+ module ActionController
288
+ class Base
289
+ include ActionController::Testing
290
+ # This stub emulates the Railtie including the URL helpers from a Rails application
291
+ include SharedTestRoutes.url_helpers
292
+ include SharedTestRoutes.mounted_helpers
293
+
294
+ self.view_paths = FIXTURE_LOAD_PATH
295
+
296
+ def self.test_routes(&block)
297
+ routes = ActionDispatch::Routing::RouteSet.new
298
+ routes.draw(&block)
299
+ include routes.url_helpers
300
+ end
301
+ end
302
+
303
+ class TestCase
304
+ include ActionDispatch::TestProcess
305
+
306
+ setup do
307
+ @routes = SharedTestRoutes
308
+ end
309
+ end
310
+ end
311
+
312
+ class ::ApplicationController < ActionController::Base
313
+ end
314
+
315
+ module ActionView
316
+ class TestCase
317
+ # Must repeat the setup because AV::TestCase is a duplication
318
+ # of AC::TestCase
319
+ setup do
320
+ @routes = SharedTestRoutes
321
+ end
322
+ end
323
+ end
324
+
325
+ class Workshop
326
+ extend ActiveModel::Naming
327
+ include ActiveModel::Conversion
328
+ attr_accessor :id
329
+
330
+ def initialize(id)
331
+ @id = id
332
+ end
333
+
334
+ def persisted?
335
+ id.present?
336
+ end
337
+
338
+ def to_s
339
+ id.to_s
340
+ end
341
+ end
342
+
343
+ module ActionDispatch
344
+ class DebugExceptions
345
+ private
346
+ remove_method :stderr_logger
347
+ # Silence logger
348
+ def stderr_logger
349
+ nil
350
+ end
351
+ end
352
+ end
353
+
354
+ module RoutingTestHelpers
355
+ def url_for(set, options, recall = nil)
356
+ set.send(:url_for, options.merge(:only_path => true, :_path_segments => recall))
357
+ end
358
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo-sprockets-rails3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,40 +9,40 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-01 00:00:00.000000000 Z
12
+ date: 2012-10-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sprockets
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 2.1.3
21
+ version: 2.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 2.1.3
29
+ version: 2.0.0
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: railties
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ~>
35
+ - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: 3.2.0
37
+ version: 3.1.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ~>
43
+ - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: 3.2.0
45
+ version: 3.1.0
46
46
  description: Speeds up the Rails 3 asset pipeline by only recompiling changed assets
47
47
  email:
48
48
  - nathan.f77@gmail.com
@@ -68,6 +68,27 @@ files:
68
68
  - MIT-LICENSE
69
69
  - Rakefile
70
70
  - README.md
71
+ - test/sprockets_helper_test.rb
72
+ - test/fixtures/alternate/stylesheets/style.css
73
+ - test/fixtures/app/images/logo.png
74
+ - test/fixtures/app/javascripts/application.js
75
+ - test/fixtures/app/javascripts/extra.js
76
+ - test/fixtures/app/javascripts/xmlhr.js
77
+ - test/fixtures/app/javascripts/dir/xmlhr.js
78
+ - test/fixtures/app/javascripts/foo.min.js
79
+ - test/fixtures/app/stylesheets/style.css
80
+ - test/fixtures/app/stylesheets/extra.css
81
+ - test/fixtures/app/stylesheets/style.ext
82
+ - test/fixtures/app/stylesheets/dir/style.css
83
+ - test/fixtures/app/stylesheets/application.css
84
+ - test/fixtures/app/stylesheets/style.min.css
85
+ - test/fixtures/app/fonts/font.ttf
86
+ - test/fixtures/app/fonts/dir/font.ttf
87
+ - test/sprockets_helpers_abstract_unit.rb
88
+ - test/assets_test.rb
89
+ - test/assets_debugging_test.rb
90
+ - test/sprockets_helper_with_routes_test.rb
91
+ - test/abstract_unit.rb
71
92
  homepage: https://github.com/ndbroadbent/turbo-sprockets-rails3
72
93
  licenses: []
73
94
  post_install_message:
@@ -92,4 +113,25 @@ rubygems_version: 1.8.24
92
113
  signing_key:
93
114
  specification_version: 3
94
115
  summary: Supercharge your Rails 3 asset pipeline
95
- test_files: []
116
+ test_files:
117
+ - test/sprockets_helper_test.rb
118
+ - test/fixtures/alternate/stylesheets/style.css
119
+ - test/fixtures/app/images/logo.png
120
+ - test/fixtures/app/javascripts/application.js
121
+ - test/fixtures/app/javascripts/extra.js
122
+ - test/fixtures/app/javascripts/xmlhr.js
123
+ - test/fixtures/app/javascripts/dir/xmlhr.js
124
+ - test/fixtures/app/javascripts/foo.min.js
125
+ - test/fixtures/app/stylesheets/style.css
126
+ - test/fixtures/app/stylesheets/extra.css
127
+ - test/fixtures/app/stylesheets/style.ext
128
+ - test/fixtures/app/stylesheets/dir/style.css
129
+ - test/fixtures/app/stylesheets/application.css
130
+ - test/fixtures/app/stylesheets/style.min.css
131
+ - test/fixtures/app/fonts/font.ttf
132
+ - test/fixtures/app/fonts/dir/font.ttf
133
+ - test/sprockets_helpers_abstract_unit.rb
134
+ - test/assets_test.rb
135
+ - test/assets_debugging_test.rb
136
+ - test/sprockets_helper_with_routes_test.rb
137
+ - test/abstract_unit.rb