turbo-sprockets-rails3-envaware 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +117 -0
  4. data/Rakefile +28 -0
  5. data/lib/sprockets/asset_with_dependencies.rb +134 -0
  6. data/lib/sprockets/static_non_digest_generator.rb +106 -0
  7. data/lib/sprockets/unprocessed_asset.rb +39 -0
  8. data/lib/turbo-sprockets-rails3.rb +15 -0
  9. data/lib/turbo-sprockets/helpers.rb +9 -0
  10. data/lib/turbo-sprockets/railtie.rb +26 -0
  11. data/lib/turbo-sprockets/sprockets_overrides/asset.rb +31 -0
  12. data/lib/turbo-sprockets/sprockets_overrides/base.rb +38 -0
  13. data/lib/turbo-sprockets/sprockets_overrides/bundled_asset.rb +33 -0
  14. data/lib/turbo-sprockets/sprockets_overrides/environment.rb +21 -0
  15. data/lib/turbo-sprockets/sprockets_overrides/index.rb +30 -0
  16. data/lib/turbo-sprockets/sprockets_overrides/processed_asset.rb +29 -0
  17. data/lib/turbo-sprockets/sprockets_overrides/static_compiler.rb +94 -0
  18. data/lib/turbo-sprockets/tasks/assets.rake +204 -0
  19. data/lib/turbo-sprockets/version.rb +3 -0
  20. data/test/abstract_unit.rb +143 -0
  21. data/test/assets_debugging_test.rb +65 -0
  22. data/test/assets_test.rb +542 -0
  23. data/test/fixtures/alternate/stylesheets/style.css +1 -0
  24. data/test/fixtures/app/fonts/dir/font.ttf +0 -0
  25. data/test/fixtures/app/fonts/font.ttf +0 -0
  26. data/test/fixtures/app/images/logo.png +0 -0
  27. data/test/fixtures/app/javascripts/application.js +1 -0
  28. data/test/fixtures/app/javascripts/dir/xmlhr.js +0 -0
  29. data/test/fixtures/app/javascripts/extra.js +0 -0
  30. data/test/fixtures/app/javascripts/foo.min.js +0 -0
  31. data/test/fixtures/app/javascripts/xmlhr.js +0 -0
  32. data/test/fixtures/app/stylesheets/application.css +1 -0
  33. data/test/fixtures/app/stylesheets/dir/style.css +0 -0
  34. data/test/fixtures/app/stylesheets/extra.css +0 -0
  35. data/test/fixtures/app/stylesheets/style.css +0 -0
  36. data/test/fixtures/app/stylesheets/style.ext +0 -0
  37. data/test/fixtures/app/stylesheets/style.min.css +0 -0
  38. data/test/sprockets_helper_test.rb +363 -0
  39. data/test/sprockets_helper_with_routes_test.rb +57 -0
  40. data/test/sprockets_helpers_abstract_unit.rb +358 -0
  41. metadata +139 -0
