Rearrange, refactor, ruin and raze.
This commit is contained in:
parent
945b167131
commit
0c8258996e
11
Gemfile
11
Gemfile
|
@ -0,0 +1,11 @@
|
|||
gem "rake", "0.8.7"
|
||||
gem "jeweler", "1.4.0"
|
||||
gem "gemcutter", "0.2.1"
|
||||
|
||||
gem "rspec", ">= 1.1.5", :only => :testing
|
||||
gem "rack", ">= 1.0.0", :only => :testing
|
||||
gem "thin", ">= 1.2.4", :only => :testing
|
||||
gem "selenium-rc", ">=2.1.0", :only => :testing
|
||||
gem "selenium-client", ">=1.2.17", :only => :testing
|
||||
|
||||
disable_system_gems
|
82
Rakefile
82
Rakefile
|
@ -1,24 +1,66 @@
|
|||
namespace :jeweler do
|
||||
require "#{File.dirname(__FILE__)}/vendor/gems/environment"
|
||||
Bundler.require_env :rake
|
||||
|
||||
begin
|
||||
require 'jeweler'
|
||||
require 'rake'
|
||||
Jeweler::Tasks.new do |gemspec|
|
||||
gemspec.name = "jasmine-ruby"
|
||||
gemspec.summary = "Jasmine Ruby"
|
||||
gemspec.description = "Javascript BDD testings"
|
||||
gemspec.email = "ragaskar@gmail.com"
|
||||
gemspec.homepage = "http://github.com/ragaskar/jasmine-ruby"
|
||||
gemspec.description = "Jasmine Ruby"
|
||||
gemspec.authors = ["Rajan Agaskar"]
|
||||
gemspec.files = FileList.new('bin/*', 'lib/**/**', 'jasmine/lib/**', 'jasmine/contrib/ruby/**', 'tasks/**', 'templates/**')
|
||||
$LOAD_PATH.unshift File.expand_path("#{File.dirname(__FILE__)}/lib")
|
||||
|
||||
gemspec.add_dependency('rspec', '>= 1.1.5')
|
||||
gemspec.add_dependency('rack', '>= 1.0.0')
|
||||
gemspec.add_dependency('thin', '>= 1.2.4')
|
||||
end
|
||||
Jeweler::GemcutterTasks.new
|
||||
rescue LoadError
|
||||
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
||||
require 'spec'
|
||||
require 'spec/rake/spectask'
|
||||
|
||||
desc "Run all examples"
|
||||
Spec::Rake::SpecTask.new('spec') do |t|
|
||||
t.spec_files = FileList['spec/**/*.rb']
|
||||
end
|
||||
|
||||
namespace :jasmine do
|
||||
# require 'jasmine'
|
||||
require 'spec/jasmine_self_test_runner'
|
||||
|
||||
# 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"
|
||||
|
||||
JasmineSelfTestRunner.new.start_server
|
||||
end
|
||||
end
|
||||
|
||||
desc "Run specs via server"
|
||||
task :jasmine => ['jasmine:server']
|
||||
|
||||
|
||||
namespace :jeweler do
|
||||
|
||||
unless File.exists?('jasmine/lib')
|
||||
raise "Jasmine submodule isn't present. Run git submodule init && git submodule update."
|
||||
end
|
||||
|
||||
require 'jeweler'
|
||||
require 'rake'
|
||||
|
||||
Jeweler::Tasks.new do |gemspec|
|
||||
gemspec.name = "xian-test-jasmine"
|
||||
gemspec.summary = "Jasmine Ruby"
|
||||
gemspec.description = "Javascript BDD testings"
|
||||
gemspec.email = "ragaskar@gmail.com"
|
||||
gemspec.homepage = "http://github.com/ragaskar/jasmine-ruby"
|
||||
gemspec.description = "Jasmine Ruby"
|
||||
gemspec.authors = ["Rajan Agaskar"]
|
||||
gemspec.files = FileList.new('bin/*', 'lib/**/**', 'jasmine/lib/**', 'jasmine/contrib/ruby/**', 'tasks/**', 'templates/**')
|
||||
|
||||
gemspec.add_dependency('rspec', '>= 1.1.5')
|
||||
gemspec.add_dependency('rack', '>= 1.0.0')
|
||||
gemspec.add_dependency('thin', '>= 1.2.4')
|
||||
gemspec.add_dependency('selenium-rc', '>=2.1.0')
|
||||
gemspec.add_dependency('selenium-client', '>=1.2.17')
|
||||
end
|
||||
|
||||
Jeweler::GemcutterTasks.new
|
||||
end
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = %q{jasmine-ruby}
|
||||
s.name = %q{jasmine}
|
||||
s.version = "0.1.0"
|
||||
|
||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||
s.authors = ["Rajan Agaskar"]
|
||||
s.date = %q{2009-11-26}
|
||||
s.date = %q{2009-12-27}
|
||||
s.default_executable = %q{jasmine}
|
||||
s.description = %q{Jasmine Ruby}
|
||||
s.email = %q{ragaskar@gmail.com}
|
||||
|
@ -19,26 +19,23 @@ Gem::Specification.new do |s|
|
|||
]
|
||||
s.files = [
|
||||
"bin/jasmine",
|
||||
"jasmine/contrib/ruby/jasmine_runner.rb",
|
||||
"jasmine/contrib/ruby/jasmine_spec_builder.rb",
|
||||
"jasmine/contrib/ruby/run.html",
|
||||
"jasmine/lib/TrivialReporter.js",
|
||||
"jasmine/lib/consolex.js",
|
||||
"jasmine/lib/jasmine-0.10.0.js",
|
||||
"jasmine/lib/jasmine.css",
|
||||
"jasmine/lib/json2.js",
|
||||
"lib/jasmine-ruby.rb",
|
||||
"lib/jasmine-ruby/jasmine_helper.rb",
|
||||
"lib/jasmine-ruby/jasmine_meta_spec.rb",
|
||||
"lib/jasmine-ruby/jasmine_runner.rb",
|
||||
"lib/jasmine-ruby/jasmine_spec_builder.rb",
|
||||
"lib/jasmine-ruby/run.html",
|
||||
"lib/jasmine.rb",
|
||||
"lib/jasmine/jasmine_helper.rb",
|
||||
"lib/jasmine/jasmine_meta_spec.rb",
|
||||
"lib/jasmine/jasmine_runner.rb",
|
||||
"lib/jasmine/jasmine_spec_builder.rb",
|
||||
"lib/jasmine/run.html",
|
||||
"templates/Rakefile",
|
||||
"templates/example_spec.js",
|
||||
"templates/jasmine_helper.rb",
|
||||
"templates/spec_helper.js"
|
||||
]
|
||||
s.homepage = %q{http://github.com/ragaskar/jasmine-ruby}
|
||||
s.homepage = %q{http://github.com/ragaskar/jasmine}
|
||||
s.rdoc_options = ["--charset=UTF-8"]
|
||||
s.require_paths = ["lib"]
|
||||
s.rubygems_version = %q{1.3.5}
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
require 'jasmine-ruby/jasmine_helper'
|
||||
require 'jasmine-ruby/jasmine_runner'
|
||||
require 'jasmine-ruby/jasmine_spec_builder'
|
|
@ -0,0 +1,3 @@
|
|||
require 'jasmine/jasmine_helper'
|
||||
require 'jasmine/jasmine_runner'
|
||||
require 'jasmine/jasmine_spec_builder'
|
|
@ -34,7 +34,7 @@ class JasmineHelper
|
|||
end
|
||||
|
||||
def self.meta_spec_path
|
||||
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'jasmine-ruby', 'jasmine_meta_spec.rb'))
|
||||
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'jasmine', 'jasmine_meta_spec.rb'))
|
||||
end
|
||||
|
||||
def self.files
|
|
@ -148,27 +148,22 @@ module Jasmine
|
|||
end
|
||||
|
||||
class SimpleServer
|
||||
def self.start(port, root_path, spec_files_or_proc, options = {})
|
||||
def self.start(port, spec_files_or_proc, options = {})
|
||||
require 'thin'
|
||||
config = {
|
||||
'/__suite__' => Jasmine::FocusedSuite.new(spec_files_or_proc, options),
|
||||
'/run.html' => Jasmine::Redirect.new('/'),
|
||||
'/' => Jasmine::RunAdapter.new(spec_files_or_proc, options)
|
||||
}
|
||||
if (options[:mappings])
|
||||
options[:mappings].each do |from, to|
|
||||
config[from] = Rack::File.new(to)
|
||||
end
|
||||
|
||||
raise "Need :mappings!" unless options[:mappings]
|
||||
options[:mappings].each do |from, to|
|
||||
config[from] = Rack::File.new(to)
|
||||
end
|
||||
|
||||
config["/__JASMINE_ROOT__"] = Rack::File.new(Jasmine.root)
|
||||
|
||||
file_serve_config = {
|
||||
'/' => Rack::File.new(root_path)
|
||||
}
|
||||
|
||||
app = Rack::Cascade.new([
|
||||
Rack::URLMap.new(file_serve_config),
|
||||
Rack::URLMap.new(config),
|
||||
JsAlert.new
|
||||
])
|
||||
|
@ -226,17 +221,24 @@ module Jasmine
|
|||
end
|
||||
|
||||
class Runner
|
||||
def initialize(selenium_jar_path, root_path, spec_files, options={})
|
||||
@root_path = root_path
|
||||
@selenium_jar_path = selenium_jar_path
|
||||
def initialize(options = {})
|
||||
require 'selenium_rc'
|
||||
@selenium_jar_path = SeleniumRC::Server.allocate.jar_path
|
||||
@spec_files = spec_files
|
||||
@options = options
|
||||
|
||||
@browser = options[:browser] ? options[:browser].delete(:browser) : 'firefox'
|
||||
@browser = options[:browser] ? options.delete(:browser) : 'firefox'
|
||||
@selenium_pid = nil
|
||||
@jasmine_server_pid = nil
|
||||
end
|
||||
|
||||
def start_server(port = 8888)
|
||||
p spec_files
|
||||
Jasmine::SimpleServer.start(port, lambda { spec_files }, :mappings => {
|
||||
"/spec" => spec_dir
|
||||
})
|
||||
end
|
||||
|
||||
def start
|
||||
start_servers
|
||||
@client = Jasmine::SimpleClient.new("localhost", @selenium_server_port, "*#{@browser}", "http://localhost:#{@jasmine_server_port}/")
|
||||
|
@ -260,7 +262,7 @@ module Jasmine
|
|||
|
||||
@jasmine_server_pid = fork do
|
||||
Process.setpgrp
|
||||
Jasmine::SimpleServer.start(@jasmine_server_port, @root_path, @spec_files, @options)
|
||||
Jasmine::SimpleServer.start(@jasmine_server_port, @spec_files, @options)
|
||||
exit! 0
|
||||
end
|
||||
puts "jasmine server started. pid is #{@jasmine_server_pid}"
|
|
@ -4,8 +4,8 @@ module Jasmine
|
|||
class SpecBuilder
|
||||
attr_accessor :suites
|
||||
|
||||
def initialize(spec_files, runner)
|
||||
@spec_files = spec_files
|
||||
def initialize(runner)
|
||||
@spec_files = runner.spec_files
|
||||
@runner = runner
|
||||
@spec_ids = []
|
||||
end
|
|
@ -0,0 +1,27 @@
|
|||
require 'jasmine'
|
||||
|
||||
class JasmineSelfTestRunner < Jasmine::Runner
|
||||
def proj_root
|
||||
File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
||||
end
|
||||
|
||||
def src_dir
|
||||
File.join(proj_root, 'src')
|
||||
end
|
||||
|
||||
def src_files
|
||||
Dir.glob(File.join(src_dir, "**/*.js"))
|
||||
end
|
||||
|
||||
def spec_dir
|
||||
File.join(proj_root, 'jasmine/spec')
|
||||
end
|
||||
|
||||
def spec_files
|
||||
Dir.glob(File.join(spec_dir, "**/*[Ss]pec.js")).collect { |f| f.sub("#{spec_dir}/", "") }
|
||||
end
|
||||
#
|
||||
# def specs
|
||||
# Jasmine.cachebust(spec_files).collect {|f| f.sub(spec_dir, "/spec")}
|
||||
# end
|
||||
end
|
|
@ -1,17 +1,7 @@
|
|||
require 'rubygems'
|
||||
require "selenium_rc"
|
||||
require 'jasmine_self_test_runner'
|
||||
|
||||
JASMINE_SPEC_DIR = File.join(File.dirname(__FILE__), "..", "jasmine", "spec")
|
||||
|
||||
require File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "jasmine-ruby", "jasmine_helper.rb"))
|
||||
require File.expand_path(File.join(JasmineHelper.root, "contrib/ruby/jasmine_spec_builder"))
|
||||
|
||||
jasmine_runner = Jasmine::Runner.new(SeleniumRC::Server.new.jar_path,
|
||||
JasmineHelper.spec_file_urls,
|
||||
JasmineHelper.dir_mappings,
|
||||
:spec_helpers => JasmineHelper.spec_helpers)
|
||||
|
||||
spec_builder = Jasmine::SpecBuilder.new(JasmineHelper.raw_spec_files, jasmine_runner)
|
||||
jasmine_runner = JasmineSelfTestRunner.new
|
||||
spec_builder = Jasmine::SpecBuilder.new(jasmine_runner)
|
||||
|
||||
should_stop = false
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
namespace :jasmine do
|
||||
require 'jasmine-ruby'
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue