Compare commits

...

38 Commits

Author SHA1 Message Date
ragaskar
41f496001f Version bump to 1.1.0 2011-09-10 13:51:11 -04:00
ragaskar
6b5956724b Version bump to rc4 2011-09-01 07:26:07 -04:00
Rajan Agaskar
ec24992250 Merge pull request #123 from Osukaru/master
fixed html comments in SpecRunner.html example
2011-09-01 04:23:41 -07:00
Osukaru
83f232237d fixed html comments 2011-08-26 01:22:11 +03:00
Rajan Agaskar
98d32bb4a4 Merge pull request #111 from qfox/patch-1
Add missing semi.
2011-07-21 04:07:52 -07:00
qfox
c4f27ae377 ASI trolling 2011-07-21 00:58:53 -07:00
ragaskar
a075c75bce Version bump to 1.1.0.rc3 2011-07-13 07:23:29 -04:00
ragaskar
a617b59e6a Bump to rc2 2011-06-24 21:34:29 -04:00
ragaskar
917b37481e Update rake 2011-06-24 21:25:06 -04:00
ragaskar
67bbc98faa Bump version 2011-06-24 21:22:19 -04:00
Davis W. Frank
620f7b6e4c Updates to Pages; Updates to docs; 2011-06-23 19:02:17 -07:00
ragaskar
b722f416c7 Write out version.rb on dist build 2011-06-23 07:55:04 -04:00
ragaskar
634a7dc402 Rollback pages submodule bump 2011-06-23 07:32:05 -04:00
Davis W. Frank
a4522e4dce Updated Release readme 2011-06-21 20:19:28 -07:00
Davis W. Frank
e113c338d0 Merge branch 'master' of github.com:pivotal/jasmine 2011-06-21 20:11:10 -07:00
ragaskar
b81f690a25 Require JSON in time for the gemspec 2011-06-21 08:05:41 -04:00
ragaskar
c06e189699 Ignore tags 2011-06-21 08:05:20 -04:00
Davis W. Frank
67b6cfb828 Improve the rake standalone task 2011-06-20 18:27:57 -07:00
Davis W. Frank
57e622fb2a Fix to version structure for "release_candidate" 2011-06-20 18:17:24 -07:00
Davis W. Frank
c0664dd6aa merge 2011-06-20 08:46:37 -07:00
Davis W. Frank
b640ce6fc0 wip on readme for release 2011-06-20 07:32:40 -07:00
ragaskar
e9af7834f5 Better argument handling in Jasmine::Core#spec_files 2011-06-18 09:43:14 -04:00
ragaskar
0d43ae9c38 Give Jasmine::Core access to jasmine specs
[#13128217]
2011-06-18 09:39:23 -04:00
ragaskar
30431a3958 Gem-ize jasmine
[Finishes #13128217]
2011-06-17 21:01:42 -04:00
Davis W. Frank
3775919c92 remove old, commented-out tasks 2011-06-17 08:23:17 -07:00
Davis W. Frank
a692ff8c95 Need HAML in the Gemfile; continued fixes to the Rake tasks 2011-06-17 08:20:22 -07:00
Davis W. Frank
e4e9b51544 rename TrivialConsoleReporter to ConsoleReporter 2011-06-16 22:35:57 -07:00
Davis W. Frank
0b97951766 Better coloring of output of Rake tasks; Turn off colored output in Rake tasks if not on a TTY (not sure if it works in Hudson); Add support to TCR for turning off colors since there is code to calc options but it wasn't used; NOTE: coloring in TCR should be MUCH better tested. 2011-06-16 22:34:11 -07:00
Davis W. Frank
75dd391d57 should fix red build 2011-06-16 08:33:59 -07:00
Davis W. Frank
ae24e00c0f Support for release candidates in the version.json file; propagates up through the version string everywhere: filenames, ZIP, source code 2011-06-15 18:37:12 -07:00
Davis W. Frank
6b2e45eab5 Refactor of standalone build tasks; Better templating of the core runner.html and the example SpecRunner.html 2011-06-15 09:15:40 -07:00
Davis W. Frank
e59171935f breaking up distribution tasks; moving version to a template to have a simpler concat function 2011-06-14 08:30:14 -07:00
Davis W. Frank
2ba0aa371c Refactor how the distribution is built 2011-06-13 08:23:10 -07:00
Davis W. Frank
c2ed71717f Remove link to github page from Runner 2011-06-11 16:51:16 -07:00
Davis W. Frank
09e8822107 WIP on new Contribution docs 2011-06-11 16:47:12 -07:00
Davis W. Frank
15763c2eb0 Output number of expected specs for browser, node before running specs. NOTE: We distribution tasks still broken. 2011-06-11 15:59:34 -07:00
Davis W. Frank
3f264cde34 fix so that all specs are pulled into runner.html 2011-06-11 14:48:41 -07:00
Davis W. Frank
f83cb7f766 Runner.html is now generated (ensures all source & specs get tested); beginnings of refactoring of Rake tasks. 2011-06-09 19:24:51 -07:00
49 changed files with 723 additions and 436 deletions

5
.gitignore vendored
View File

@@ -5,3 +5,8 @@ site/
.bundle/
.pairs
.rvmrc
*.gem
.bundle
tags
Gemfile.lock
pkg/*

44
Contribute.markdown Normal file
View File

@@ -0,0 +1,44 @@
# Developing for Jasmine Core
## How to Contribute
We welcome your contributions - Thanks for helping make Jasmine a better project for everyone. Please review the backlog and discussion lists (the main group - [http://groups.google.com/group/jasmine-js](http://groups.google.com/group/jasmine-js) and the developer's list - [http://groups.google.com/group/jasmine-js-dev](http://groups.google.com/group/jasmine-js-dev)) before starting work - what you're looking for may already have been done. If it hasn't, the community can help make your contribution better.
## How to write new Jasmine code
Or, How to make a successful pull request
* _Do not change the public interface_. Lots of projects depend on Jasmine and if you aren't careful you'll break them
* _Be environment agnostic_ - server-side developers are just as important as browser developers
* _Be browser agnostic_ - if you must rely on browser-specific functionality, please write it in a way that degrades gracefully
* _Write specs_ - Jasmine's a testing framework; don't add functionality without test-driving it
* _Ensure the *entire* test suite is green_ in all the big browsers, Node, and JSHint - your contribution shouldn't break Jasmine for other users
Follow these tips and your pull request, patch, or suggestion is much more likely to be integrated.
## Environment
Ruby, RubyGems and Rake are used in order to script the various file interactions. You will need to run on a system that supports Ruby in order to run Jasmine's specs.
Node.js is used to run most of the specs (the HTML-independent code) and should be present. Additionally, the JS Hint project scrubs the source code as part of the spec process.
## Development
All source code belongs in `src/`. The `core/` directory contains the bulk of Jasmine's functionality. This code should remain browser- and environment-agnostic. If your feature or fix cannot be, as mentioned above, please degrade gracefully. Any code that should only be in a non-browser environment should live in `src/console/`. Any code that depends on a browser (specifically, it expects `window` to be the global or `document` is present) should live in `src/html/`.
Please respect the code patterns as possible. For example, using `jasmine.getGlobal()` to get the global object so as to remain environment agnostic.
## Running Specs
As in all good projects, the `spec/` directory mirrors `src/` and follows the same rules. The browser runner will include and attempt to run all specs. The node runner will exclude any html-dependent specs (those in `spec/html/`).
You will notice that all specs are run against the built `jasmine.js` instead of the component source files. This is intentional as a way to ensure that the concatenation code is working correctly.
Please ensure all specs are green before committing.
There are rake tasks to help with getting green:
* `rake spec` outputs the expected number of specs that should be run and attempts to run in browser and Node
* `rake spec:browser` opens `spec/runner.html` in the default browser on MacOS. Please run this in at least Firefox and Chrome before committing
* `rake spec:node` runs all the Jasmine specs in Node.js - it will complain if Node is not installed
* `rake hint` runs all the files through JSHint and will complain about potential viable issues with your code. Fix them.

View File

@@ -1,6 +1,4 @@
source :rubygems
gem "json_pure", "~>1.4.3"
gem "frank"
gem "ragaskar-jsdoc_helper"
gem "rake", "0.8.7"
gem "term-ansicolor", :require => "term/ansicolor"
gem "rake"
gemspec

View File

@@ -1,33 +0,0 @@
GEM
remote: http://rubygems.org/
specs:
daemons (1.0.10)
frank (1.0.8)
haml (>= 3.0)
mongrel (>= 1.2.0.pre2)
net-scp (>= 1.0)
net-ssh (>= 2.0)
rack (>= 1.0)
tilt (= 0.9)
gem_plugin (0.2.3)
haml (3.0.25)
json_pure (1.4.6)
mongrel (1.2.0.pre2)
daemons (~> 1.0.10)
gem_plugin (~> 0.2.3)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-ssh (2.1.0)
rack (1.2.1)
ragaskar-jsdoc_helper (0.0.2.1)
rake (0.8.7)
tilt (0.9)
PLATFORMS
ruby
DEPENDENCIES
frank
json_pure (~> 1.4.3)
ragaskar-jsdoc_helper
rake (= 0.8.7)

View File

@@ -1,49 +0,0 @@
1. Ensure all specs are green in browsers & Node.js (via rake tasks)
1. Ensure CI is green
1.
## Development
## Release
# Making a Release of Jasmine Core
'Jasmine' is the Github repo for Jasmine Core and contains all the JavaScript code for the Jasmine BDD framework.
It also contains two HTML pages for the Github Pages at http://pivotal.github.com/jasmine.
## The Repo
All of the JS for Jasmine is in the src directory. The specs for each file are in the specs directory. There are rake tasks to build the various files for distribution.
## Running Specs
There are rake tasks to help with getting green:
* `rake spec:browser` opens `spec/runner.html` in the default browser. Please run this in at least Firefox and Chrome before comitting
* `rake spec:node` runs all the Jasmine specs in Node.js
* `rake jasmine:lint` runs all the files through JSHint and will complain about potential viable issues with your code. Fix them.
## The Pages
Github pages have to exist in a branch called gh-pages in order for their app to serve them. This repo adds that branch as a submodule under the `pages` directory. This is a bit of a hack, but it allows us to work with the pages and the source at the same time and with one set of rake tasks.
If you want to submit changes to this repo and aren't a Pivotal Labs employee, you can fork and work in the gh-pages branch. You won't be able to edit the pages in the submodule off of master.
The pages are built with [Frank](https://github.com/blahed/frank). All the source for these pages live in the pages_source directory.
## Releasing
Once all specs are green and you've updated the version in `version.json`, you need to run the rake task to make a distribution: `rake jasmine:dist`.

View File

@@ -6,6 +6,13 @@ Jasmine is a Behavior Driven Development testing framework for JavaScript. It do
Documentation & guides live here: [http://pivotal.github.com/jasmine/](http://pivotal.github.com/jasmine/)
## What's Here?
*
## Support
* Search past discussions: [http://groups.google.com/group/jasmine-js](http://groups.google.com/group/jasmine-js)
@@ -14,32 +21,6 @@ Documentation & guides live here: [http://pivotal.github.com/jasmine/](http://pi
* View the project backlog at Pivotal Tracker: [http://www.pivotaltracker.com/projects/10606](http://www.pivotaltracker.com/projects/10606)
* Follow us on Twitter: [@JasmineBDD](http://twitter.com/JasmineBDD)
## How to Contribute
We welcome your contributions - Thanks for helping make Jasmine a better project for everyone. Please review the backlog and discussion lists (the main group - [http://groups.google.com/group/jasmine-js](http://groups.google.com/group/jasmine-js) and the developer's list - [http://groups.google.com/group/jasmine-js-dev](http://groups.google.com/group/jasmine-js-dev)) before starting work - what you're looking for may already have been done. If it hasn't, the community can help make your contribution better.
### Development Environment
Jasmine Core relies on Ruby for executing the test suite and building the project for release. The spec suite runs in any major, modern browser (Firefox, Safari, Chrome, and yes various IE's) and in [Node.js](http://nodejs.org). While you probably have browsers installed, you want to make sure that Ruby and Node are present.
### How to Develop for Jasmine Core
* Write specs
* Make them pass in a browser (or three):
* open `spec/runner.html` in your browsers
* `rake spec:browser` will run in the default browser on MacOS
* Make them pass in Node: `rake spec:node`
* Fix any warnings or errors from JSHint: `rake jasmine:lint`
Running `rake spec` will run the browser tests, then run specs in Node, then run JSHint. But this will only run in the default browser and only on MacOS (for now).
### Making a Successful Pull Request
* __Include specs for your work__ - it helps us understand your intent and makes sure that future development doesn't break your work
* __Ensure the full test suite is green__ in all the big browsers, Node, and JSHint - your contribution shouldn't break Jasmine for other users
Do these things and we'll take a look.
## Maintainers

187
Rakefile
View File

@@ -1,170 +1,33 @@
require 'json'
require "bundler"
Bundler::GemHelper.install_tasks
require "term/ansicolor"
require "json"
require "tilt"
def jasmine_sources
first_sources = JSON.parse(File.read('src/SourcesList.json')).collect {|f| "src/core/#{f}"}
sources = first_sources
sources += Dir.glob('src/core/*.js').reject {|f| first_sources.include?(f)}.sort
sources
end
def jasmine_html_sources
["src/html/TrivialReporter.js"]
end
def jasmine_version
"#{version_hash['major']}.#{version_hash['minor']}.#{version_hash['build']}"
end
def version_hash
require 'json'
@version ||= JSON.parse(File.new("src/core/version.json").read);
end
def substitute_jasmine_version(filename)
contents = File.read(filename)
contents = contents.gsub(/##JASMINE_VERSION##/, (jasmine_version))
contents = contents.gsub(/[^\n]*REMOVE_THIS_LINE_FROM_BUILD[^\n]*/, '')
File.open(filename, 'w') { |f| f.write(contents) }
Dir["#{File.dirname(__FILE__)}/tasks/**/*.rb"].each do |file|
require file
end
task :default => :spec
desc "Run spec suite: Browser, Node, JSHint"
task :spec => ["jasmine:build", "spec:node", "spec:browser"]
namespace :spec do
desc 'Run specs in Node.js'
task :node do
raise "Node is required to run all jasmine specs" unless system("node spec/node_suite.js")
end
desc "Run specs in the default browser (MacOS only)"
task :browser do
system("open spec/runner.html")
end
task :require_pages_submodule do
raise "Submodule for Github Pages isn't present. Run git submodule update --init" unless pages_submodule_present
end
namespace :jasmine do
desc 'Prepares for distribution'
task :dist => ['jasmine:build',
'jasmine:doc',
'jasmine:build_pages',
'jasmine:build_example_project',
'jasmine:fill_index_downloads']
desc 'Check jasmine sources for coding problems'
task :lint do
puts "Running JSHint via Node.js"
system("node jshint/run.js") || exit(1)
end
desc "Alias to JSHint"
task :hint => :lint
desc 'Builds lib/jasmine from source'
task :build => :lint do
puts 'Building Jasmine from source'
sources = jasmine_sources
version = version_hash
File.open("lib/jasmine.js", 'w') do |jasmine|
sources.each do |source_filename|
jasmine.puts(File.read(source_filename))
end
jasmine.puts %{
jasmine.version_= {
"major": #{version['major'].to_json},
"minor": #{version['minor'].to_json},
"build": #{version['build'].to_json},
"revision": #{Time.now.to_i}
};
}
end
File.open("lib/jasmine-html.js", 'w') do |jasmine_html|
jasmine_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
downloads_file = 'pages/download.html'
task :need_pages_submodule do
unless File.exist?(downloads_file)
raise "Jasmine pages submodule isn't present. Run git submodule update --init"
end
end
desc "Build the Github pages HTML"
task :build_pages => :need_pages_submodule do
Dir.chdir("pages") do
FileUtils.rm_r('pages_output') if File.exist?('pages_output')
Dir.chdir('pages_source') do
system("frank export ../pages_output")
end
puts "\nCopying Frank output to the root of the gh-pages branch\n\n"
system("cp -r pages_output/* .")
end
end
desc "Build jasmine documentation"
task :doc => :need_pages_submodule do
puts 'Creating Jasmine Documentation'
require 'rubygems'
require 'jsdoc_helper'
FileUtils.rm_r "pages/jsdoc", :force => true
JsdocHelper::Rake::Task.new(:lambda_jsdoc) do |t|
t[:files] = jasmine_sources << jasmine_html_sources
t[:options] = "-a"
t[:out] = "pages/jsdoc"
# JsdocHelper bug: template must be relative to the JsdocHelper gem, ick
t[:template] = File.join("../".*(100), Dir::getwd, "jsdoc-template")
end
Rake::Task[:lambda_jsdoc].invoke
end
desc "Build example project"
task :build_example_project => :need_pages_submodule do
require 'tmpdir'
temp_dir = File.join(Dir.tmpdir, 'jasmine-standalone-project')
puts "Building Example Project in #{temp_dir}"
FileUtils.rm_r temp_dir if File.exist?(temp_dir)
Dir.mkdir(temp_dir)
root = File.expand_path(File.dirname(__FILE__))
FileUtils.cp_r File.join(root, 'example/.'), File.join(temp_dir)
substitute_jasmine_version(File.join(temp_dir, "SpecRunner.html"))
lib_dir = File.join(temp_dir, "lib/jasmine-#{jasmine_version}")
FileUtils.mkdir_p(lib_dir)
{
"lib/jasmine.js" => "jasmine.js",
"lib/jasmine-html.js" => "jasmine-html.js",
"src/html/jasmine.css" => "jasmine.css",
"MIT.LICENSE" => "MIT.LICENSE"
}.each_pair do |src, dest|
FileUtils.cp(File.join(root, src), File.join(lib_dir, dest))
end
dist_dir = File.join(root, 'pages/downloads')
zip_file_name = File.join(dist_dir, "jasmine-standalone-#{jasmine_version}.zip")
puts "Zipping Example Project and moving to #{zip_file_name}"
FileUtils.mkdir(dist_dir) unless File.exist?(dist_dir)
if File.exist?(zip_file_name)
puts "WARNING!!! #{zip_file_name} already exists!"
FileUtils.rm(zip_file_name)
end
exec "cd #{temp_dir} && zip -r #{zip_file_name} . -x .[a-zA-Z0-9]*"
end
task :require_node do
raise "\nNode.js is required to develop code for Jasmine. Please visit http://nodejs.org to install.\n\n" unless node_installed?
end
def pages_submodule_present
File.exist?('pages/download.html')
end
def node_installed?
`which node` =~ /node/
end
class String
include Term::ANSIColor
end
Term::ANSIColor.coloring = STDOUT.isatty

40
Release.markdown Normal file
View File

@@ -0,0 +1,40 @@
# How to work on a Jasmine Release
## Development
___Jasmine Core Maintainers Only___
Follow the instructions in `Contribute.markdown` during development.
### Git Commits
### Version
We attempt to stick to [Semantic Versioning](). Most of the time, development should be against a new minor version - fixing bugs and adding new features that are backwards compatible.
The current version lives in the file `src/version.json`. This file should be set to the version that is _currently_ under development. That is, if version 1.0.0 is the current release then version should be incremented say, to 1.1.0.
This version is used by both `jasmine.js` and the `jasmine-core` Ruby gem.
### Update the Github Pages (as needed)
Github pages have to exist in a branch called gh-pages in order for their app to serve them. This repo adds that branch as a submodule under the `pages` directory. This is a bit of a hack, but it allows us to work with the pages and the source at the same time and with one set of rake tasks.
If you want to submit changes to this repo and aren't a Pivotal Labs employee, you can fork and work in the `gh-pages` branch. You won't be able to edit the pages in the submodule off of master.
The pages are built with [Frank](https://github.com/blahed/frank). All the source for these pages live in the `pages/pages_source` directory.
## Release
When ready to release - specs are all green and the stories are done:
1. Update the version in `version.json` to a release candidate - add an `rc` property with a value of 1
1. Update any comments on the public interfaces
1. `rake doc` - builds the `jsdoc` pages
1. Update any links or top-level landing page for the Github Pages
1. `rake standalone` - builds the standalone distribution ZIP file
1. `rake build_pages` - builds the Github Pages
1. `rake release` - tags the repo with the version, builds the `jasmine-core` gem, pushes the gem to Rubygems.org
There should be a post to Pivotal Labs blog and a tweet to that link.

View File

@@ -1,21 +0,0 @@
# Project-specific configuration for CruiseControl.rb
Project.configure do |project|
# Send email notifications about broken and fixed builds to email1@your.site, email2@your.site (default: send to nobody)
# project.email_notifier.emails = ['email1@your.site', 'email2@your.site']
# Set email 'from' field to john@doe.com:
# project.email_notifier.from = 'john@doe.com'
# Build the project by invoking rake task 'custom'
project.rake_task = 'jasmine:test:ci:saucelabs'
# Build the project by invoking shell script "build_my_app.sh". Keep in mind that when the script is invoked,
# current working directory is <em>[cruise&nbsp;data]</em>/projects/your_project/work, so if you do not keep build_my_app.sh
# in version control, it should be '../build_my_app.sh' instead
#project.build_command = 'cp ../saucelabs.yml .'
# Ping Subversion for new revisions every 5 minutes (default: 30 seconds)
# project.scheduler.polling_interval = 5.minutes
end

View File

@@ -1,27 +0,0 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Test Runner</title>
<link rel="stylesheet" type="text/css" href="lib/jasmine-##JASMINE_VERSION##/jasmine.css">
<script type="text/javascript" src="lib/jasmine-##JASMINE_VERSION##/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-##JASMINE_VERSION##/jasmine-html.js"></script>
<!-- include source files here... -->
<script type="text/javascript" src="src/Player.js"></script>
<script type="text/javascript" src="src/Song.js"></script>
<!-- include spec files here... -->
<script type="text/javascript" src="spec/SpecHelper.js"></script>
<script type="text/javascript" src="spec/PlayerSpec.js"></script>
</head>
<body>
<div id="REMOVE_THIS_LINE_FROM_BUILD"><p>You must be trying to look at examples in the Jasmine source tree.</p><p>Please download a distribution version of Jasmine at <a href="http://pivotal.github.com/jasmine/">http://pivotal.github.com/jasmine/</a>.</p></div>
<script type="text/javascript">
jasmine.getEnv().addReporter(new jasmine.TrivialReporter());
jasmine.getEnv().execute();
</script>
</body>
</html>

22
jasmine-core.gemspec Normal file
View File

@@ -0,0 +1,22 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "jasmine-core/version"
Gem::Specification.new do |s|
s.name = "jasmine-core"
s.version = Jasmine::Core::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Rajan Agaskar", "Davis Frank", "Christian Williams"]
s.summary = %q{JavaScript BDD framework}
s.description = %q{Test your JavaScript without any framework dependencies, in any environment, and with a nice descriptive syntax.}
s.email = %q{jasmine-js@googlegroups.com}
s.homepage = "http://pivotal.github.com/jasmine"
s.rubyforge_project = "jasmine-core"
s.files = Dir.glob("./lib/**/*") + Dir.glob("./lib/jasmine-core/spec/**/*.js")
s.require_paths = ["lib"]
s.add_development_dependency "term-ansicolor"
s.add_development_dependency "json_pure", ">= 1.4.3"
s.add_development_dependency "frank"
s.add_development_dependency "ragaskar-jsdoc_helper"
end

36
lib/jasmine-core.rb Normal file
View File

@@ -0,0 +1,36 @@
module Jasmine
module Core
class << self
def path
File.join(File.dirname(__FILE__), "jasmine-core")
end
def js_files
(["jasmine.js"] + Dir.glob(File.join(path, "*.js"))).map { |f| File.basename(f) }.uniq
end
SPEC_TYPES = ["core", "html", "node"]
def core_spec_files
spec_files("core")
end
def html_spec_files
spec_files("html")
end
def node_spec_files
spec_files("node")
end
def spec_files(type)
raise ArgumentError.new("Unrecognized spec type") unless SPEC_TYPES.include?(type)
(Dir.glob(File.join(path, "spec", type, "*.js"))).map { |f| File.join("spec", type, File.basename(f)) }.uniq
end
def css_files
Dir.glob(File.join(path, "*.css")).map { |f| File.basename(f) }
end
end
end
end

View File

@@ -0,0 +1,54 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Spec Runner</title>
<link rel="shortcut icon" type="image/png" href="lib/jasmine-1.1.0.rc1/jasmine_favicon.png">
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.1.0.rc1/jasmine.css">
<script type="text/javascript" src="lib/jasmine-1.1.0.rc1/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-1.1.0.rc1/jasmine-html.js"></script>
<!-- include spec files here... -->
<script type="text/javascript" src="spec/SpecHelper.js"></script>
<script type="text/javascript" src="spec/PlayerSpec.js"></script>
<!-- include source files here... -->
<script type="text/javascript" src="src/Player.js"></script>
<script type="text/javascript" src="src/Song.js"></script>
<script type="text/javascript">
(function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
var trivialReporter = new jasmine.TrivialReporter();
jasmineEnv.addReporter(trivialReporter);
jasmineEnv.specFilter = function(spec) {
return trivialReporter.specFilter(spec);
};
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};
function execJasmine() {
jasmineEnv.execute();
}
})();
</script>
</head>
<body>
</body>
</html>

