Add rails generators. Add sources.yaml support. Fix Prototype.js collision on jasmine:ci. Version bump to 0.4.0.
This commit is contained in:
parent
d2fe23b52b
commit
53305edc68
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
:minor: 1
|
:patch: 0
|
||||||
:build:
|
|
||||||
:patch: 3
|
|
||||||
:major: 0
|
:major: 0
|
||||||
|
:build:
|
||||||
|
:minor: 4
|
||||||
|
|
57
bin/jasmine
57
bin/jasmine
|
@ -10,45 +10,46 @@ def expand(*paths)
|
||||||
File.expand_path(File.join(*paths))
|
File.expand_path(File.join(*paths))
|
||||||
end
|
end
|
||||||
|
|
||||||
def rakefile_path
|
def template_path(filepath)
|
||||||
expand(cwd, 'templates/Rakefile')
|
expand(cwd, File.join("generators/jasmine/templates", filepath))
|
||||||
|
end
|
||||||
|
|
||||||
|
def dest_path(filepath)
|
||||||
|
expand(Dir.pwd, filepath)
|
||||||
|
end
|
||||||
|
|
||||||
|
def copy_unless_exists(relative_path, dest_path = nil)
|
||||||
|
unless File.exist?(dest_path(relative_path))
|
||||||
|
File.copy(template_path(relative_path), dest_path(dest_path || relative_path))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ARGV[0] == 'init'
|
if ARGV[0] == 'init'
|
||||||
require 'ftools'
|
require 'ftools'
|
||||||
File.makedirs('spec/javascripts')
|
File.makedirs('spec/javascripts')
|
||||||
File.makedirs('spec/helpers')
|
File.makedirs('spec/javascripts/support')
|
||||||
|
|
||||||
dest_root = File.expand_path(Dir.pwd)
|
copy_unless_exists('spec/javascripts/SpecHelper.js')
|
||||||
dest_spec = expand(dest_root, 'spec')
|
copy_unless_exists('spec/javascripts/ExampleSpec.js')
|
||||||
dest_spec_javascripts = expand(dest_root, 'spec/javascripts')
|
copy_unless_exists('spec/javascripts/support/jasmine_config.rb')
|
||||||
dest_spec_helpers = expand(dest_root, 'spec/helpers')
|
copy_unless_exists('spec/javascripts/support/jasmine_spec.rb')
|
||||||
|
|
||||||
unless File.exist?(expand(dest_spec_helpers, 'spec_helper.js'))
|
rails_tasks_dir = dest_path('lib/tasks')
|
||||||
File.copy(expand(cwd, 'templates/spec_helper.js'), dest_spec_helpers)
|
|
||||||
end
|
|
||||||
unless File.exist?(expand(dest_spec_helpers, 'jasmine_helper.rb'))
|
|
||||||
File.copy(expand(cwd, 'templates/jasmine_helper.rb'), dest_spec_helpers)
|
|
||||||
end
|
|
||||||
|
|
||||||
File.copy(expand(cwd, 'templates/example_spec.js'), dest_spec_javascripts)
|
|
||||||
|
|
||||||
rails_tasks_dir = expand(dest_root, 'lib', 'tasks')
|
|
||||||
if File.exist?(rails_tasks_dir)
|
if File.exist?(rails_tasks_dir)
|
||||||
File.makedirs('lib/tasks/jasmine')
|
copy_unless_exists('lib/tasks/jasmine.rake')
|
||||||
File.copy(rakefile_path, File.join(rails_tasks_dir, 'jasmine/jasmine.rake'))
|
copy_unless_exists('spec/javascripts/support/sources-rails.yaml', 'spec/javascripts/support/sources.yaml')
|
||||||
else
|
else
|
||||||
if File.exist?(expand(dest_root, 'Rakefile'))
|
copy_unless_exists('spec/javascripts/support/sources.yaml')
|
||||||
existing_rakefile = expand(dest_root, 'Rakefile')
|
if File.exist?(dest_path('Rakefile'))
|
||||||
load existing_rakefile
|
load dest_path('Rakefile')
|
||||||
unless Rake::Task.task_defined?('jasmine')
|
end
|
||||||
open(existing_rakefile, 'a') do |f|
|
write_mode = Rake::Task.task_defined?('jasmine') ? 'a' : 'w'
|
||||||
f.write(File.read(rakefile_path))
|
File.open(dest_path('Rakefile'), write_mode) do |f|
|
||||||
|
f.write(File.read(template_path('lib/tasks/jasmine.rake')))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
File.open(template_path('INSTALL'), 'r').each_line do |line|
|
||||||
File.copy(rakefile_path, dest_root)
|
puts line
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
class JasmineGenerator < Rails::Generator::Base
|
||||||
|
def manifest
|
||||||
|
record do |m|
|
||||||
|
|
||||||
|
m.directory "spec/javascripts"
|
||||||
|
m.file "spec/javascripts/SpecHelper.js", "spec/javascripts/SpecHelper.js"
|
||||||
|
m.file "spec/javascripts/ExampleSpec.js", "spec/javascripts/ExampleSpec.js"
|
||||||
|
|
||||||
|
m.directory "spec/javascripts/support"
|
||||||
|
m.file "spec/javascripts/support/jasmine_config.rb", "spec/javascripts/support/jasmine_config.rb"
|
||||||
|
m.file "spec/javascripts/support/jasmine_spec.rb", "spec/javascripts/support/jasmine_spec.rb"
|
||||||
|
m.file "spec/javascripts/support/sources-rails.yaml", "spec/javascripts/support/sources.yaml"
|
||||||
|
|
||||||
|
m.directory "lib/tasks"
|
||||||
|
m.file "lib/tasks/jasmine.rake", "lib/tasks/jasmine.rake"
|
||||||
|
|
||||||
|
m.readme "INSTALL"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def file_name
|
||||||
|
"create_blog"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,9 @@
|
||||||
|
Jasmine has been installed with example specs.
|
||||||
|
|
||||||
|
To run the server:
|
||||||
|
|
||||||
|
rake jasmine
|
||||||
|
|
||||||
|
To run the automated CI task with Selenium:
|
||||||
|
|
||||||
|
rake jasmine:ci
|
|
@ -0,0 +1,23 @@
|
||||||
|
namespace :jasmine do
|
||||||
|
require 'jasmine'
|
||||||
|
|
||||||
|
desc "Run continuous integration tests"
|
||||||
|
require "spec"
|
||||||
|
require 'spec/rake/spectask'
|
||||||
|
Spec::Rake::SpecTask.new(:ci) do |t|
|
||||||
|
t.spec_opts = ["--color", "--format", "specdoc"]
|
||||||
|
t.verbose = true
|
||||||
|
t.spec_files = ['spec/javascripts/support/jasmine_spec.rb']
|
||||||
|
end
|
||||||
|
task :server do
|
||||||
|
require 'spec/javascripts/support/jasmine_config'
|
||||||
|
|
||||||
|
puts "your tests are here:"
|
||||||
|
puts " http://localhost:8888/run.html"
|
||||||
|
|
||||||
|
Jasmine::Config.new.start_server
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
desc "Run specs via server"
|
||||||
|
task :jasmine => ['jasmine:server']
|
|
@ -0,0 +1,23 @@
|
||||||
|
require 'jasmine'
|
||||||
|
|
||||||
|
class Jasmine::Config
|
||||||
|
|
||||||
|
def project_root
|
||||||
|
File.expand_path(File.join(File.dirname(__FILE__), "..", "..", ".."))
|
||||||
|
end
|
||||||
|
|
||||||
|
# Return an array of files to include before jasmine specs. Override if needed.
|
||||||
|
# def src_files
|
||||||
|
# match_files(src_dir, "**/*.js")
|
||||||
|
# end
|
||||||
|
|
||||||
|
# Path to your JavaScript source files
|
||||||
|
# def src_dir
|
||||||
|
# File.join(project_root, "public")
|
||||||
|
# end
|
||||||
|
|
||||||
|
# Path to your JavaScript specs
|
||||||
|
# def spec_dir
|
||||||
|
# File.join(project_root, 'spec/javascripts')
|
||||||
|
# end
|
||||||
|
end
|
|
@ -0,0 +1,17 @@
|
||||||
|
require 'rubygems'
|
||||||
|
require File.expand_path(File.join(File.dirname(__FILE__), 'jasmine_config'))
|
||||||
|
|
||||||
|
jasmine_config = Jasmine::Config.new
|
||||||
|
spec_builder = Jasmine::SpecBuilder.new(jasmine_config)
|
||||||
|
|
||||||
|
should_stop = false
|
||||||
|
|
||||||
|
Spec::Runner.configure do |config|
|
||||||
|
config.after(:suite) do
|
||||||
|
spec_builder.stop if should_stop
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
spec_builder.start
|
||||||
|
should_stop = true
|
||||||
|
spec_builder.declare_suites
|
|
@ -0,0 +1,8 @@
|
||||||
|
sources:
|
||||||
|
- javascripts/prototype.js
|
||||||
|
- javascripts/effects.js
|
||||||
|
- javascripts/controls.js
|
||||||
|
- javascripts/dragdrop.js
|
||||||
|
- javascripts/application.js
|
||||||
|
src_dir: public
|
||||||
|
spec_dir: spec/javascripts
|
|
@ -0,0 +1,5 @@
|
||||||
|
#sources:
|
||||||
|
# - lib/source1.js
|
||||||
|
# - lib/source2.js
|
||||||
|
#src_dir:
|
||||||
|
#spec_dir: spec/javascripts
|
|
@ -5,19 +5,28 @@
|
||||||
|
|
||||||
Gem::Specification.new do |s|
|
Gem::Specification.new do |s|
|
||||||
s.name = %q{jasmine}
|
s.name = %q{jasmine}
|
||||||
s.version = "0.1.3"
|
s.version = "0.4.0"
|
||||||
|
|
||||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||||
s.authors = ["Rajan Agaskar", "Christian Williams"]
|
s.authors = ["Rajan Agaskar", "Christian Williams"]
|
||||||
s.date = %q{2009-12-31}
|
s.date = %q{2010-01-26}
|
||||||
|
s.default_executable = %q{jasmine}
|
||||||
s.description = %q{Javascript BDD test framework}
|
s.description = %q{Javascript BDD test framework}
|
||||||
s.email = %q{ragaskar@gmail.com}
|
s.email = %q{ragaskar@gmail.com}
|
||||||
s.executables = ["autospec", "edit_json.rb", "jasmine", "jeweler", "prettify_json.rb", "rackup", "rake", "rubyforge", "selenium-rc", "spec", "thin"]
|
s.executables = ["jasmine"]
|
||||||
s.extra_rdoc_files = [
|
s.extra_rdoc_files = [
|
||||||
"README.markdown"
|
"README.markdown"
|
||||||
]
|
]
|
||||||
s.files = [
|
s.files = [
|
||||||
"bin/jasmine",
|
"generators/jasmine/jasmine_generator.rb",
|
||||||
|
"generators/jasmine/templates/INSTALL",
|
||||||
|
"generators/jasmine/templates/lib/tasks/jasmine.rake",
|
||||||
|
"generators/jasmine/templates/spec/javascripts/ExampleSpec.js",
|
||||||
|
"generators/jasmine/templates/spec/javascripts/SpecHelper.js",
|
||||||
|
"generators/jasmine/templates/spec/javascripts/support/jasmine_config.rb",
|
||||||
|
"generators/jasmine/templates/spec/javascripts/support/jasmine_spec.rb",
|
||||||
|
"generators/jasmine/templates/spec/javascripts/support/sources-rails.yaml",
|
||||||
|
"generators/jasmine/templates/spec/javascripts/support/sources.yaml",
|
||||||
"jasmine/contrib/ruby/jasmine_runner.rb",
|
"jasmine/contrib/ruby/jasmine_runner.rb",
|
||||||
"jasmine/contrib/ruby/jasmine_spec_builder.rb",
|
"jasmine/contrib/ruby/jasmine_spec_builder.rb",
|
||||||
"jasmine/contrib/ruby/run.html",
|
"jasmine/contrib/ruby/run.html",
|
||||||
|
@ -29,13 +38,10 @@ Gem::Specification.new do |s|
|
||||||
"lib/jasmine.rb",
|
"lib/jasmine.rb",
|
||||||
"lib/jasmine/base.rb",
|
"lib/jasmine/base.rb",
|
||||||
"lib/jasmine/config.rb",
|
"lib/jasmine/config.rb",
|
||||||
"lib/jasmine/jasmine_helper.rb",
|
|
||||||
"lib/jasmine/jasmine_meta_spec.rb",
|
|
||||||
"lib/jasmine/run.html.erb",
|
"lib/jasmine/run.html.erb",
|
||||||
"lib/jasmine/selenium_driver.rb",
|
"lib/jasmine/selenium_driver.rb",
|
||||||
"lib/jasmine/server.rb",
|
"lib/jasmine/server.rb",
|
||||||
"lib/jasmine/spec_builder.rb",
|
"lib/jasmine/spec_builder.rb"
|
||||||
"templates/Rakefile"
|
|
||||||
]
|
]
|
||||||
s.homepage = %q{http://github.com/pivotal/jasmine-ruby}
|
s.homepage = %q{http://github.com/pivotal/jasmine-ruby}
|
||||||
s.rdoc_options = ["--charset=UTF-8"]
|
s.rdoc_options = ["--charset=UTF-8"]
|
||||||
|
|
|
@ -3,5 +3,4 @@ require 'jasmine/config'
|
||||||
require 'jasmine/server'
|
require 'jasmine/server'
|
||||||
require 'jasmine/selenium_driver'
|
require 'jasmine/selenium_driver'
|
||||||
|
|
||||||
require 'jasmine/jasmine_helper'
|
|
||||||
require 'jasmine/spec_builder'
|
require 'jasmine/spec_builder'
|
|
@ -1,5 +1,7 @@
|
||||||
module Jasmine
|
module Jasmine
|
||||||
class Config
|
class Config
|
||||||
|
require 'yaml'
|
||||||
|
|
||||||
def initialize(options = {})
|
def initialize(options = {})
|
||||||
require 'selenium_rc'
|
require 'selenium_rc'
|
||||||
@selenium_jar_path = SeleniumRC::Server.allocate.jar_path
|
@selenium_jar_path = SeleniumRC::Server.allocate.jar_path
|
||||||
|
@ -86,31 +88,60 @@ module Jasmine
|
||||||
Dir.glob(File.join(dir, pattern)).collect {|f| f.sub("#{dir}/", "")}.sort
|
Dir.glob(File.join(dir, pattern)).collect {|f| f.sub("#{dir}/", "")}.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def project_root
|
||||||
|
Dir.pwd
|
||||||
|
end
|
||||||
|
|
||||||
|
def src_dir
|
||||||
|
if simple_config['src_dir']
|
||||||
|
File.join(project_root, simple_config['src_dir'])
|
||||||
|
else
|
||||||
|
project_root
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def simple_config_file
|
||||||
|
File.join(project_root, 'spec/javascripts/support/sources.yaml')
|
||||||
|
end
|
||||||
|
|
||||||
|
def simple_config
|
||||||
|
config = File.exist?(simple_config_file) ? File.open(simple_config_file) { |yf| YAML::load( yf ) } : false
|
||||||
|
config || {}
|
||||||
|
end
|
||||||
|
|
||||||
def src_files
|
def src_files
|
||||||
match_files(src_dir, "**/*.js")
|
simple_config['sources'] || []
|
||||||
end
|
end
|
||||||
|
|
||||||
def src_path
|
def spec_dir
|
||||||
"src"
|
if simple_config['spec_dir']
|
||||||
|
File.join(project_root, simple_config['spec_dir'])
|
||||||
|
else
|
||||||
|
File.join(project_root, 'spec/javascripts')
|
||||||
end
|
end
|
||||||
|
|
||||||
def spec_path
|
|
||||||
"spec"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def spec_files
|
def spec_files
|
||||||
match_files(spec_dir, "**/*.js")
|
match_files(spec_dir, "**/*.js")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def spec_path
|
||||||
|
"/__spec__"
|
||||||
|
end
|
||||||
|
|
||||||
|
def root_path
|
||||||
|
"/__root__"
|
||||||
|
end
|
||||||
|
|
||||||
def mappings
|
def mappings
|
||||||
{
|
{
|
||||||
"/" + src_path => src_dir,
|
spec_path => spec_dir,
|
||||||
"/" + spec_path => spec_dir
|
root_path => project_root
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def js_files
|
def js_files
|
||||||
src_files.collect {|f| "/" + File.join(src_path, f) } + spec_files.collect {|f| "/" + File.join(spec_path, f) }
|
src_files.collect {|f| "/" + f } + spec_files.collect {|f| File.join(spec_path, f) }
|
||||||
end
|
end
|
||||||
|
|
||||||
def spec_files_full_paths
|
def spec_files_full_paths
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
class JasmineHelper
|
|
||||||
def self.lib_dir
|
|
||||||
File.expand_path(File.join(root, 'lib'))
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.jasmine
|
|
||||||
['/lib/' + File.basename(Dir.glob("#{JasmineHelper.lib_dir}/jasmine*.js").first)] +
|
|
||||||
['/lib/json2.js',
|
|
||||||
'/lib/TrivialReporter.js']
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.root
|
|
||||||
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'jasmine'))
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.spec_dir
|
|
||||||
File.expand_path('spec')
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.spec_files
|
|
||||||
Dir.glob(File.join(spec_dir, "javascripts/**/*[Ss]pec.js"))
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.specs
|
|
||||||
spec_files.collect {|f| f.sub(spec_dir, "/spec")}
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.spec_helpers_files
|
|
||||||
Dir.glob(File.join(spec_dir, "helpers/**/*.js"))
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.spec_helpers
|
|
||||||
spec_helpers_files.collect {|f| f.sub(spec_dir, "/spec")}
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.meta_spec_path
|
|
||||||
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'jasmine', 'jasmine_meta_spec.rb'))
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.files
|
|
||||||
[]
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.stylesheets
|
|
||||||
[]
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
|
@ -1,30 +0,0 @@
|
||||||
require 'rubygems'
|
|
||||||
require "selenium_rc"
|
|
||||||
require File.expand_path(File.join(File.dirname(__FILE__), "jasmine_helper.rb"))
|
|
||||||
helper_overrides = File.expand_path(File.join(Dir.pwd, "spec", "helpers", "jasmine_helper.rb"))
|
|
||||||
if File.exist?(helper_overrides)
|
|
||||||
require helper_overrides
|
|
||||||
end
|
|
||||||
require File.expand_path(File.join(File.dirname(__FILE__), "jasmine_runner.rb"))
|
|
||||||
require File.expand_path(File.join(File.dirname(__FILE__), "spec_builder"))
|
|
||||||
|
|
||||||
jasmine_runner = Jasmine::Runner.new(SeleniumRC::Server.new.jar_path,
|
|
||||||
Dir.pwd,
|
|
||||||
JasmineHelper.specs,
|
|
||||||
{ :spec_helpers => JasmineHelper.files + JasmineHelper.spec_helpers,
|
|
||||||
:stylesheets => JasmineHelper.stylesheets
|
|
||||||
})
|
|
||||||
|
|
||||||
spec_builder = Jasmine::SpecBuilder.new(JasmineHelper.spec_files, jasmine_runner)
|
|
||||||
|
|
||||||
should_stop = false
|
|
||||||
|
|
||||||
Spec::Runner.configure do |config|
|
|
||||||
config.after(:suite) do
|
|
||||||
spec_builder.stop if should_stop
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
spec_builder.start
|
|
||||||
should_stop = true
|
|
||||||
spec_builder.declare_suites
|
|
|
@ -38,7 +38,7 @@ module Jasmine
|
||||||
escaped_script = "'" + script.gsub(/(['\\])/) { '\\' + $1 } + "'"
|
escaped_script = "'" + script.gsub(/(['\\])/) { '\\' + $1 } + "'"
|
||||||
|
|
||||||
result = @driver.get_eval("try { eval(#{escaped_script}, window); } catch(err) { window.eval(#{escaped_script}); }")
|
result = @driver.get_eval("try { eval(#{escaped_script}, window); } catch(err) { window.eval(#{escaped_script}); }")
|
||||||
JSON.parse("[#{result}]")[0]
|
JSON.parse("{\"result\":#{result}}")["result"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -101,6 +101,7 @@ module Jasmine
|
||||||
thin_config["/__JASMINE_ROOT__"] = Rack::File.new(Jasmine.root)
|
thin_config["/__JASMINE_ROOT__"] = Rack::File.new(Jasmine.root)
|
||||||
|
|
||||||
app = Rack::Cascade.new([
|
app = Rack::Cascade.new([
|
||||||
|
Rack::URLMap.new({'/' => Rack::File.new(@config.src_dir)}),
|
||||||
Rack::URLMap.new(thin_config),
|
Rack::URLMap.new(thin_config),
|
||||||
JsAlert.new
|
JsAlert.new
|
||||||
])
|
])
|
||||||
|
|
|
@ -58,7 +58,7 @@ module Jasmine
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
end
|
end
|
||||||
|
|
||||||
@suites = eval_js('JSON.stringify(jsApiReporter.suites())')
|
@suites = eval_js("var result = jsApiReporter.suites(); if (window.Prototype && Object.toJSON) { Object.toJSON(result) } else { JSON.stringify(result) }")
|
||||||
end
|
end
|
||||||
|
|
||||||
def results_for(spec_id)
|
def results_for(spec_id)
|
||||||
|
@ -69,7 +69,7 @@ module Jasmine
|
||||||
def load_results
|
def load_results
|
||||||
@spec_results = {}
|
@spec_results = {}
|
||||||
@spec_ids.each_slice(50) do |slice|
|
@spec_ids.each_slice(50) do |slice|
|
||||||
@spec_results.merge!(eval_js("JSON.stringify(jsApiReporter.resultsForSpecs(#{JSON.generate(slice)}))"))
|
@spec_results.merge!(eval_js("var result = jsApiReporter.resultsForSpecs(#{JSON.generate(slice)}); if (window.Prototype && Object.toJSON) { Object.toJSON(result) } else { JSON.stringify(result) }"))
|
||||||
end
|
end
|
||||||
@spec_results
|
@spec_results
|
||||||
end
|
end
|
||||||
|
@ -116,7 +116,6 @@ module Jasmine
|
||||||
|
|
||||||
def report_spec(spec_id)
|
def report_spec(spec_id)
|
||||||
spec_results = results_for(spec_id)
|
spec_results = results_for(spec_id)
|
||||||
|
|
||||||
out = ""
|
out = ""
|
||||||
messages = spec_results['messages'].each do |message|
|
messages = spec_results['messages'].each do |message|
|
||||||
case
|
case
|
||||||
|
|
|
@ -2,52 +2,76 @@ require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
||||||
|
|
||||||
describe Jasmine::Config do
|
describe Jasmine::Config do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@template_dir = File.expand_path(File.join(File.dirname(__FILE__), "../templates"))
|
@template_dir = File.expand_path(File.join(File.dirname(__FILE__), "../generators/jasmine/templates"))
|
||||||
@config = Jasmine::Config.new
|
@config = Jasmine::Config.new
|
||||||
@config.stub!(:src_dir).and_return(File.join(@template_dir, "public"))
|
@config.stub!(:src_dir).and_return(File.join(@template_dir, "public"))
|
||||||
@config.stub!(:spec_dir).and_return(File.join(@template_dir, "spec"))
|
@config.stub!(:spec_dir).and_return(File.join(@template_dir, "spec"))
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should provide a list of all src and spec files" do
|
describe "simple_config" do
|
||||||
@config.src_files.should == ['javascripts/Example.js']
|
it "if sources.yaml not found" do
|
||||||
@config.spec_files.should == ['javascript/ExampleSpec.js', 'javascript/SpecHelper.js']
|
File.stub!(:exist?).and_return(false)
|
||||||
|
@config.src_files.should == []
|
||||||
|
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
||||||
|
@config.mappings.should == {
|
||||||
|
'/__root__' => @config.project_root,
|
||||||
|
'/__spec__' => @config.spec_dir
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it "if sources.yaml is empty" do
|
||||||
|
YAML.stub!(:load).and_return(false)
|
||||||
|
@config.src_files.should == []
|
||||||
|
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
||||||
|
@config.mappings.should == {
|
||||||
|
'/__root__' => @config.project_root,
|
||||||
|
'/__spec__' => @config.spec_dir
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it "using default sources.yaml" do
|
||||||
|
@config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/sources.yaml'))
|
||||||
|
@config.src_files.should == []
|
||||||
|
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
||||||
|
@config.mappings.should == {
|
||||||
|
'/__root__' => @config.project_root,
|
||||||
|
'/__spec__' => @config.spec_dir
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it "using rails sources.yaml" do
|
||||||
|
@config.stub!(:simple_config_file).and_return(File.join(@template_dir, 'spec/javascripts/support/sources-rails.yaml'))
|
||||||
|
@config.src_files.should == ['javascripts/prototype.js',
|
||||||
|
'javascripts/effects.js',
|
||||||
|
'javascripts/controls.js',
|
||||||
|
'javascripts/dragdrop.js',
|
||||||
|
'javascripts/application.js']
|
||||||
|
@config.spec_files.should == ['javascripts/ExampleSpec.js', 'javascripts/SpecHelper.js']
|
||||||
|
@config.js_files.should == [
|
||||||
|
'/javascripts/prototype.js',
|
||||||
|
'/javascripts/effects.js',
|
||||||
|
'/javascripts/controls.js',
|
||||||
|
'/javascripts/dragdrop.js',
|
||||||
|
'/javascripts/application.js',
|
||||||
|
'/__spec__/javascripts/ExampleSpec.js',
|
||||||
|
'/__spec__/javascripts/SpecHelper.js',
|
||||||
|
]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
it "should provide dir mappings" do
|
||||||
|
@config.mappings.should == {
|
||||||
|
'/__root__' => @config.project_root,
|
||||||
|
'/__spec__' => @config.spec_dir
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should provide a list of all spec files with full paths" do
|
it "should provide a list of all spec files with full paths" do
|
||||||
@config.spec_files_full_paths.should == [
|
@config.spec_files_full_paths.should == [
|
||||||
File.join(@template_dir, 'spec/javascript/ExampleSpec.js'),
|
File.join(@template_dir, 'spec/javascripts/ExampleSpec.js'),
|
||||||
File.join(@template_dir, 'spec/javascript/SpecHelper.js')
|
File.join(@template_dir, 'spec/javascripts/SpecHelper.js')
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should provide a list of all js files" do
|
|
||||||
@config.js_files.should == [
|
|
||||||
'/src/javascripts/Example.js',
|
|
||||||
'/spec/javascript/ExampleSpec.js',
|
|
||||||
'/spec/javascript/SpecHelper.js',
|
|
||||||
]
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should provide dir mappings" do
|
|
||||||
@config.mappings.should == {
|
|
||||||
'/src' => @config.src_dir,
|
|
||||||
'/spec' => @config.spec_dir
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
it "should allow overriding src and spec paths" do
|
|
||||||
@config.stub!(:src_path).and_return("public")
|
|
||||||
@config.stub!(:spec_path).and_return("spekz")
|
|
||||||
|
|
||||||
@config.js_files.should == [
|
|
||||||
'/public/javascripts/Example.js',
|
|
||||||
'/spekz/javascript/ExampleSpec.js',
|
|
||||||
'/spekz/javascript/SpecHelper.js',
|
|
||||||
]
|
|
||||||
|
|
||||||
@config.mappings.should == {
|
|
||||||
'/public' => @config.src_dir,
|
|
||||||
'/spekz' => @config.spec_dir
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
|
@ -1,15 +1,15 @@
|
||||||
require 'jasmine'
|
require 'jasmine'
|
||||||
|
|
||||||
class JasmineSelfTestConfig < Jasmine::Config
|
class JasmineSelfTestConfig < Jasmine::Config
|
||||||
def proj_root
|
def project_root
|
||||||
File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
||||||
end
|
end
|
||||||
|
|
||||||
def src_dir
|
def src_dir
|
||||||
File.join(proj_root, 'src')
|
File.join(project_root, 'src')
|
||||||
end
|
end
|
||||||
|
|
||||||
def spec_dir
|
def spec_dir
|
||||||
File.join(proj_root, 'jasmine/spec')
|
File.join(project_root, 'jasmine/spec')
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,30 +0,0 @@
|
||||||
namespace :jasmine do
|
|
||||||
require 'jasmine'
|
|
||||||
helper_overrides = File.expand_path(File.join(File.dirname(__FILE__), "spec/helpers/jasmine_helper.rb"))
|
|
||||||
if File.exist?(helper_overrides)
|
|
||||||
require helper_overrides
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Run continuous integration tests"
|
|
||||||
require "spec"
|
|
||||||
require 'spec/rake/spectask'
|
|
||||||
Spec::Rake::SpecTask.new(:ci) do |t|
|
|
||||||
t.spec_opts = ["--color", "--format", "specdoc"]
|
|
||||||
t.verbose = true
|
|
||||||
t.spec_files = [JasmineHelper.meta_spec_path]
|
|
||||||
end
|
|
||||||
task :server do
|
|
||||||
puts "your tests are here:"
|
|
||||||
puts " http://localhost:8888/run.html"
|
|
||||||
|
|
||||||
Jasmine::Server.start(8888,
|
|
||||||
File.expand_path(Dir.pwd),
|
|
||||||
lambda { JasmineHelper.specs },
|
|
||||||
{ :spec_helpers => JasmineHelper.files + JasmineHelper.spec_helpers,
|
|
||||||
:stylesheets => JasmineHelper.stylesheets
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
desc "Run specs via server"
|
|
||||||
task :jasmine => ['jasmine:server']
|
|
|
@ -1,2 +0,0 @@
|
||||||
ExampleClass = function() {
|
|
||||||
};
|
|
|
@ -1,12 +0,0 @@
|
||||||
class JasmineHelper
|
|
||||||
def self.files
|
|
||||||
#return a list of files you want to load before your spec defintions load
|
|
||||||
[]
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.stylesheets
|
|
||||||
#return a list of stylesheets you want to load in the runner
|
|
||||||
[]
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
Loading…
Reference in New Issue