ok, use coffee-script and external compiler, the html thing doesn't work
This commit is contained in:
parent
928decefd7
commit
234f49e583
@ -44,9 +44,8 @@ These options can also be placed into a `.jasmine-headless-webkit` file in your
|
|||||||
|
|
||||||
### CoffeeScript Support
|
### CoffeeScript Support
|
||||||
|
|
||||||
`jasmine-headless-webkit` brings in the `coffee-script-source` gem and allows you to run CoffeeScript
|
`jasmine-headless-webkit` brings in the `coffee-script` gem and compiles & injects all CoffeeScript into the
|
||||||
files without needing compilation. It uses [the `<script type="text/coffeescript">` method](http://jashkenas.github.com/coffee-script/#scripts) of loading
|
generated HTML page. All you need to do is configure your `jasmine.yml` file to look for .coffee files:
|
||||||
CoffeeScript. All you need to do is configure your `jasmine.yml` file to look for .coffee files:
|
|
||||||
|
|
||||||
src_files:
|
src_files:
|
||||||
- app/assets/javascripts/**/*.coffee
|
- app/assets/javascripts/**/*.coffee
|
||||||
|
@ -10,13 +10,12 @@ require 'getoptlong'
|
|||||||
require 'rubygems'
|
require 'rubygems'
|
||||||
|
|
||||||
gem 'jasmine'
|
gem 'jasmine'
|
||||||
gem 'coffee-script-source'
|
gem 'coffee-script'
|
||||||
|
|
||||||
require 'jasmine'
|
require 'jasmine'
|
||||||
require 'coffee_script/source'
|
require 'coffee-script'
|
||||||
|
|
||||||
require 'jasmine/cli'
|
require 'jasmine/cli'
|
||||||
|
|
||||||
include Jasmine::CLI
|
include Jasmine::CLI
|
||||||
|
|
||||||
opts = GetoptLong.new(
|
opts = GetoptLong.new(
|
||||||
@ -53,8 +52,7 @@ puts "Running Jasmine specs..."
|
|||||||
|
|
||||||
files = [
|
files = [
|
||||||
'file://' + File.join(Jasmine.root, 'lib/jasmine.js'),
|
'file://' + File.join(Jasmine.root, 'lib/jasmine.js'),
|
||||||
'file://' + File.join(Jasmine.root, 'lib/jasmine-html.js'),
|
'file://' + File.join(Jasmine.root, 'lib/jasmine-html.js')
|
||||||
'file://' + CoffeeScript::Source.bundled_path,
|
|
||||||
]
|
]
|
||||||
|
|
||||||
files += [ [ 'src_files', 'src_dir' ], [ 'stylesheets', 'src_dir' ], [ 'helpers', 'spec_dir' ], [ 'spec_files', 'spec_dir' ] ].collect do |searches, root|
|
files += [ [ 'src_files', 'src_dir' ], [ 'stylesheets', 'src_dir' ], [ 'helpers', 'spec_dir' ], [ 'spec_files', 'spec_dir' ] ].collect do |searches, root|
|
||||||
@ -75,7 +73,7 @@ files = files.flatten.compact.collect { |file|
|
|||||||
when '.js'
|
when '.js'
|
||||||
%{<script type="text/javascript" src="#{file}"></script>}
|
%{<script type="text/javascript" src="#{file}"></script>}
|
||||||
when '.coffee'
|
when '.coffee'
|
||||||
%{<script type="text/coffeescript" src="#{file}"></script>}
|
%{<script type="text/javascript">#{CoffeeScript.compile File.read(file)}</script>}
|
||||||
when '.css'
|
when '.css'
|
||||||
%{<link rel="stylesheet" href="#{file}" type="text/css" />}
|
%{<link rel="stylesheet" href="#{file}" type="text/css" />}
|
||||||
end
|
end
|
||||||
|
@ -21,5 +21,5 @@ Gem::Specification.new do |s|
|
|||||||
s.require_paths = ["lib"]
|
s.require_paths = ["lib"]
|
||||||
|
|
||||||
s.add_dependency 'jasmine'
|
s.add_dependency 'jasmine'
|
||||||
s.add_dependency 'coffee-script-source'
|
s.add_dependency 'coffee-script'
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
module JasmineMixin
|
module JasmineMixin
|
||||||
JASMINE_PROGRAM = File.expand_path('../../../bin/jasmine-headless-webkit', __FILE__)
|
JASMINE_PROGRAM = File.expand_path('../../../bin/jasmine-headless-webkit', __FILE__)
|
||||||
|
|
||||||
JAVASCRIPT_EXTENSIONS = %w{js}
|
JAVASCRIPT_EXTENSIONS = %w{js coffee}
|
||||||
|
|
||||||
def self.included(klass)
|
def self.included(klass)
|
||||||
klass::ALL_HOOKS << [ :run_jasmine, :ran_jasmine ]
|
klass::ALL_HOOKS << [ :run_jasmine, :ran_jasmine ]
|
||||||
@ -81,12 +81,16 @@ module JasmineMixin
|
|||||||
end
|
end
|
||||||
|
|
||||||
def setup_jasmine_project_mappings
|
def setup_jasmine_project_mappings
|
||||||
add_mapping(%r{spec/javascripts/.*_spec\.js}) { |filename, _|
|
add_mapping(%r{spec/javascripts/.*_spec\.(js|coffee)}) { |filename, _|
|
||||||
filename
|
filename
|
||||||
}
|
}
|
||||||
|
|
||||||
add_mapping(%r{public/javascripts/(.*)\.js}) { |_, m|
|
add_mapping(%r{public/javascripts/(.*)\.js}) { |_, m|
|
||||||
[ "spec/javascripts/#{m[1]}_spec.js" ]
|
files_matching(%{spec/javascripts/#{m[1]}_spec\..*$})
|
||||||
|
}
|
||||||
|
|
||||||
|
add_mapping(%r{app/coffeescripts/(.*)\.coffee}) { |_, m|
|
||||||
|
files_matching(%{spec/javascripts/#{m[1]}_spec\..*$})
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user