Created
January 21, 2011 21:41
-
-
Save rsim/790479 to your computer and use it in GitHub Desktop.
Adds CoffeeScript support for jasmine gem (rake jasmine task), uses barista gem to compile CoffeScript files to JavaScript before running Jasmine tests.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# put this file in spec/javascripts/support directory | |
require 'barista' | |
require 'logger' | |
require File.join(Rails.root, 'config/initializers/barista_config') | |
Barista.configure do |c| | |
c.env = 'test' | |
c.logger = Logger.new(STDOUT) | |
c.logger.level = Logger::INFO | |
c.before_compilation do |path| | |
relative_path = Pathname(path).relative_path_from(Rails.root) | |
c.logger.info "[#{Time.now.strftime("%Y-%m-%d %H:%M:%S")}] Barista: Compiling #{relative_path}" | |
end | |
end | |
Barista.setup_defaults | |
module Jasmine | |
def self.app(config) | |
Barista::Framework.register 'jasmine', File.expand_path('../coffeescripts', config.spec_dir) | |
Barista::Framework['jasmine'].instance_variable_set('@output_root', Pathname(config.spec_dir).join('compiled')) | |
Rack::Builder.app do | |
use Rack::Head | |
map('/run.html') { run Jasmine::Redirect.new('/') } | |
map('/__suite__') { run Barista::Filter.new(Jasmine::FocusedSuite.new(config)) } | |
map('/__JASMINE_ROOT__') { run Rack::File.new(Jasmine.root) } | |
map(config.spec_path) { run Rack::File.new(config.spec_dir) } | |
map(config.root_path) { run Rack::File.new(config.project_root) } | |
map('/favicon.ico') { run Rack::File.new(File.join(Rails.root, 'public')) } | |
map('/') do | |
run Rack::Cascade.new([ | |
Rack::URLMap.new('/' => Rack::File.new(config.src_dir)), | |
Barista::Filter.new(Jasmine::RunAdapter.new(config)) | |
]) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok I think I found the source of the problem - line #29 Should be