View File

@@ -34,7 +34,7 @@ jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
this.createDom('div', { className: 'banner' },
this.createDom('div', { className: 'logo' },
this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"),
this.createDom('span', { className: 'title' }, "Jasmine"),
this.createDom('span', { className: 'version' }, runner.env.versionString())),
this.createDom('div', { className: 'options' },
"Show ",

View File

@@ -735,12 +735,17 @@ jasmine.Env.prototype.version = function () {
* @returns string containing jasmine version build info, if set.
*/
jasmine.Env.prototype.versionString = function() {
if (jasmine.version_) {
var version = this.version();
return version.major + "." + version.minor + "." + version.build + " revision " + version.revision;
} else {
if (!jasmine.version_) {
return "version unknown";
}
var version = this.version();
var versionString = version.major + "." + version.minor + "." + version.build;
if (version.release_candidate) {
versionString += ".rc" + version.release_candidate;
}
versionString += " revision " + version.revision;
return versionString;
};
/**
@@ -2463,10 +2468,9 @@ jasmine.getGlobal().clearInterval = function(timeoutKey) {
}
};
jasmine.version_= {
"major": 1,
"minor": 1,
"build": 0,
"revision": 1307546962
"revision": 1315677058
};

1
lib/jasmine-core/spec Symbolic link
View File

@@ -0,0 +1 @@
../../spec

View File

@@ -0,0 +1,6 @@
module Jasmine
module Core
VERSION = "1.1.0"
end
end

2
pages

Submodule pages updated: d08ce2de24...a9d577eb45

View File

@@ -1,4 +1,4 @@
describe("TrivialConsoleReporter", function() {
describe("ConsoleReporter", function() {
//keep these literal. otherwise the test loses value as a test.
function green(str) {
return '\033[32m' + str + '\033[0m';
@@ -107,14 +107,14 @@ describe("TrivialConsoleReporter", function() {
})();
done = false;
reporter = new jasmine.TrivialConsoleReporter(out.print, function(runner) {
reporter = new jasmine.ConsoleReporter(out.print, function(runner) {
done = true
});
});
describe('Integration', function() {
it("prints the proper output under a pass scenario. small numbers.", function() {
it("prints the proper output under a pass scenario - small numbers.", function() {
simulateRun(reporter,
repeat(passingSpec, 3),
[],
@@ -134,16 +134,10 @@ describe("TrivialConsoleReporter", function() {
1777
);
expect(out.getOutput()).toEqual(
[
"Started",
green(".") + green(".") + green("."),
"",
"Finished in 0.777 seconds",
green("3 specs, 0 failures"),
""
].join("\n") + "\n"
);
var output = out.getOutput();
expect(output).toMatch(/^Started/);
expect(output).toMatch(/\.\.\./);
expect(output).toMatch(/3 specs, 0 failures/);
});
it("prints the proper output under a pass scenario. large numbers.", function() {
@@ -165,33 +159,12 @@ describe("TrivialConsoleReporter", function() {
1000,
1777);
expect(out.getOutput()).toEqual(
[
"Started",
green(".") + green(".") + green(".") + green(".") + green(".") + //50 green dots
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") +
green(".") + green(".") + green(".") + green(".") + green(".") + //7 green dots
green(".") + green("."),
"",
"Finished in 0.777 seconds",
green("3 specs, 0 failures"),
""
].join("\n") + "\n"
);
var output = out.getOutput();
expect(output).toMatch(/^Started/);
expect(output).toMatch(/\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\./);
expect(output).toMatch(/3 specs, 0 failures/);
});
it("prints the proper output under a failure scenario.", function() {
simulateRun(reporter,
[failingSpec, passingSpec, failingSpec],
@@ -237,24 +210,12 @@ describe("TrivialConsoleReporter", function() {
1000,
1777);
expect(out.getOutput()).toEqual(
[
"Started",
red("F") + green(".") + red("F"),
"",
"The oven heats up",
" stack trace one",
" second line",
" stack trace two",
"",
"The washing machine washes clothes",
" stack trace one",
"",
"Finished in 0.777 seconds",
red("3 specs, 2 failures"),
""
].join("\n") + "\n"
);
var output = out.getOutput();
expect(output).toMatch(/^Started/);
expect(output).toMatch(/F\.F/);
expect(output).toMatch(/The oven heats up\n stack trace one\n second line\n stack trace two/);
expect(output).toMatch(/The washing machine washes clothes\n stack trace one/);
expect(output).toMatch(/3 specs, 2 failures/);
});
});
@@ -275,19 +236,19 @@ describe("TrivialConsoleReporter", function() {
it("prints a green dot if the spec passes", function() {
reporter.reportSpecResults(passingSpec);
expect(out.getOutput()).toEqual(green("."));
expect(out.getOutput()).toMatch(/\./);
});
it("prints a red dot if the spec fails", function() {
reporter.reportSpecResults(failingSpec);
expect(out.getOutput()).toEqual(red("F"));
expect(out.getOutput()).toMatch(/F/);
});
it("prints a yellow star if the spec was skipped", function() {
reporter.reportSpecResults(skippedSpec);
expect(out.getOutput()).toEqual(yellow("*"));
expect(out.getOutput()).toMatch(/\*/);
});
});

