Runner.html is now generated (ensures all source & specs get tested); beginnings of refactoring of Rake tasks.
This commit is contained in:
31
tasks/build_dist.rb
Normal file
31
tasks/build_dist.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
desc "Build core jasmine.js"
|
||||
task :build_jasmine_js => :lint do
|
||||
puts 'Building Jasmine from source'
|
||||
|
||||
File.open("lib/jasmine.js", 'w') do |jasmine_js|
|
||||
core_sources.each do |source_filename|
|
||||
file = File.read(source_filename)
|
||||
# file += "\n" unless file.match(/\n$/)
|
||||
file.chomp
|
||||
jasmine_js << file
|
||||
end
|
||||
|
||||
jasmine_js << version_source
|
||||
end
|
||||
|
||||
File.open("lib/jasmine-html.js", 'w') do |jasmine_html|
|
||||
html_sources.each do |source_filename|
|
||||
jasmine_html.puts(File.read(source_filename))
|
||||
end
|
||||
end
|
||||
|
||||
FileUtils.cp("src/html/jasmine.css", "lib/jasmine.css")
|
||||
end
|
||||
|
||||
desc 'Check jasmine sources for coding problems'
|
||||
task :lint do
|
||||
puts "Running JSHint via Node.js"
|
||||
system("node jshint/run.js") || exit(1)
|
||||
end
|
||||
|
||||
task :hint => :lint
|
||||
32
tasks/build_specs.rb
Normal file
32
tasks/build_specs.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
require 'ostruct'
|
||||
|
||||
desc "build the browser spec runner.html based on current tree"
|
||||
task :build_runner_html do
|
||||
template = Tilt.new('spec/templates/runner.html.erb')
|
||||
|
||||
File.open('spec/runner.html', 'w+') do |f|
|
||||
scope = OpenStruct.new(:source_tags => other_source_file_tags,
|
||||
:spec_file_tags => spec_file_tags)
|
||||
f << template.render(scope)
|
||||
end
|
||||
end
|
||||
|
||||
def other_source_file_tags
|
||||
other_files = html_sources + console_sources
|
||||
script_tags_for other_files.collect { |f| "../#{f}" }
|
||||
end
|
||||
|
||||
def spec_file_tags
|
||||
spec_files = core_specfiles + html_specfiles + console_specfiles
|
||||
script_tags_for spec_files.collect { |f| "../#{f}" }
|
||||
end
|
||||
|
||||
def script_tags_for(files)
|
||||
script_tag = Tilt::new('spec/templates/script_tag.html.erb')
|
||||
|
||||
files.inject([]) do |tags, f|
|
||||
scope = OpenStruct.new :file => f
|
||||
tags << script_tag.render(scope)
|
||||
tags
|
||||
end.join("\n ")
|
||||
end
|
||||
0
tasks/docs.rb
Normal file
0
tasks/docs.rb
Normal file
52
tasks/helpers.rb
Normal file
52
tasks/helpers.rb
Normal file
@@ -0,0 +1,52 @@
|
||||
require 'json'
|
||||
|
||||
def core_sources
|
||||
first_sources = JSON.parse(File.read('src/SourcesList.json')).collect { |f| "src/core/#{f}" }
|
||||
|
||||
remaining_sources = Dir.glob('src/core/*.js').reject { |f| first_sources.include?(f) }.sort
|
||||
|
||||
first_sources + remaining_sources
|
||||
end
|
||||
|
||||
def html_sources
|
||||
Dir.glob('src/html/*.js')
|
||||
end
|
||||
|
||||
def console_sources
|
||||
Dir.glob('src/console/*.js')
|
||||
end
|
||||
|
||||
def core_specfiles
|
||||
Dir.glob('spec/core/*.js')
|
||||
end
|
||||
|
||||
def html_specfiles
|
||||
Dir.glob('spec/html/*.js')
|
||||
end
|
||||
|
||||
def console_specfiles
|
||||
Dir.glob('spec/console/*.js')
|
||||
end
|
||||
|
||||
def version_string
|
||||
"#{version_hash['major']}.#{version_hash['minor']}.#{version_hash['build']}"
|
||||
end
|
||||
|
||||
def version_source
|
||||
<<-JS
|
||||
jasmine.version_= {
|
||||
"major": #{version_hash['major'].to_json},
|
||||
"minor": #{version_hash['minor'].to_json},
|
||||
"build": #{version_hash['build'].to_json},
|
||||
"revision": #{Time.now.to_i}
|
||||
}
|
||||
JS
|
||||
end
|
||||
|
||||
def version_hash
|
||||
@version ||= JSON.parse(File.new("src/core/version.json").read);
|
||||
end
|
||||
|
||||
def node_installed?
|
||||
`which node` =~ /node/
|
||||
end
|
||||
18
tasks/spec.rb
Normal file
18
tasks/spec.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
desc "Run spec suite: Browser, Node, JSHint"
|
||||
task :spec => ["build_jasmine_js", "spec:node", "spec:browser"]
|
||||
|
||||
desc 'Run specs in Node.js'
|
||||
task "spec:node" => :require_node do
|
||||
puts "Running all appropriate specs via Node.js"
|
||||
system("node spec/node_suite.js")
|
||||
end
|
||||
|
||||
desc "Run specs in the default browser (MacOS only)"
|
||||
task "spec:browser" => :build_runner_html do
|
||||
puts "Running all appropriate specs via the default web browser"
|
||||
system("open spec/runner.html")
|
||||
end
|
||||
|
||||
#def core_spec_count
|
||||
#
|
||||
#end
|
||||
Reference in New Issue
Block a user