Compare commits

..

3 Commits

Author SHA1 Message Date
ragaskar
22904c4f83 Add release candidate option. Add node required message. Bump version. 2011-06-11 00:33:47 -04:00
ragaskar
995cdd6e3b Jasmine core files should be available to other gems 2011-06-10 23:16:10 -04:00
ragaskar
48c8d2cc1f Add bundler gem skeleton 2011-06-10 23:02:12 -04:00
41 changed files with 133841 additions and 664 deletions

1
.gitignore vendored
View File

@@ -7,6 +7,5 @@ site/
.rvmrc
*.gem
.bundle
tags
Gemfile.lock
pkg/*

View File

@@ -1,44 +0,0 @@
# 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,4 +1,3 @@
source :rubygems
gem "term-ansicolor", :require => "term/ansicolor"
gem "rake"
gemspec

49
HowToRelease.markdown Normal file
View File

@@ -0,0 +1,49 @@
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,13 +6,6 @@ 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)
@@ -21,6 +14,32 @@ 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

182
Rakefile
View File

@@ -1,33 +1,169 @@
require "bundler"
require 'bundler'
Bundler::GemHelper.install_tasks
require "term/ansicolor"
require "json"
require "tilt"
Dir["#{File.dirname(__FILE__)}/tasks/**/*.rb"].each do |file|
require file
def sources
dependencies = JSON.parse(File.read('./src/SourcesList.json')).collect {|f| "./src/core/#{f}"}
dependencies + Dir.glob('./src/core/*.js').reject {|f| dependencies.include?(f)}.sort
end
def html_sources
["./src/html/TrivialReporter.js"]
end
def version_hash
@version ||= JSON.parse(File.new("./src/core/version.json").read)
end
def substitute_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) }
end
task :default => :spec
task :require_pages_submodule do
raise "Submodule for Github Pages isn't present. Run git submodule update --init" unless pages_submodule_present
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 => "jasmine:require_node" do
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
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?
namespace :jasmine do
task :require_node do
raise "Node.js is required" if `which node` == ''
end
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 => "jasmine:require_node" 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'
version = Jasmine::Core::VERSION_HASH
File.open("./lib/jasmine-core/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},
"release_candidate": #{version['release_candidate'].to_json}
};
}
end
File.open("./lib/jasmine-core/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-core/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] = sources << 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_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
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
task :build => "jasmine:build"

View File

@@ -1,40 +0,0 @@
# 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

@@ -13,9 +13,9 @@ Gem::Specification.new do |s|
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.files = Dir.glob("./lib/**/*")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
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"

View File

@@ -9,25 +9,6 @@ module Jasmine
(["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

View File

@@ -2,53 +2,26 @@
"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>
<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>
<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>
<!-- 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>

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('span', { className: 'title' }, "Jasmine"),
this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"),
this.createDom('span', { className: 'version' }, runner.env.versionString())),
this.createDom('div', { className: 'options' },
"Show ",

View File

@@ -735,17 +735,17 @@ jasmine.Env.prototype.version = function () {
* @returns string containing jasmine version build info, if set.
*/
jasmine.Env.prototype.versionString = function() {
if (!jasmine.version_) {
if (jasmine.version_) {
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;
} else {
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;
};
/**
@@ -2468,9 +2468,12 @@ jasmine.getGlobal().clearInterval = function(timeoutKey) {
}
};
jasmine.version_= {
"major": 1,
"minor": 1,
"major": 2,
"minor": 0,
"build": 0,
"revision": 1315677058
"revision": 1307766763,
"release_candidate": 1
};

View File

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

View File

@@ -1,6 +1,8 @@
module Jasmine
module Core
VERSION = "1.1.0"
require 'json'
VERSION_HASH = JSON.parse(File.new(File.join(File.dirname(__FILE__), "..", "..", "src", "core", "version.json")).read);
VERSION = "#{VERSION_HASH['major']}.#{VERSION_HASH['minor']}.#{VERSION_HASH['build']}"
VERSION << ".rc#{VERSION_HASH['release_candidate']}" if VERSION_HASH['release_candidate']
end
end

2
pages

Submodule pages updated: a9d577eb45...d08ce2de24

View File

@@ -1,4 +1,4 @@
describe("ConsoleReporter", function() {
describe("TrivialConsoleReporter", 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("ConsoleReporter", function() {
})();
done = false;
reporter = new jasmine.ConsoleReporter(out.print, function(runner) {
reporter = new jasmine.TrivialConsoleReporter(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,10 +134,16 @@ describe("ConsoleReporter", function() {
1777
);
var output = out.getOutput();
expect(output).toMatch(/^Started/);
expect(output).toMatch(/\.\.\./);
expect(output).toMatch(/3 specs, 0 failures/);
expect(out.getOutput()).toEqual(
[
"Started",
green(".") + green(".") + green("."),
"",
"Finished in 0.777 seconds",
green("3 specs, 0 failures"),
""
].join("\n") + "\n"
);
});
it("prints the proper output under a pass scenario. large numbers.", function() {
@@ -159,12 +165,33 @@ describe("ConsoleReporter", function() {
1000,
1777);
var output = out.getOutput();
expect(output).toMatch(/^Started/);
expect(output).toMatch(/\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\.\./);
expect(output).toMatch(/3 specs, 0 failures/);
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"
);
});
it("prints the proper output under a failure scenario.", function() {
simulateRun(reporter,
[failingSpec, passingSpec, failingSpec],
@@ -210,12 +237,24 @@ describe("ConsoleReporter", function() {
1000,
1777);
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/);
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"
);
});
});
@@ -236,19 +275,19 @@ describe("ConsoleReporter", function() {
it("prints a green dot if the spec passes", function() {
reporter.reportSpecResults(passingSpec);
expect(out.getOutput()).toMatch(/\./);
expect(out.getOutput()).toEqual(green("."));
});
it("prints a red dot if the spec fails", function() {
reporter.reportSpecResults(failingSpec);
expect(out.getOutput()).toMatch(/F/);
expect(out.getOutput()).toEqual(red("F"));
});
it("prints a yellow star if the spec was skipped", function() {
reporter.reportSpecResults(skippedSpec);
expect(out.getOutput()).toMatch(/\*/);
expect(out.getOutput()).toEqual(yellow("*"));
});
});

View File

@@ -10,7 +10,7 @@ var jasmineGlobals = require('../lib/jasmine-core/jasmine.js');
for (var k in jasmineGlobals) {
global[k] = jasmineGlobals[k];
}
require('../src/console/ConsoleReporter.js');
require('../src/console/TrivialConsoleReporter.js');
/*
Pulling in code from jasmine-node.
@@ -30,14 +30,14 @@ delete global.window;
function noop() {
}
jasmine.executeSpecs = function(specs, done, isVerbose, showColors) {
jasmine.executeSpecs = function(specs, done) {
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.ConsoleReporter(sys.print, done, showColors);
var consoleReporter = new jasmine.TrivialConsoleReporter(sys.print, done);
jasmineEnv.addReporter(consoleReporter);
jasmineEnv.execute();

View File

@@ -2,46 +2,41 @@
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Jasmine Spec Runner: Jasmine Core</title>
<title>Jasmine Test Runner</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-core/jasmine.js"></script>
<script type="text/javascript" src="../src/html/TrivialReporter.js"></script>
<script type="text/javascript" src="../src/console/TrivialConsoleReporter.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" 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>
<script type="text/javascript">
(function() {
@@ -56,22 +51,13 @@
return trivialReporter.specFilter(spec);
};
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
execJasmine();
};
function execJasmine() {
jasmineEnv.execute();
}
};
})();
</script>
<link href="../src/html/jasmine.css" rel="stylesheet"/>
</head>
<body>

View File

@@ -1,49 +0,0 @@
<!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

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

View File

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

View File

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

View File

@@ -51,17 +51,17 @@ jasmine.Env.prototype.version = function () {
* @returns string containing jasmine version build info, if set.
*/
jasmine.Env.prototype.versionString = function() {
if (!jasmine.version_) {
if (jasmine.version_) {
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;
} else {
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);
});
};
};

6
src/core/version.json Normal file
View File

@@ -0,0 +1,6 @@
{
"major": 2,
"minor": 0,
"build": 0,
"release_candidate": 1
}

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('span', { className: 'title' }, "Jasmine"),
this.createDom('a', { href: 'http://pivotal.github.com/jasmine/', target: "_blank" }, "Jasmine"),
this.createDom('span', { className: 'version' }, runner.env.versionString())),
this.createDom('div', { className: 'options' },
"Show ",

View File

@@ -1,3 +0,0 @@
<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

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

View File

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

View File

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

View File

@@ -1,5 +0,0 @@
{
"major": 1,
"minor": 1,
"build": 0
}

133457
tags Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,48 +0,0 @@
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

View File

@@ -1,50 +0,0 @@
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

View File

@@ -1,17 +0,0 @@
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

View File

@@ -1,50 +0,0 @@
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

View File

@@ -1,13 +0,0 @@
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

View File

@@ -1,37 +0,0 @@
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

View File

@@ -1,91 +0,0 @@
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

View File

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