View File

@@ -64,9 +64,10 @@ describe("jasmine.Env", function() {
"major": 1,
"minor": 9,
"build": 7,
"release_candidate": "1",
"revision": 8
};
expect(env.versionString()).toEqual("1.9.7 revision 8");
expect(env.versionString()).toEqual("1.9.7.rc1 revision 8");
});
it("should return a nice string when version is unknown", function() {

View File

@@ -6,11 +6,11 @@ var path = require('path');
// undefined = "diz be undefined yo";
var jasmineGlobals = require('../lib/jasmine.js');
var jasmineGlobals = require('../lib/jasmine-core/jasmine.js');
for (var k in jasmineGlobals) {
global[k] = jasmineGlobals[k];
}
require('../src/console/TrivialConsoleReporter.js');
require('../src/console/ConsoleReporter.js');
/*
Pulling in code from jasmine-node.
@@ -30,14 +30,14 @@ delete global.window;
function noop() {
}
jasmine.executeSpecs = function(specs, done) {
jasmine.executeSpecs = function(specs, done, isVerbose, showColors) {
for (var i = 0, len = specs.length; i < len; ++i) {
var filename = specs[i];
require(filename.replace(/\.\w+$/, ""));
}
var jasmineEnv = jasmine.getEnv();
var consoleReporter = new jasmine.TrivialConsoleReporter(sys.print, done);
var consoleReporter = new jasmine.ConsoleReporter(sys.print, done, showColors);
jasmineEnv.addReporter(consoleReporter);
jasmineEnv.execute();
@@ -124,4 +124,4 @@ jasmine.executeSpecs(domIndependentSpecs, function(runner, log) {
} else {
process.exit(1);
}
}, isVerbose, showColors);
}, isVerbose, showColors);

View File

@@ -2,41 +2,46 @@
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Test Runner</title>
<title>Jasmine Spec Runner: Jasmine Core</title>
<link rel="shortcut icon" type="image/png" href="../images/jasmine_favicon.png">
<link href="../lib/jasmine-core/jasmine.css" rel="stylesheet"/>
<script type="text/javascript" src="../lib/jasmine-core/jasmine.js"></script>
<script type="text/javascript">
// yes, really keep this here to keep us honest, but only for jasmine's own runner! [xw]
undefined = "diz be undefined yo";
</script>
<link rel="shortcut icon" type="image/png" href="../images/jasmine_favicon.png">
<script type="text/javascript" src="../lib/jasmine.js"></script>
<script type="text/javascript" src="../src/html/TrivialReporter.js"></script>
<script type="text/javascript" src="../src/console/TrivialConsoleReporter.js"></script>
<script type="text/javascript" src="core/BaseSpec.js"></script>
<script type="text/javascript" src="core/CustomMatchersSpec.js"></script>
<script type="text/javascript" src="core/EnvSpec.js"></script>
<script type="text/javascript" src="core/ExceptionsSpec.js"></script>
<script type="text/javascript" src="core/JsApiReporterSpec.js"></script>
<script type="text/javascript" src="core/MatchersSpec.js"></script>
<script type="text/javascript" src="core/MockClockSpec.js"></script>
<script type="text/javascript" src="core/MultiReporterSpec.js"></script>
<script type="text/javascript" src="core/NestedResultsSpec.js"></script>
<script type="text/javascript" src="core/PrettyPrintSpec.js"></script>
<script type="text/javascript" src="core/ReporterSpec.js"></script>
<script type="text/javascript" src="core/RunnerSpec.js"></script>
<script type="text/javascript" src="core/QueueSpec.js"></script>
<script type="text/javascript" src="core/SpecSpec.js"></script>
<script type="text/javascript" src="core/SpecRunningSpec.js"></script>
<script type="text/javascript" src="core/SpySpec.js"></script>
<script type="text/javascript" src="core/SuiteSpec.js"></script>
<script type="text/javascript" src="core/UtilSpec.js"></script>
<script type="text/javascript" src="core/WaitsForBlockSpec.js"></script>
<script type="text/javascript" src="console/TrivialConsoleReporterSpec.js"></script>
<script type="text/javascript" src="html/MatchersHtmlSpec.js"></script>
<script type="text/javascript" src="html/PrettyPrintHtmlSpec.js"></script>
<script type="text/javascript" src="html/TrivialReporterSpec.js"></script>
<!-- include source files here... -->
<script type="text/javascript" src=".././src/html/TrivialReporter.js"></script>
<script type="text/javascript" src=".././src/console/ConsoleReporter.js"></script>
<!-- include spec files here... -->
<script type="text/javascript" src=".././spec/core/BaseSpec.js"></script>
<script type="text/javascript" src=".././spec/core/CustomMatchersSpec.js"></script>
<script type="text/javascript" src=".././spec/core/EnvSpec.js"></script>
<script type="text/javascript" src=".././spec/core/ExceptionsSpec.js"></script>
<script type="text/javascript" src=".././spec/core/JsApiReporterSpec.js"></script>
<script type="text/javascript" src=".././spec/core/MatchersSpec.js"></script>
<script type="text/javascript" src=".././spec/core/MockClockSpec.js"></script>
<script type="text/javascript" src=".././spec/core/MultiReporterSpec.js"></script>
<script type="text/javascript" src=".././spec/core/NestedResultsSpec.js"></script>
<script type="text/javascript" src=".././spec/core/PrettyPrintSpec.js"></script>
<script type="text/javascript" src=".././spec/core/QueueSpec.js"></script>
<script type="text/javascript" src=".././spec/core/ReporterSpec.js"></script>
<script type="text/javascript" src=".././spec/core/RunnerSpec.js"></script>
<script type="text/javascript" src=".././spec/core/SpecRunningSpec.js"></script>
<script type="text/javascript" src=".././spec/core/SpecSpec.js"></script>
<script type="text/javascript" src=".././spec/core/SpySpec.js"></script>
<script type="text/javascript" src=".././spec/core/SuiteSpec.js"></script>
<script type="text/javascript" src=".././spec/core/UtilSpec.js"></script>
<script type="text/javascript" src=".././spec/core/WaitsForBlockSpec.js"></script>
<script type="text/javascript" src=".././spec/html/MatchersHtmlSpec.js"></script>
<script type="text/javascript" src=".././spec/html/PrettyPrintHtmlSpec.js"></script>
<script type="text/javascript" src=".././spec/html/TrivialReporterSpec.js"></script>
<script type="text/javascript" src=".././spec/console/ConsoleReporterSpec.js"></script>
<script type="text/javascript">
(function() {
@@ -51,13 +56,22 @@
return trivialReporter.specFilter(spec);
};
var currentWindowOnload = window.onload;
window.onload = function() {
jasmineEnv.execute();
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};
function execJasmine() {
jasmineEnv.execute();
}
})();
</script>
<link href="../src/html/jasmine.css" rel="stylesheet"/>
</head>
<body>

View File

@@ -0,0 +1,49 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><%= title %></title>
<%= favicon %>
<%= jasmine_tags %>
<!-- include source files here... -->
<%= source_tags %>
<!-- include spec files here... -->
<%= spec_file_tags %>
<script type="text/javascript">
(function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 1000;
var trivialReporter = new jasmine.TrivialReporter();
jasmineEnv.addReporter(trivialReporter);
jasmineEnv.specFilter = function(spec) {
return trivialReporter.specFilter(spec);
};
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};
function execJasmine() {
jasmineEnv.execute();
}
})();
</script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1 @@
<script type="text/javascript" src="<%= file %>"></script>

View File

@@ -1,4 +1,4 @@
jasmine.TrivialConsoleReporter = function(print, doneCallback) {
jasmine.ConsoleReporter = function(print, doneCallback, showColors) {
//inspired by mhevery's jasmine-node reporter
//https://github.com/mhevery/jasmine-node
@@ -16,7 +16,7 @@ jasmine.TrivialConsoleReporter = function(print, doneCallback) {
};
function coloredStr(color, str) {
return ansi[color] + str + ansi.none;
return showColors ? (ansi[color] + str + ansi.none) : str;
}
function greenStr(str) {

View File

@@ -19,4 +19,4 @@ jasmine.Block.prototype.execute = function(onComplete) {
this.spec.fail(e);
}
onComplete();
};
};

View File

@@ -51,12 +51,17 @@ jasmine.Env.prototype.version = function () {
* @returns string containing jasmine version build info, if set.
*/
jasmine.Env.prototype.versionString = function() {
if (jasmine.version_) {
var version = this.version();
return version.major + "." + version.minor + "." + version.build + " revision " + version.revision;
} else {
if (!jasmine.version_) {
return "version unknown";
}
var version = this.version();
var versionString = version.major + "." + version.minor + "." + version.build;
if (version.release_candidate) {
versionString += ".rc" + version.release_candidate;
}
versionString += " revision " + version.revision;
return versionString;
};
/**

View File

@@ -74,4 +74,4 @@ jasmine.Runner.prototype.topLevelSuites = function() {
jasmine.Runner.prototype.results = function() {
return this.queue.results();
};
};

View File

@@ -79,4 +79,4 @@ jasmine.Suite.prototype.execute = function(onComplete) {
this.queue.start(function () {
self.finish(onComplete);
});
};
};

View File

@@ -34,7 +34,7 @@ jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' },
this.createDom('div', { className: 'banner' },
this.createDom('div', { className: 'logo' },
this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"),
this.createDom('span', { className: 'title' }, "Jasmine"),
this.createDom('span', { className: 'version' }, runner.env.versionString())),
this.createDom('div', { className: 'options' },
"Show ",

View File

@@ -0,0 +1,3 @@
<link rel="stylesheet" type="text/css" href="lib/jasmine-<%= jasmine_version %>/jasmine.css">
<script type="text/javascript" src="lib/jasmine-<%= jasmine_version %>/jasmine.js"></script>
<script type="text/javascript" src="lib/jasmine-<%= jasmine_version %>/jasmine-html.js"></script>

View File

@@ -0,0 +1,6 @@
jasmine.version_= {
"major": <%= major %>,
"minor": <%= minor %>,
"build": <%= build %>,
"revision": <%= revision %><%= %Q{,\n "release_candidate": #{release_candidate}} if release_candidate %>
};

View File

@@ -0,0 +1,6 @@
module Jasmine
module Core
VERSION = "<%= "#{major}.#{minor}.#{build}" %><%= ".rc#{release_candidate}" if release_candidate %>"
end
end

6
src/version.js Normal file
View File

@@ -0,0 +1,6 @@
jasmine.version_= {
"major": 1,
"minor": 1,
"build": 0,
"revision": 1315677058
};

48
tasks/build_dist.rb Normal file
View File

@@ -0,0 +1,48 @@
desc "Build core jasmine.js"
task :build_dist => [:lint, :write_version_files] do
puts 'Building Jasmine distribution from source'.cyan
concat_into('./lib/jasmine-core/jasmine.js') { core_sources + version_source_file }
concat_into('./lib/jasmine-core/jasmine-html.js') { html_sources }
FileUtils.cp('./src/html/jasmine.css', './lib/jasmine-core/jasmine.css')
end
def concat_into(output_file, &block)
files = yield
File.open(output_file, 'w') do |out|
files.each do |f|
out << File.read(f)
end
end
end
desc 'Check jasmine sources for coding problems'
task :lint => :require_node do
puts "Running JSHint via Node.js".cyan
system("node jshint/run.js") || exit(1)
end
task :hint => :lint
task :write_version_files do
scope = OpenStruct.new(:major => version_hash["major"],
:minor => version_hash["minor"],
:build => version_hash["build"],
:release_candidate => version_hash["release_candidate"],
:revision => Time.now.to_i)
js_template = Tilt.new('./src/templates/version.js.erb')
File.open('./src/version.js', 'w+') do |f|
f << js_template.render(scope)
end
rb_template = Tilt.new('./src/templates/version.rb.erb')
File.open('./lib/jasmine-core/version.rb', 'w+') do |f|
f << rb_template.render(scope)
end
end
def version_source_file
Dir.glob('src/version.js')
end

50
tasks/build_specs.rb Normal file
View File

@@ -0,0 +1,50 @@
require 'ostruct'
#build the browser spec for Jasmine core 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(:title => "Jasmine Spec Runner: Jasmine Core",
:favicon => favicon,
:jasmine_tags => jasmine_tags,
:source_tags => source_tags,
:spec_file_tags => spec_file_tags)
f << template.render(scope)
end
end
def favicon
<<HTML
<link rel="shortcut icon" type="image/png" href="../images/jasmine_favicon.png">
HTML
end
def jasmine_tags
tags = %Q{<link href="../lib/jasmine-core/jasmine.css" rel="stylesheet"/>}
tags << "\n "
tags << script_tags_for("../lib/jasmine-core/jasmine.js")
tags << "\n "
tags << undefined_catch
tags
end
def undefined_catch
<<HTML
<script type="text/javascript">
// yes, really keep this here to keep us honest, but only for jasmine's own runner! [xw]
undefined = "diz be undefined yo";
</script>
HTML
end
def source_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

17
tasks/docs.rb Normal file
View File

@@ -0,0 +1,17 @@
desc "Build jasmine documentation"
task :doc => :require_pages_submodule do
puts 'Creating Jasmine Documentation'
require 'rubygems'
require 'jsdoc_helper'
FileUtils.rm_r "pages/jsdoc", :force => true
JsdocHelper::Rake::Task.new(:lambda_jsdoc) do |t|
t[:files] = core_sources + html_sources + console_sources
t[:options] = "-a"
t[:out] = "pages/jsdoc"
# JsdocHelper bug: template must be relative to the JsdocHelper gem, ick
t[:template] = File.join("../".*(100), Dir::getwd, "jsdoc-template")
end
Rake::Task[:lambda_jsdoc].invoke
end

50
tasks/helpers.rb Normal file
View File

@@ -0,0 +1,50 @@
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 = "#{version_hash['major']}.#{version_hash['minor']}.#{version_hash['build']}"
version += ".rc#{version_hash['release_candidate']}" if version_hash['release_candidate']
version
end
def version_hash
@version ||= JSON.parse(File.new("./src/version.json").read);
end
def script_tags_for(files)
script_tag = Tilt::new('./spec/templates/script_tag.html.erb')
srcs = (files.is_a?(String) ? [files] : files)
srcs.inject([]) do |tags, f|
scope = OpenStruct.new :file => f
tags << script_tag.render(scope)
tags
end.join("\n ")
end

13
tasks/pages.rb Normal file
View File

@@ -0,0 +1,13 @@
desc "Build the Github pages HTML"
task :build_pages => :require_pages_submodule do
Dir.chdir("pages") do
FileUtils.rm_r('pages_output') if File.exist?('pages_output')
Dir.chdir('pages_source') do
system("frank export ../pages_output")
end
puts "\n"
puts "Copying built website to the root of the gh-pages branch".cyan
puts "\n\n"
system("cp -r pages_output/* .")
end
end

37
tasks/spec.rb Normal file
View File

@@ -0,0 +1,37 @@
desc "Run spec suite: Browser, Node, JSHint"
task :spec => ["build_dist", "count_specs", "spec:node", "spec:browser"]
desc 'Run specs in Node.js'
task "spec:node" => [:count_specs, :require_node] do
puts "Running all appropriate specs via Node.js".cyan
color = Term::ANSIColor.coloring? ? "--color" : "--noColor"
system("node spec/node_suite.js #{color}")
end
desc "Run specs in the default browser (MacOS only)"
task "spec:browser" => [:count_specs, :build_runner_html] do
puts "Running all appropriate specs via the default web browser".cyan
system("open spec/runner.html")
end
#Count number of specs in Jasmine core
task :count_specs do
core_specs_count = count_specs_in(Dir.glob('spec/core/*.js'))
console_spec_count = count_specs_in(Dir.glob('spec/console/*.js'))
html_spec_count = count_specs_in(Dir.glob('spec/html/*.js'))
puts "\n"
puts "#{(core_specs_count + console_spec_count).to_s.yellow.bold} specs for Node.js runner (exclude DOM-related specs)"
puts "#{(core_specs_count + console_spec_count + html_spec_count).to_s.yellow.bold} specs for Browser runner (all specs)"
puts "\n"
puts "Please verify that these numbers match the runner output."
puts "\n"
end
def count_specs_in(files)
files.inject(0) do |count, file|
File.read(file).scan(/\sit\(/) {|s| count += 1}
count
end
end

91
tasks/standalone.rb Normal file
View File

@@ -0,0 +1,91 @@
require 'ostruct'
desc "Build standalone distribution"
task :standalone => [:require_pages_submodule, :protect_current_dist_zip, :build_spec_runner_html] do
require 'tmpdir'
zip_root = File.join(Dir.tmpdir, "zip_root")
temp_dir = File.join(zip_root, "jasmine-standalone-#{version_string}")
puts "Building Example Project in #{temp_dir}"
FileUtils.rm_r temp_dir if File.exist?(temp_dir)
FileUtils.mkdir_p(temp_dir)
root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
FileUtils.mkdir_p(File.join(root, "example"))
FileUtils.cp_r(File.join(root, 'example/.'), File.join(temp_dir))
lib_dir = File.join(temp_dir, "lib/jasmine-#{version_string}")
FileUtils.mkdir_p(lib_dir)
{
"images/jasmine_favicon.png" => "jasmine_favicon.png",
"lib/jasmine-core/jasmine.js" => "jasmine.js",
"lib/jasmine-core/jasmine-html.js" => "jasmine-html.js",
"lib/jasmine-core/jasmine.css" => "jasmine.css",
"MIT.LICENSE" => "MIT.LICENSE"
}.each_pair do |src, dest|
FileUtils.cp(File.join(root, src), File.join(lib_dir, dest))
end
dist_dir = File.join(root, 'pages/downloads')
zip_file_name = File.join(dist_dir, "jasmine-standalone-#{version_string}.zip")
puts "Zipping Example Project and moving to #{zip_file_name}"
exec "cd #{zip_root} && zip #{zip_file_name} -r . -x .[a-zA-Z0-9]*"
end
#Build SpecRunner.html for standalone dist example project
task :build_spec_runner_html do
template = Tilt.new('spec/templates/runner.html.erb')
File.open('lib/jasmine-core/example/SpecRunner.html', 'w+') do |f|
scope = OpenStruct.new(:title => "Jasmine Spec Runner",
:favicon => example_favicon,
:jasmine_tags => example_jasmine_tags,
:source_tags => example_source_tags,
:spec_file_tags => example_spec_tags)
f << template.render(scope)
end
end
def example_path
"lib/jasmine-#{version_string}"
end
def example_favicon
<<HTML
<link rel="shortcut icon" type="image/png" href="#{example_path}/jasmine_favicon.png">
HTML
end
def example_jasmine_tags
tags = %Q{<link rel="stylesheet" type="text/css" href="#{example_path}/jasmine.css">}
tags << "\n "
tags << script_tags_for(["#{example_path}/jasmine.js", "#{example_path}/jasmine-html.js"])
tags
end
def example_source_tags
script_tags_for ['spec/SpecHelper.js', 'spec/PlayerSpec.js']
end
def example_spec_tags
script_tags_for ['src/Player.js', 'src/Song.js']
end
task :protect_current_dist_zip do
root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
dist_dir = File.join(root, 'pages/downloads')
zip_file_name = File.join(dist_dir, "jasmine-standalone-#{version_string}.zip")
zip_present_message = "\n\n"
zip_present_message << "==> STOPPED <==".red
zip_present_message << "\n\n"
zip_present_message << "The file ".red + "#{zip_file_name}" + " already exists.".red + "\n"
zip_present_message << "If you should be building the next version, update src/version.json"
zip_present_message << "\n"
zip_present_message << "If the version is correct, you must be trying to re-build the standalone ZIP. Delete the ZIP and rebuild."
zip_present_message << "\n"
raise zip_present_message if File.exist?(zip_file_name)
end

5
tasks/version.rb Normal file
View File

@@ -0,0 +1,5 @@
task :version do
require 'pp'
pp version_hash
pp version_string
end