Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

plugged everything up

  • Loading branch information...
commit e745e2eefe79eac2e3cda0bfe34ca5566090b839 1 parent 69c286c
@searls authored
View
54 config/initializers/processes_jasmine_directives.rb
@@ -1,54 +0,0 @@
-require 'jasmine'
-require 'jasmine-core'
-
-class ProcessesJasmineDirectives < Sprockets::DirectiveProcessor
- def process_require_jasmine_directive(asset_type)
- jasmine_config = Jasmine::Config.new
-
- if asset_type == "css"
- require_jasmine_css
- require_user_css(jasmine_config)
- else
- require_jasmine_javascript
- require_user_javascript(jasmine_config)
- end
- end
-
- private
-
- def require_jasmine_css
- Jasmine::Core.css_files.each do |f|
- context.require_asset "/#{Jasmine::Core.path}/#{f}"
- end
- end
-
- def require_user_css(config)
- config.css_files.each do |f|
- require_asset "#{Rails.root}#{f}"
- end
- end
-
- def require_jasmine_javascript
- Jasmine::Core.js_files.map do |f|
- context.require_asset "/#{Jasmine::Core.path}/#{f}"
- end
- end
-
- def require_user_javascript(jasmine_config)
- jasmine_config.js_files.each do |file_path|
- context.require_asset resolve_user_javascript_path(file_path,jasmine_config)
- end
- end
- # /js/__spec__/apple_spec.js
- def resolve_user_javascript_path(file_path,config)
- if file_path.include? config.spec_path
- file_path.gsub(/#{config.spec_path}/,config.spec_dir)
- else
- "#{Rails.root}#{file_path}"
- end
- end
-
-end
-
-Rails.application.assets.register_preprocessor 'application/javascript', ProcessesJasmineDirectives
-Rails.application.assets.register_preprocessor 'text/css', ProcessesJasmineDirectives
View
4 config/initializers/sprockets.rb
@@ -0,0 +1,4 @@
+require 'processes_jasmine_directives'
+
+Rails.application.assets.register_preprocessor 'application/javascript', ProcessesJasmineDirectives
+Rails.application.assets.register_preprocessor 'text/css', ProcessesJasmineDirectives
View
3  lib/processes_jasmine_directives.rb
@@ -1,6 +1,7 @@
require 'jasmine-core'
+require 'sprockets/directive_processor'
-class ProcessesJasmineDirectives
+class ProcessesJasmineDirectives < Sprockets::DirectiveProcessor
ASSET_TYPES = ["css","js"]
def process_require_jasmine_directive(asset_type)
View
3  spec/lib/processes_jasmine_directives_spec.rb
@@ -2,9 +2,10 @@
require 'sprockets/context'
require 'gimme'
require 'jasmine'
+require 'tempfile'
describe ProcessesJasmineDirectives do
- let(:target_object) { ProcessesJasmineDirectives.new }
+ let(:target_object) { ProcessesJasmineDirectives.new(__FILE__) }
let(:context_double) { gimme(Sprockets::Context) }
let(:jasmine_config) { gimme_next(Jasmine::Config) }
Please sign in to comment.
Something went wrong with that request. Please try again.