@@ -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 ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: turbo-sprockets-rails3-envaware
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.10
5
+ platform: ruby
6
+ authors:
7
+ - Made
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sprockets
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: railties
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>'
32
+ - !ruby/object:Gem::Version
33
+ version: 3.2.8
34
+ - - <
35
+ - !ruby/object:Gem::Version
36
+ version: 4.0.0
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - '>'
42
+ - !ruby/object:Gem::Version
43
+ version: 3.2.8
44
+ - - <
45
+ - !ruby/object:Gem::Version
46
+ version: 4.0.0
47
+ description: Quick-n-dirty fork of turbo-sprockets to add support for multiple environments
48
+ (e.g. staging, pre-prod, prod etc.). Longer term looking to have this pulled back
49
+ in to master.
50
+ email:
51
+ - chris@madebymade.co.uk
52
+ executables: []
53
+ extensions: []
54
+ extra_rdoc_files: []
55
+ files:
56
+ - lib/sprockets/asset_with_dependencies.rb
57
+ - lib/sprockets/static_non_digest_generator.rb
58
+ - lib/sprockets/unprocessed_asset.rb
59
+ - lib/turbo-sprockets/helpers.rb
60
+ - lib/turbo-sprockets/railtie.rb
61
+ - lib/turbo-sprockets/sprockets_overrides/asset.rb
62
+ - lib/turbo-sprockets/sprockets_overrides/base.rb
63
+ - lib/turbo-sprockets/sprockets_overrides/bundled_asset.rb
64
+ - lib/turbo-sprockets/sprockets_overrides/environment.rb
65
+ - lib/turbo-sprockets/sprockets_overrides/index.rb
66
+ - lib/turbo-sprockets/sprockets_overrides/processed_asset.rb
67
+ - lib/turbo-sprockets/sprockets_overrides/static_compiler.rb
68
+ - lib/turbo-sprockets/tasks/assets.rake
69
+ - lib/turbo-sprockets/version.rb
70
+ - lib/turbo-sprockets-rails3.rb
71
+ - MIT-LICENSE
72
+ - Rakefile
73
+ - README.md
74
+ - test/abstract_unit.rb
75
+ - test/assets_debugging_test.rb
76
+ - test/assets_test.rb
77
+ - test/fixtures/alternate/stylesheets/style.css
78
+ - test/fixtures/app/fonts/dir/font.ttf
79
+ - test/fixtures/app/fonts/font.ttf
80
+ - test/fixtures/app/images/logo.png
81
+ - test/fixtures/app/javascripts/application.js
82
+ - test/fixtures/app/javascripts/dir/xmlhr.js
83
+ - test/fixtures/app/javascripts/extra.js
84
+ - test/fixtures/app/javascripts/foo.min.js
85
+ - test/fixtures/app/javascripts/xmlhr.js
86
+ - test/fixtures/app/stylesheets/application.css
87
+ - test/fixtures/app/stylesheets/dir/style.css
88
+ - test/fixtures/app/stylesheets/extra.css
89
+ - test/fixtures/app/stylesheets/style.css
90
+ - test/fixtures/app/stylesheets/style.ext
91
+ - test/fixtures/app/stylesheets/style.min.css
92
+ - test/sprockets_helper_test.rb
93
+ - test/sprockets_helper_with_routes_test.rb
94
+ - test/sprockets_helpers_abstract_unit.rb
95
+ homepage: https://github.com/madebymade/turbo-sprockets-rails3
96
+ licenses: []
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project:
114
+ rubygems_version: 2.0.3
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Supercharge your Rails 3 asset pipeline
118
+ test_files:
119
+ - test/abstract_unit.rb
120
+ - test/assets_debugging_test.rb
121
+ - test/assets_test.rb
122
+ - test/fixtures/alternate/stylesheets/style.css
123
+ - test/fixtures/app/fonts/dir/font.ttf
124
+ - test/fixtures/app/fonts/font.ttf
125
+ - test/fixtures/app/images/logo.png
126
+ - test/fixtures/app/javascripts/application.js
127
+ - test/fixtures/app/javascripts/dir/xmlhr.js
128
+ - test/fixtures/app/javascripts/extra.js
129
+ - test/fixtures/app/javascripts/foo.min.js
130
+ - test/fixtures/app/javascripts/xmlhr.js
131
+ - test/fixtures/app/stylesheets/application.css
132
+ - test/fixtures/app/stylesheets/dir/style.css
133
+ - test/fixtures/app/stylesheets/extra.css
134
+ - test/fixtures/app/stylesheets/style.css
135
+ - test/fixtures/app/stylesheets/style.ext
136
+ - test/fixtures/app/stylesheets/style.min.css
137
+ - test/sprockets_helper_test.rb
138
+ - test/sprockets_helper_with_routes_test.rb
139
+ - test/sprockets_helpers_abstract_unit.rb