Compare commits

..

7 Commits

Author SHA1 Message Date
ragaskar
c216047711 Version bump 2011-09-10 12:37:39 -04:00
Sean Durham
b087609733 Add stylesheets for TrivialReporter 2011-09-09 21:08:24 -04:00
Sean Durham
ac50cf4c14 include stylesheets for TrivialReporter and HTMLReporter, scoped so they don't interfere with each other. 2011-09-09 21:08:13 -04:00
Davis W. Frank
de341a8fe1 Bump version, recompile libraries 2011-09-09 21:04:24 -04:00
Davis W. Frank
fa317e4dda Deprecate TrivialReporter, Use HTMLReporter 2011-09-09 21:04:20 -04:00
Davis W. Frank
05b7730db1 Add New HTMLReporter 2011-09-09 21:04:15 -04:00
Davis W. Frank
9423dfee07 Add semi. 2011-09-09 21:03:57 -04:00
78 changed files with 1866 additions and 2875 deletions

2
.gitignore vendored
View File

@@ -10,5 +10,3 @@ site/
tags
Gemfile.lock
pkg/*
.sass-cache/*
src/html/.sass-cache/*

2
.gitmodules vendored
View File

@@ -1,3 +1,3 @@
[submodule "pages"]
path = pages
url = https://github.com/pivotal/jasmine.git
url = git@github.com:pivotal/jasmine.git

1
.rspec
View File

@@ -1 +0,0 @@
--color

View File

@@ -1,9 +0,0 @@
# before_script:
# - "sh -e /etc/init.d/xvfb start"
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"#
script: "DISPLAY=:99.0 bundle exec rake jasmine_core_spec"
rvm:
- "1.9.3"

View File

@@ -12,7 +12,7 @@ Or, How to make a successful pull request
* _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
* _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.
@@ -34,12 +34,11 @@ As in all good projects, the `spec/` directory mirrors `src/` and follows the sa
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 or issuing a pull request.
Please ensure all specs are green before committing.
There are Thor tasks to help with getting green - run `thor list` to see them all. Here are the key tasks:
* `thor jasmine_dev:execute_specs` outputs the expected number of specs that should be run and attempts to run in browser and Node
* `thor jasmine_dev:execute_specs_in_browser` opens `spec/runner.html` in the default browser on MacOS. Please run this in at least Firefox and Chrome before committing
* `thor jasmine_dev:execute_specs_in_node` runs all the Jasmine specs in Node.js - it will complain if Node is not installed
* `thor jasmine_dev:js_hint` runs all the files through JSHint and will complain about potential viable issues with your code. Fix them.
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,11 +1,4 @@
source :rubygems
gem "term-ansicolor", :require => "term/ansicolor"
gem "rake"
gem "jasmine", git: 'https://github.com/pivotal/jasmine-gem.git'
unless ENV["TRAVIS"]
group :debug do
gem 'debugger'
end
end
gemspec

View File

@@ -1,5 +1,4 @@
<a name="README">[Jasmine](http://pivotal.github.com/jasmine/)</a> <a title="Build at Travis CI" href="http://travis-ci.org/#!/pivotal/jasmine"><img src="https://secure.travis-ci.org/pivotal/jasmine.png" /></a>
<a name="README">[Jasmine](http://pivotal.github.com/jasmine/)</a>
=======
**A JavaScript Testing Framework**
@@ -7,11 +6,18 @@ 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)
* Send an email to the list: [jasmine-js@googlegroups.com](jasmine-js@googlegroups.com)
* Check the current build status: [ci.pivotallabs.com](http://ci.pivotallabs.com)
* 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)
@@ -22,4 +28,4 @@ Documentation & guides live here: [http://pivotal.github.com/jasmine/](http://pi
* [Rajan Agaskar](mailto:rajan@pivotallabs.com), Pivotal Labs
* [Christian Williams](mailto:antixian666@gmail.com), Square
Copyright (c) 2008-2012 Pivotal Labs. This software is licensed under the MIT License.
Copyright (c) 2008-2011 Pivotal Labs. This software is licensed under the MIT License.

View File

@@ -1,5 +1,6 @@
require "bundler"
Bundler::GemHelper.install_tasks
require "term/ansicolor"
require "json"
require "tilt"
@@ -7,74 +8,26 @@ Dir["#{File.dirname(__FILE__)}/tasks/**/*.rb"].each do |file|
require file
end
desc "Run all Jasmine JS specs"
task :jasmine_specs do
jasmine_dev = JasmineDev.new
return unless jasmine_dev.node_installed?
system "thor jasmine_dev:execute_specs"
puts "\n\033[33m>>> DEPRECATED <<< Run Jasmine's JavaScript specs with 'thor jasmine_dev:execute_specs'\n\033[0m"
end
desc "Run all Jasmine core tests (JavaScript and dev tasks)"
task :spec => :require_pages_submodule do
jasmine_dev = JasmineDev.new
return unless jasmine_dev.node_installed?
system "rspec"
end
task :default => :spec
task :require_pages_submodule do
jasmine_dev = JasmineDev.new
unless jasmine_dev.pages_submodule_installed?
puts 'Installing the Github pages submodule:'
system 'git submodule update --init'
puts 'Now continuing...'
end
raise "Submodule for Github Pages isn't present. Run git submodule update --init" unless pages_submodule_present
end
desc "View full development tasks"
task :list_dev_tasks do
puts "Jasmine uses Thor for command line tasks for development. Here is the command set:"
system "thor list"
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
require "jasmine"
require 'rspec'
require 'rspec/core/rake_task'
desc "Run all examples"
RSpec::Core::RakeTask.new(:jasmine_core_spec) do |t|
t.pattern = 'spec/jasmine_self_test_spec.rb'
def pages_submodule_present
File.exist?('pages/download.html')
end
namespace :jasmine do
task :server do
port = ENV['JASMINE_PORT'] || 8888
Jasmine.load_configuration_from_yaml(File.join(Dir.pwd, 'spec', 'jasmine.yml'))
config = Jasmine.config
server = Jasmine::Server.new(8888, Jasmine::Application.app(config))
server.start
puts "your tests are here:"
puts " http://localhost:#{port}/"
end
desc "Copy examples from Jasmine JS to the gem"
task :copy_examples_to_gem do
require "fileutils"
# copy jasmine's example tree into our generator templates dir
FileUtils.rm_r('generators/jasmine/templates/jasmine-example', :force => true)
FileUtils.cp_r(File.join(Jasmine::Core.path, 'example'), 'generators/jasmine/templates/jasmine-example', :preserve => true)
end
def node_installed?
`which node` =~ /node/
end
desc "Run specs via server"
task :jasmine => ['jasmine:server']
class String
include Term::ANSIColor
end
Term::ANSIColor.coloring = STDOUT.isatty

View File

@@ -5,11 +5,8 @@ ___Jasmine Core Maintainers Only___
Follow the instructions in `Contribute.markdown` during development.
### Git Rules
### Git Commits
Please work on feature branches.
Please attempt to keep commits to `master` small, but cohesive. If a feature is contained in a bunch of small commits (e.g., it has several wip commits), please squash them when merging back to `master`.
### Version
@@ -19,11 +16,10 @@ The current version lives in the file `src/version.json`. This file should be se
This version is used by both `jasmine.js` and the `jasmine-core` Ruby gem.
Note that Jasmine should *not* use the "patch" version number. Let downstream projects rev their patch versions as needed, keeping their major and minor version numbers in sync with Jasmine core.
### 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.
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.
@@ -33,10 +29,12 @@ The pages are built with [Frank](https://github.com/blahed/frank). All the sourc
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 a `release_candidate` property with a value of 1
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. `thor jasmine_dev:release_prep` - updates the version, builds the `.js` files, builds the standalone release, and builds 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,29 +0,0 @@
#
# Compass configuration file - for building Jasmine's 'final CSS files
#
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "src/html"
sass_dir = "src/html"
images_dir = "images"
javascripts_dir = "javascripts"
# You can select your preferred output style here (can be overridden via the command line):
# output_style = :expanded or :nested or :compact or :compressed
output_style = :compact
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
# To disable debugging comments that display the original location of your selectors. Uncomment:
line_comments = false
# If you prefer the indented syntax, you might want to regenerate this
# project again passing --syntax sass, or you can uncomment this:
# preferred_syntax = :sass
# and then run:
# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass

View File

@@ -6,27 +6,17 @@ Gem::Specification.new do |s|
s.name = "jasmine-core"
s.version = Jasmine::Core::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Rajan Agaskar", "Davis W. Frank", "Christian Williams"]
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.license = "MIT"
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 "tilt"
s.add_development_dependency "sass"
s.add_development_dependency "compass"
s.add_development_dependency "frank"
s.add_development_dependency "ragaskar-jsdoc_helper"
s.add_development_dependency "rspec"
s.add_development_dependency "fuubar"
s.add_development_dependency "awesome_print"
s.add_development_dependency "thor"
s.add_development_dependency "nokogiri"
s.add_development_dependency "redcarpet", "1.7"
s.add_development_dependency "rocco"
s.add_development_dependency "rdiscount"
end

View File

@@ -1 +0,0 @@
require "#{File.expand_path(File.dirname(__FILE__))}/tasks/jasmine_dev"

View File

@@ -1,5 +1,5 @@
var fs = require("fs");
var util = require("util");
var sys = require("sys");
var path = require("path");
var JSHINT = require("./jshint").JSHINT;

View File

@@ -10,11 +10,11 @@
<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... -->
<!-- include source files here... -->
<script type="text/javascript" src="spec/SpecHelper.js"></script>
<script type="text/javascript" src="spec/PlayerSpec.js"></script>
<!-- include source files here... -->
<!-- include spec files here... -->
<script type="text/javascript" src="src/Player.js"></script>
<script type="text/javascript" src="src/Song.js"></script>

View File

@@ -78,14 +78,13 @@ jasmine.HtmlReporter = function(_doc) {
createReporterDom(runner.env.versionString());
doc.body.appendChild(dom.reporter);
setExceptionHandling();
reporterView = new jasmine.HtmlReporter.ReporterView(dom);
reporterView.addSpecs(specs, self.specFilter);
};
self.reportRunnerResults = function(runner) {
reporterView && reporterView.complete();
reporterView.complete();
};
self.reportSuiteResults = function(suite) {
@@ -132,7 +131,7 @@ jasmine.HtmlReporter = function(_doc) {
}
var paramMap = [];
var params = jasmine.HtmlReporter.parameters(doc);
var params = doc.location.search.substring(1).split('&');
for (var i = 0; i < params.length; i++) {
var p = params[i].split('=');
@@ -152,77 +151,73 @@ jasmine.HtmlReporter = function(_doc) {
self.createDom('span', { className: 'version' }, version)),
dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
dom.alert = self.createDom('div', {className: 'alert'},
self.createDom('span', { className: 'exceptions' },
self.createDom('label', { className: 'label', 'for': 'no_try_catch' }, 'No try/catch'),
self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
dom.alert = self.createDom('div', {className: 'alert'}),
dom.results = self.createDom('div', {className: 'results'},
dom.summary = self.createDom('div', { className: 'summary' }),
dom.details = self.createDom('div', { id: 'details' }))
);
}
};
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);jasmine.HtmlReporterHelpers = {};
function noTryCatch() {
return window.location.search.match(/catch=false/);
}
jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
var el = document.createElement(type);
function searchWithCatch() {
var params = jasmine.HtmlReporter.parameters(window.document);
var removed = false;
var i = 0;
for (var i = 2; i < arguments.length; i++) {
var child = arguments[i];
while (!removed && i < params.length) {
if (params[i].match(/catch=/)) {
params.splice(i, 1);
removed = true;
if (typeof child === 'string') {
el.appendChild(document.createTextNode(child));
} else {
if (child) {
el.appendChild(child);
}
i++;
}
if (jasmine.CATCH_EXCEPTIONS) {
params.push("catch=false");
}
return params.join("&");
}
function setExceptionHandling() {
var chxCatch = document.getElementById('no_try_catch');
if (noTryCatch()) {
chxCatch.setAttribute('checked', true);
jasmine.CATCH_EXCEPTIONS = false;
for (var attr in attrs) {
if (attr == "className") {
el[attr] = attrs[attr];
} else {
el.setAttribute(attr, attrs[attr]);
}
chxCatch.onclick = function() {
window.location.search = searchWithCatch();
};
}
return el;
};
jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
var results = child.results();
var status = results.passed() ? 'passed' : 'failed';
if (results.skipped) {
status = 'skipped';
}
return status;
};
jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
var parentDiv = this.dom.summary;
var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite';
var parent = child[parentSuite];
if (parent) {
if (typeof this.views.suites[parent.id] == 'undefined') {
this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views);
}
parentDiv = this.views.suites[parent.id].element;
}
parentDiv.appendChild(childElement);
};
jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
for(var fn in jasmine.HtmlReporterHelpers) {
ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn];
}
};
jasmine.HtmlReporter.parameters = function(doc) {
var paramStr = doc.location.search.substring(1);
var params = [];
if (paramStr.length > 0) {
params = paramStr.split('&');
}
return params;
}
jasmine.HtmlReporter.sectionLink = function(sectionName) {
var link = '?';
var params = [];
if (sectionName) {
params.push('spec=' + encodeURIComponent(sectionName));
}
if (!jasmine.CATCH_EXCEPTIONS) {
params.push("catch=false");
}
if (params.length > 0) {
link += params.join("&");
}
return link;
};
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
jasmine.HtmlReporter.ReporterView = function(dom) {
this.startedAt = new Date();
this.runningSpecCount = 0;
@@ -246,30 +241,8 @@ jasmine.HtmlReporter.ReporterView = function(dom) {
};
};
this.addSpecs = function(specs, specFilter) {
this.totalSpecCount = specs.length;
this.views = {
specs: {},
suites: {}
};
for (var i = 0; i < specs.length; i++) {
var spec = specs[i];
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
if (specFilter(spec)) {
this.runningSpecCount++;
}
}
};
this.specComplete = function(spec) {
this.completeSpecCount++;
if (isUndefined(this.views.specs[spec.id])) {
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
}
var specView = this.views.specs[spec.id];
switch (specView.status()) {
@@ -306,17 +279,17 @@ jasmine.HtmlReporter.ReporterView = function(dom) {
// currently running UI
if (isUndefined(this.runningAlert)) {
this.runningAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "runningAlert bar" });
this.runningAlert = this.createDom('a', {href: "?", className: "runningAlert bar"});
dom.alert.appendChild(this.runningAlert);
}
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + this.totalSpecCount + " spec" + (this.totalSpecCount == 1 ? "" : "s" );
// skipped specs UI
if (isUndefined(this.skippedAlert)) {
this.skippedAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "skippedAlert bar" });
this.skippedAlert = this.createDom('a', {href: "?", className: "skippedAlert bar"});
}
this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + this.totalSpecCount + " spec" + (this.totalSpecCount == 1 ? "" : "s" ) + " - run all";
if (this.skippedCount === 1 && isDefined(dom.alert)) {
dom.alert.appendChild(this.skippedAlert);
@@ -324,15 +297,15 @@ jasmine.HtmlReporter.ReporterView = function(dom) {
// passing specs UI
if (isUndefined(this.passedAlert)) {
this.passedAlert = this.createDom('span', { href: jasmine.HtmlReporter.sectionLink(), className: "passingAlert bar" });
this.passedAlert = this.createDom('span', {href: "?", className: "passingAlert bar"});
}
this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
this.passedAlert.innerHTML = "Passing " + this.passedCount + " spec" + (this.passedCount == 1 ? "" : "s" );
// failing specs UI
if (isUndefined(this.failedAlert)) {
this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
}
this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
this.failedAlert.innerHTML = "Failing " + this.failedCount + " spec" + (this.totalSpecCount == 1 ? "" : "s" );
if (this.failedCount === 1 && isDefined(dom.alert)) {
dom.alert.appendChild(this.failedAlert);
@@ -340,17 +313,17 @@ jasmine.HtmlReporter.ReporterView = function(dom) {
}
// summary info
this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
this.summaryMenuItem.innerHTML = "" + this.runningSpecCount + " spec" + (this.runningSpecCount == 1 ? "" : "s" );
this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
};
this.complete = function() {
dom.alert.removeChild(this.runningAlert);
this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + this.totalSpecCount + " spec" + (this.totalSpecCount == 1 ? "" : "s" ) + " - run all";
if (this.failedCount === 0) {
dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + this.passedCount + " spec" + (this.passedCount == 1 ? "" : "s" )));
} else {
showDetails();
}
@@ -358,6 +331,23 @@ jasmine.HtmlReporter.ReporterView = function(dom) {
dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
};
this.addSpecs = function(specs, specFilter) {
this.totalSpecCount = specs.length;
this.views = {
specs: {},
suites: {}
};
for (var i = 0; i < specs.length; i++) {
var spec = specs[i];
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
if (specFilter(spec)) {
this.runningSpecCount++;
}
}
};
return this;
function showDetails() {
@@ -373,15 +363,6 @@ jasmine.HtmlReporter.ReporterView = function(dom) {
function isDefined(obj) {
return !isUndefined(obj);
}
function specPluralizedFor(count) {
var str = count + " spec";
if (count > 1) {
str += "s"
}
return str;
}
};
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
@@ -396,11 +377,11 @@ jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
this.dom.symbolSummary.appendChild(this.symbol);
this.summary = this.createDom('div', { className: 'specSummary' },
this.createDom('a', {
className: 'description',
href: jasmine.HtmlReporter.sectionLink(this.spec.getFullName()),
title: this.spec.getFullName()
}, this.spec.description)
this.createDom('a', {
className: 'description',
href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
title: this.spec.getFullName()
}, this.spec.description)
);
this.detail = this.createDom('div', { className: 'specDetail' },
@@ -471,7 +452,7 @@ jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.Ht
this.views = views;
this.element = this.createDom('div', { className: 'suite' },
this.createDom('a', { className: 'description', href: jasmine.HtmlReporter.sectionLink(this.suite.getFullName()) }, this.suite.description)
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(this.suite.getFullName()) }, this.suite.description)
);
this.appendToSummary(this.suite, this.element);
@@ -487,12 +468,11 @@ jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
/* @deprecated Use jasmine.HtmlReporter instead
*/
jasmine.TrivialReporter = function(doc) {
this.document = doc || document;
this.suiteDivs = {};
this.logRunningSpecs = false;
this.log("DEPRECATION WARNING: jasmine.TrivialReporter is deprecated as of v1.2 and will be removed in version 2.0. Please use (the vastly nicer) jasmine.HtmlReporter.")
};
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {

View File

@@ -1,82 +1,413 @@
body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
/* line 25, _HTMLReporter.scss */
body {
background-color: #eeeeee;
padding: 0;
margin: 5px;
overflow-y: scroll;
}
#HTMLReporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
#HTMLReporter a { text-decoration: none; }
#HTMLReporter a:hover { text-decoration: underline; }
#HTMLReporter p, #HTMLReporter h1, #HTMLReporter h2, #HTMLReporter h3, #HTMLReporter h4, #HTMLReporter h5, #HTMLReporter h6 { margin: 0; line-height: 14px; }
#HTMLReporter .banner, #HTMLReporter .symbolSummary, #HTMLReporter .summary, #HTMLReporter .resultMessage, #HTMLReporter .specDetail .description, #HTMLReporter .alert .bar, #HTMLReporter .stackTrace { padding-left: 9px; padding-right: 9px; }
#HTMLReporter #jasmine_content { position: fixed; right: 100%; }
#HTMLReporter .version { color: #aaaaaa; }
#HTMLReporter .banner { margin-top: 14px; }
#HTMLReporter .duration { color: #aaaaaa; float: right; }
#HTMLReporter .symbolSummary { overflow: hidden; *zoom: 1; margin: 14px 0; }
#HTMLReporter .symbolSummary li { display: block; float: left; height: 7px; width: 14px; margin-bottom: 7px; font-size: 16px; }
#HTMLReporter .symbolSummary li.passed { font-size: 14px; }
#HTMLReporter .symbolSummary li.passed:before { color: #5e7d00; content: "\02022"; }
#HTMLReporter .symbolSummary li.failed { line-height: 9px; }
#HTMLReporter .symbolSummary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; }
#HTMLReporter .symbolSummary li.skipped { font-size: 14px; }
#HTMLReporter .symbolSummary li.skipped:before { color: #bababa; content: "\02022"; }
#HTMLReporter .symbolSummary li.pending { line-height: 11px; }
#HTMLReporter .symbolSummary li.pending:before { color: #aaaaaa; content: "-"; }
#HTMLReporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
#HTMLReporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
#HTMLReporter .runningAlert { background-color: #666666; }
#HTMLReporter .skippedAlert { background-color: #aaaaaa; }
#HTMLReporter .skippedAlert:first-child { background-color: #333333; }
#HTMLReporter .skippedAlert:hover { text-decoration: none; color: white; text-decoration: underline; }
#HTMLReporter .passingAlert { background-color: #a6b779; }
#HTMLReporter .passingAlert:first-child { background-color: #5e7d00; }
#HTMLReporter .failingAlert { background-color: #cf867e; }
#HTMLReporter .failingAlert:first-child { background-color: #b03911; }
#HTMLReporter .results { margin-top: 14px; }
#HTMLReporter #details { display: none; }
#HTMLReporter .resultsMenu, #HTMLReporter .resultsMenu a { background-color: #fff; color: #333333; }
#HTMLReporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
#HTMLReporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
#HTMLReporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
#HTMLReporter.showDetails .summary { display: none; }
#HTMLReporter.showDetails #details { display: block; }
#HTMLReporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
#HTMLReporter .summary { margin-top: 14px; }
#HTMLReporter .summary .suite .suite, #HTMLReporter .summary .specSummary { margin-left: 14px; }
#HTMLReporter .summary .specSummary.passed a { color: #5e7d00; }
#HTMLReporter .summary .specSummary.failed a { color: #b03911; }
#HTMLReporter .description + .suite { margin-top: 0; }
#HTMLReporter .suite { margin-top: 14px; }
#HTMLReporter .suite a { color: #333333; }
#HTMLReporter #details .specDetail { margin-bottom: 28px; }
#HTMLReporter #details .specDetail .description { display: block; color: white; background-color: #b03911; }
#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
#HTMLReporter .resultMessage span.result { display: block; }
#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
/* line 32, _HTMLReporter.scss */
#HTMLReporter {
font-size: 11px;
font-family: Monaco, "Lucida Console", monospace;
line-height: 14px;
color: #333333;
}
/* line 39, _HTMLReporter.scss */
#HTMLReporter a {
text-decoration: none;
}
/* line 42, _HTMLReporter.scss */
#HTMLReporter a:hover {
text-decoration: underline;
}
/* line 47, _HTMLReporter.scss */
#HTMLReporter p, #HTMLReporter h1, #HTMLReporter h2, #HTMLReporter h3, #HTMLReporter h4, #HTMLReporter h5, #HTMLReporter h6 {
margin: 0;
line-height: 14px;
}
/* line 58, _HTMLReporter.scss */
#HTMLReporter .banner,
#HTMLReporter .symbolSummary,
#HTMLReporter .summary,
#HTMLReporter .resultMessage,
#HTMLReporter .specDetail .description,
#HTMLReporter .alert .bar,
#HTMLReporter .stackTrace {
padding-left: 9px;
padding-right: 9px;
}
/* line 65, _HTMLReporter.scss */
#HTMLReporter #jasmine_content {
position: fixed;
right: 100%;
}
/* line 70, _HTMLReporter.scss */
#HTMLReporter .version {
color: #aaaaaa;
}
/* line 77, _HTMLReporter.scss */
#HTMLReporter .banner {
margin-top: 14px;
}
/* line 81, _HTMLReporter.scss */
#HTMLReporter .duration {
color: #aaaaaa;
float: right;
}
/* line 90, _HTMLReporter.scss */
#HTMLReporter .symbolSummary {
overflow: hidden;
*zoom: 1;
margin: 14px 0;
}
/* line 94, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li {
display: block;
float: left;
height: 7px;
width: 14px;
margin-bottom: 7px;
font-size: 16px;
}
/* line 105, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li.passed {
font-size: 14px;
}
/* line 108, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li.passed:before {
color: #5e7d00;
content: "\02022";
}
/* line 114, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li.failed {
line-height: 9px;
}
/* line 117, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li.failed:before {
color: #b03911;
content: "x";
font-weight: bold;
margin-left: -1px;
}
/* line 125, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li.skipped {
font-size: 14px;
}
/* line 128, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li.skipped:before {
color: #bababa;
content: "\02022";
}
/* line 134, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li.pending {
line-height: 11px;
}
/* line 137, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li.pending:before {
color: #aaaaaa;
content: "-";
}
/* line 149, _HTMLReporter.scss */
#HTMLReporter .bar {
line-height: 28px;
font-size: 14px;
display: block;
color: #eee;
}
/* line 158, _HTMLReporter.scss */
#HTMLReporter .runningAlert {
background-color: #666666;
}
/* line 162, _HTMLReporter.scss */
#HTMLReporter .skippedAlert {
background-color: #aaaaaa;
}
/* line 165, _HTMLReporter.scss */
#HTMLReporter .skippedAlert:first-child {
background-color: #333333;
}
/* line 169, _HTMLReporter.scss */
#HTMLReporter .skippedAlert:hover {
text-decoration: none;
color: white;
text-decoration: underline;
}
/* line 176, _HTMLReporter.scss */
#HTMLReporter .passingAlert {
background-color: #a6b779;
}
/* line 179, _HTMLReporter.scss */
#HTMLReporter .passingAlert:first-child {
background-color: #5e7d00;
}
/* line 184, _HTMLReporter.scss */
#HTMLReporter .failingAlert {
background-color: #cf867e;
}
/* line 187, _HTMLReporter.scss */
#HTMLReporter .failingAlert:first-child {
background-color: #b03911;
}
/* line 200, _HTMLReporter.scss */
#HTMLReporter .results {
margin-top: 14px;
}
/* line 208, _HTMLReporter.scss */
#HTMLReporter #details {
display: none;
}
/* line 213, _HTMLReporter.scss */
#HTMLReporter .resultsMenu,
#HTMLReporter .resultsMenu a {
background-color: #fff;
color: #333333;
}
/* line 220, _HTMLReporter.scss */
#HTMLReporter.showDetails .summaryMenuItem {
font-weight: normal;
text-decoration: inherit;
}
/* line 224, _HTMLReporter.scss */
#HTMLReporter.showDetails .summaryMenuItem:hover {
text-decoration: underline;
}
/* line 229, _HTMLReporter.scss */
#HTMLReporter.showDetails .detailsMenuItem {
font-weight: bold;
text-decoration: underline;
}
/* line 234, _HTMLReporter.scss */
#HTMLReporter.showDetails .summary {
display: none;
}
/* line 238, _HTMLReporter.scss */
#HTMLReporter.showDetails #details {
display: block;
}
/* line 243, _HTMLReporter.scss */
#HTMLReporter .summaryMenuItem {
font-weight: bold;
text-decoration: underline;
}
/* line 253, _HTMLReporter.scss */
#HTMLReporter .summary {
margin-top: 14px;
}
/* line 256, _HTMLReporter.scss */
#HTMLReporter .summary .suite .suite, #HTMLReporter .summary .specSummary {
margin-left: 14px;
}
/* line 261, _HTMLReporter.scss */
#HTMLReporter .summary .specSummary.passed a {
color: #5e7d00;
}
/* line 264, _HTMLReporter.scss */
#HTMLReporter .summary .specSummary.failed a {
color: #b03911;
}
/* line 270, _HTMLReporter.scss */
#HTMLReporter .description + .suite {
margin-top: 0;
}
/* line 274, _HTMLReporter.scss */
#HTMLReporter .suite {
margin-top: 14px;
}
/* line 277, _HTMLReporter.scss */
#HTMLReporter .suite a {
color: #333333;
}
/* line 288, _HTMLReporter.scss */
#HTMLReporter #details .specDetail {
margin-bottom: 28px;
}
/* line 291, _HTMLReporter.scss */
#HTMLReporter #details .specDetail .description {
display: block;
color: white;
background-color: #b03911;
}
/* line 303, _HTMLReporter.scss */
#HTMLReporter .resultMessage {
padding-top: 14px;
color: #333333;
}
/* line 309, _HTMLReporter.scss */
#HTMLReporter .resultMessage span.result {
display: block;
}
/* line 313, _HTMLReporter.scss */
#HTMLReporter .stackTrace {
margin: 5px 0 0 0;
max-height: 224px;
overflow: auto;
line-height: 18px;
color: #666666;
border: 1px solid #ddd;
background: white;
white-space: pre;
}
#TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ }
#TrivialReporter a:visited, #TrivialReporter a { color: #303; }
#TrivialReporter a:hover, #TrivialReporter a:active { color: blue; }
#TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; }
#TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; }
#TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; }
#TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; }
#TrivialReporter .runner.running { background-color: yellow; }
#TrivialReporter .options { text-align: right; font-size: .8em; }
#TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; }
#TrivialReporter .suite .suite { margin: 5px; }
#TrivialReporter .suite.passed { background-color: #dfd; }
#TrivialReporter .suite.failed { background-color: #fdd; }
#TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; }
#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; }
#TrivialReporter .spec.failed { background-color: #fbb; border-color: red; }
#TrivialReporter .spec.passed { background-color: #bfb; border-color: green; }
#TrivialReporter .spec.skipped { background-color: #bbb; }
#TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; }
#TrivialReporter .passed { background-color: #cfc; display: none; }
#TrivialReporter .failed { background-color: #fbb; }
#TrivialReporter .skipped { color: #777; background-color: #eee; display: none; }
#TrivialReporter .resultMessage span.result { display: block; line-height: 2em; color: black; }
#TrivialReporter .resultMessage .mismatch { color: black; }
#TrivialReporter .stackTrace { white-space: pre; font-size: .8em; margin-left: 10px; max-height: 5em; overflow: auto; border: 1px inset red; padding: 1em; background: #eef; }
#TrivialReporter .finished-at { padding-left: 1em; font-size: .6em; }
#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped { display: block; }
#TrivialReporter #jasmine_content { position: fixed; right: 100%; }
#TrivialReporter .runner { border: 1px solid gray; display: block; margin: 5px 0; padding: 2px 0 2px 10px; }
/* line 2, _TrivialReporter.scss */
#TrivialReporter {
padding: 8px 13px;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
overflow-y: scroll;
background-color: white;
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
/*.resultMessage {*/
/*white-space: pre;*/
/*}*/
}
/* line 14, _TrivialReporter.scss */
#TrivialReporter a:visited, #TrivialReporter a {
color: #303;
}
/* line 18, _TrivialReporter.scss */
#TrivialReporter a:hover, #TrivialReporter a:active {
color: blue;
}
/* line 22, _TrivialReporter.scss */
#TrivialReporter .run_spec {
float: right;
padding-right: 5px;
font-size: .8em;
text-decoration: none;
}
/* line 29, _TrivialReporter.scss */
#TrivialReporter .banner {
color: #303;
background-color: #fef;
padding: 5px;
}
/* line 35, _TrivialReporter.scss */
#TrivialReporter .logo {
float: left;
font-size: 1.1em;
padding-left: 5px;
}
/* line 41, _TrivialReporter.scss */
#TrivialReporter .logo .version {
font-size: .6em;
padding-left: 1em;
}
/* line 46, _TrivialReporter.scss */
#TrivialReporter .runner.running {
background-color: yellow;
}
/* line 51, _TrivialReporter.scss */
#TrivialReporter .options {
text-align: right;
font-size: .8em;
}
/* line 59, _TrivialReporter.scss */
#TrivialReporter .suite {
border: 1px outset gray;
margin: 5px 0;
padding-left: 1em;
}
/* line 65, _TrivialReporter.scss */
#TrivialReporter .suite .suite {
margin: 5px;
}
/* line 69, _TrivialReporter.scss */
#TrivialReporter .suite.passed {
background-color: #dfd;
}
/* line 73, _TrivialReporter.scss */
#TrivialReporter .suite.failed {
background-color: #fdd;
}
/* line 77, _TrivialReporter.scss */
#TrivialReporter .spec {
margin: 5px;
padding-left: 1em;
clear: both;
}
/* line 83, _TrivialReporter.scss */
#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped {
padding-bottom: 5px;
border: 1px solid gray;
}
/* line 88, _TrivialReporter.scss */
#TrivialReporter .spec.failed {
background-color: #fbb;
border-color: red;
}
/* line 93, _TrivialReporter.scss */
#TrivialReporter .spec.passed {
background-color: #bfb;
border-color: green;
}
/* line 98, _TrivialReporter.scss */
#TrivialReporter .spec.skipped {
background-color: #bbb;
}
/* line 102, _TrivialReporter.scss */
#TrivialReporter .messages {
border-left: 1px dashed gray;
padding-left: 1em;
padding-right: 1em;
}
/* line 108, _TrivialReporter.scss */
#TrivialReporter .passed {
background-color: #cfc;
display: none;
}
/* line 113, _TrivialReporter.scss */
#TrivialReporter .failed {
background-color: #fbb;
}
/* line 117, _TrivialReporter.scss */
#TrivialReporter .skipped {
color: #777;
background-color: #eee;
display: none;
}
/* line 128, _TrivialReporter.scss */
#TrivialReporter .resultMessage span.result {
display: block;
line-height: 2em;
color: black;
}
/* line 134, _TrivialReporter.scss */
#TrivialReporter .resultMessage .mismatch {
color: black;
}
/* line 138, _TrivialReporter.scss */
#TrivialReporter .stackTrace {
white-space: pre;
font-size: .8em;
margin-left: 10px;
max-height: 5em;
overflow: auto;
border: 1px inset red;
padding: 1em;
background: #eef;
}
/* line 149, _TrivialReporter.scss */
#TrivialReporter .finished-at {
padding-left: 1em;
font-size: .6em;
}
/* line 155, _TrivialReporter.scss */
#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped {
display: block;
}
/* line 160, _TrivialReporter.scss */
#TrivialReporter #jasmine_content {
position: fixed;
right: 100%;
}
/* line 165, _TrivialReporter.scss */
#TrivialReporter .runner {
border: 1px solid gray;
display: block;
margin: 5px 0;
padding: 2px 0 2px 10px;
}

View File

@@ -1,4 +1,4 @@
var isCommonJS = typeof window == "undefined" && typeof exports == "object";
var isCommonJS = typeof window == "undefined";
/**
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
@@ -34,23 +34,11 @@ jasmine.VERBOSE = false;
*/
jasmine.DEFAULT_UPDATE_INTERVAL = 250;
/**
* Maximum levels of nesting that will be included when an object is pretty-printed
*/
jasmine.MAX_PRETTY_PRINT_DEPTH = 40;
/**
* Default timeout interval in milliseconds for waitsFor() blocks.
*/
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
/**
* By default exceptions thrown in the context of a test are caught by jasmine so that it can run the remaining tests in the suite.
* Set to false to let the exception bubble up in the browser.
*
*/
jasmine.CATCH_EXCEPTIONS = true;
jasmine.getGlobal = function() {
function getGlobal() {
return this;
@@ -208,21 +196,6 @@ jasmine.any = function(clazz) {
return new jasmine.Matchers.Any(clazz);
};
/**
* Returns a matchable subset of a JSON object. For use in expectations when you don't care about all of the
* attributes on the object.
*
* @example
* // don't care about any other attributes than foo.
* expect(mySpy).toHaveBeenCalledWith(jasmine.objectContaining({foo: "bar"});
*
* @param sample {Object} sample
* @returns matchable object for the sample
*/
jasmine.objectContaining = function (sample) {
return new jasmine.Matchers.ObjectContaining(sample);
};
/**
* Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks.
*
@@ -475,7 +448,7 @@ jasmine.log = function() {
* @see jasmine.createSpy
* @param obj
* @param methodName
* @return {jasmine.Spy} a Jasmine spy that can be chained with all spy methods
* @returns a Jasmine spy that can be chained with all spy methods
*/
var spyOn = function(obj, methodName) {
return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
@@ -520,7 +493,6 @@ if (isCommonJS) exports.xit = xit;
* jasmine.Matchers functions.
*
* @param {Object} actual Actual value to test against and expected value
* @return {jasmine.Matchers}
*/
var expect = function(actual) {
return jasmine.getEnv().currentSpec.expect(actual);
@@ -880,25 +852,6 @@ jasmine.Env.prototype.xit = function(desc, func) {
};
};
jasmine.Env.prototype.compareRegExps_ = function(a, b, mismatchKeys, mismatchValues) {
if (a.source != b.source)
mismatchValues.push("expected pattern /" + b.source + "/ is not equal to the pattern /" + a.source + "/");
if (a.ignoreCase != b.ignoreCase)
mismatchValues.push("expected modifier i was" + (b.ignoreCase ? " " : " not ") + "set and does not equal the origin modifier");
if (a.global != b.global)
mismatchValues.push("expected modifier g was" + (b.global ? " " : " not ") + "set and does not equal the origin modifier");
if (a.multiline != b.multiline)
mismatchValues.push("expected modifier m was" + (b.multiline ? " " : " not ") + "set and does not equal the origin modifier");
if (a.sticky != b.sticky)
mismatchValues.push("expected modifier y was" + (b.sticky ? " " : " not ") + "set and does not equal the origin modifier");
return (mismatchValues.length === 0);
};
jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {
if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {
return true;
@@ -961,19 +914,11 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
return a.getTime() == b.getTime();
}
if (a.jasmineMatches) {
return a.jasmineMatches(b);
}
if (b.jasmineMatches) {
return b.jasmineMatches(a);
}
if (a instanceof jasmine.Matchers.ObjectContaining) {
if (a instanceof jasmine.Matchers.Any) {
return a.matches(b);
}
if (b instanceof jasmine.Matchers.ObjectContaining) {
if (b instanceof jasmine.Matchers.Any) {
return b.matches(a);
}
@@ -985,10 +930,6 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
return (a == b);
}
if (a instanceof RegExp && b instanceof RegExp) {
return this.compareRegExps_(a, b, mismatchKeys, mismatchValues);
}
if (typeof a === "object" && typeof b === "object") {
return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
}
@@ -1055,16 +996,11 @@ jasmine.Block = function(env, func, spec) {
this.spec = spec;
};
jasmine.Block.prototype.execute = function(onComplete) {
if (!jasmine.CATCH_EXCEPTIONS) {
jasmine.Block.prototype.execute = function(onComplete) {
try {
this.func.apply(this.spec);
}
else {
try {
this.func.apply(this.spec);
} catch (e) {
this.spec.fail(e);
}
} catch (e) {
this.spec.fail(e);
}
onComplete();
};
@@ -1276,7 +1212,7 @@ jasmine.Matchers.prototype.toEqual = function(expected) {
/**
* toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
* @param expected
* @deprecated as of 1.0. Use not.toEqual() instead.
* @deprecated as of 1.0. Use not.toNotEqual() instead.
*/
jasmine.Matchers.prototype.toNotEqual = function(expected) {
return !this.env.equals_(this.actual, expected);
@@ -1322,17 +1258,6 @@ jasmine.Matchers.prototype.toBeNull = function() {
return (this.actual === null);
};
/**
* Matcher that compares the actual to NaN.
*/
jasmine.Matchers.prototype.toBeNaN = function() {
this.message = function() {
return [ "Expected " + jasmine.pp(this.actual) + " to be NaN." ];
};
return (this.actual !== this.actual);
};
/**
* Matcher that boolean not-nots the actual.
*/
@@ -1410,14 +1335,18 @@ jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
}
this.message = function() {
var invertedMessage = "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was.";
var positiveMessage = "";
if (this.actual.callCount === 0) {
positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.";
// todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw]
return [
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was."
];
} else {
positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but actual calls were " + jasmine.pp(this.actual.argsForCall).replace(/^\[ | \]$/g, '')
return [
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall),
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall)
];
}
return [positiveMessage, invertedMessage];
};
return this.env.contains_(this.actual.argsForCall, expectedArgs);
@@ -1456,7 +1385,7 @@ jasmine.Matchers.prototype.toContain = function(expected) {
* Matcher that checks that the expected item is NOT an element in the actual Array.
*
* @param {Object} expected
* @deprecated as of 1.0. Use not.toContain() instead.
* @deprecated as of 1.0. Use not.toNotContain() instead.
*/
jasmine.Matchers.prototype.toNotContain = function(expected) {
return !this.env.contains_(this.actual, expected);
@@ -1475,19 +1404,22 @@ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
* up to a given level of decimal precision (default 2).
*
* @param {Number} expected
* @param {Number} precision, as number of decimal places
* @param {Number} precision
*/
jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
if (!(precision === 0)) {
precision = precision || 2;
}
return Math.abs(expected - this.actual) < (Math.pow(10, -precision) / 2);
var multiplier = Math.pow(10, precision);
var actual = Math.round(this.actual * multiplier);
expected = Math.round(expected * multiplier);
return expected == actual;
};
/**
* Matcher that checks that the expected exception was thrown by the actual.
*
* @param {String} [expected]
* @param {String} expected
*/
jasmine.Matchers.prototype.toThrow = function(expected) {
var result = false;
@@ -1521,7 +1453,7 @@ jasmine.Matchers.Any = function(expectedClass) {
this.expectedClass = expectedClass;
};
jasmine.Matchers.Any.prototype.jasmineMatches = function(other) {
jasmine.Matchers.Any.prototype.matches = function(other) {
if (this.expectedClass == String) {
return typeof other == 'string' || other instanceof String;
}
@@ -1541,222 +1473,10 @@ jasmine.Matchers.Any.prototype.jasmineMatches = function(other) {
return other instanceof this.expectedClass;
};
jasmine.Matchers.Any.prototype.jasmineToString = function() {
jasmine.Matchers.Any.prototype.toString = function() {
return '<jasmine.any(' + this.expectedClass + ')>';
};
jasmine.Matchers.ObjectContaining = function (sample) {
this.sample = sample;
};
jasmine.Matchers.ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) {
mismatchKeys = mismatchKeys || [];
mismatchValues = mismatchValues || [];
var env = jasmine.getEnv();
var hasKey = function(obj, keyName) {
return obj != null && obj[keyName] !== jasmine.undefined;
};
for (var property in this.sample) {
if (!hasKey(other, property) && hasKey(this.sample, property)) {
mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
}
else if (!env.equals_(this.sample[property], other[property], mismatchKeys, mismatchValues)) {
mismatchValues.push("'" + property + "' was '" + (other[property] ? jasmine.util.htmlEscape(other[property].toString()) : other[property]) + "' in expected, but was '" + (this.sample[property] ? jasmine.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in actual.");
}
}
return (mismatchKeys.length === 0 && mismatchValues.length === 0);
};
jasmine.Matchers.ObjectContaining.prototype.jasmineToString = function () {
return "<jasmine.objectContaining(" + jasmine.pp(this.sample) + ")>";
};
// Mock setTimeout, clearTimeout
// Contributed by Pivotal Computer Systems, www.pivotalsf.com
jasmine.FakeTimer = function() {
this.reset();
var self = this;
self.setTimeout = function(funcToCall, millis) {
self.timeoutsMade++;
self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false);
return self.timeoutsMade;
};
self.setInterval = function(funcToCall, millis) {
self.timeoutsMade++;
self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true);
return self.timeoutsMade;
};
self.clearTimeout = function(timeoutKey) {
self.scheduledFunctions[timeoutKey] = jasmine.undefined;
};
self.clearInterval = function(timeoutKey) {
self.scheduledFunctions[timeoutKey] = jasmine.undefined;
};
};
jasmine.FakeTimer.prototype.reset = function() {
this.timeoutsMade = 0;
this.scheduledFunctions = {};
this.nowMillis = 0;
};
jasmine.FakeTimer.prototype.tick = function(millis) {
var oldMillis = this.nowMillis;
var newMillis = oldMillis + millis;
this.runFunctionsWithinRange(oldMillis, newMillis);
this.nowMillis = newMillis;
};
jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) {
var scheduledFunc;
var funcsToRun = [];
for (var timeoutKey in this.scheduledFunctions) {
scheduledFunc = this.scheduledFunctions[timeoutKey];
if (scheduledFunc != jasmine.undefined &&
scheduledFunc.runAtMillis >= oldMillis &&
scheduledFunc.runAtMillis <= nowMillis) {
funcsToRun.push(scheduledFunc);
this.scheduledFunctions[timeoutKey] = jasmine.undefined;
}
}
if (funcsToRun.length > 0) {
funcsToRun.sort(function(a, b) {
return a.runAtMillis - b.runAtMillis;
});
for (var i = 0; i < funcsToRun.length; ++i) {
try {
var funcToRun = funcsToRun[i];
this.nowMillis = funcToRun.runAtMillis;
funcToRun.funcToCall();
if (funcToRun.recurring) {
this.scheduleFunction(funcToRun.timeoutKey,
funcToRun.funcToCall,
funcToRun.millis,
true);
}
} catch(e) {
}
}
this.runFunctionsWithinRange(oldMillis, nowMillis);
}
};
jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) {
this.scheduledFunctions[timeoutKey] = {
runAtMillis: this.nowMillis + millis,
funcToCall: funcToCall,
recurring: recurring,
timeoutKey: timeoutKey,
millis: millis
};
};
/**
* @namespace
*/
jasmine.Clock = {
defaultFakeTimer: new jasmine.FakeTimer(),
reset: function() {
jasmine.Clock.assertInstalled();
jasmine.Clock.defaultFakeTimer.reset();
},
tick: function(millis) {
jasmine.Clock.assertInstalled();
jasmine.Clock.defaultFakeTimer.tick(millis);
},
runFunctionsWithinRange: function(oldMillis, nowMillis) {
jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis);
},
scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {
jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring);
},
useMock: function() {
if (!jasmine.Clock.isInstalled()) {
var spec = jasmine.getEnv().currentSpec;
spec.after(jasmine.Clock.uninstallMock);
jasmine.Clock.installMock();
}
},
installMock: function() {
jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer;
},
uninstallMock: function() {
jasmine.Clock.assertInstalled();
jasmine.Clock.installed = jasmine.Clock.real;
},
real: {
setTimeout: jasmine.getGlobal().setTimeout,
clearTimeout: jasmine.getGlobal().clearTimeout,
setInterval: jasmine.getGlobal().setInterval,
clearInterval: jasmine.getGlobal().clearInterval
},
assertInstalled: function() {
if (!jasmine.Clock.isInstalled()) {
throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
}
},
isInstalled: function() {
return jasmine.Clock.installed == jasmine.Clock.defaultFakeTimer;
},
installed: null
};
jasmine.Clock.installed = jasmine.Clock.real;
//else for IE support
jasmine.getGlobal().setTimeout = function(funcToCall, millis) {
if (jasmine.Clock.installed.setTimeout.apply) {
return jasmine.Clock.installed.setTimeout.apply(this, arguments);
} else {
return jasmine.Clock.installed.setTimeout(funcToCall, millis);
}
};
jasmine.getGlobal().setInterval = function(funcToCall, millis) {
if (jasmine.Clock.installed.setInterval.apply) {
return jasmine.Clock.installed.setInterval.apply(this, arguments);
} else {
return jasmine.Clock.installed.setInterval(funcToCall, millis);
}
};
jasmine.getGlobal().clearTimeout = function(timeoutKey) {
if (jasmine.Clock.installed.clearTimeout.apply) {
return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
} else {
return jasmine.Clock.installed.clearTimeout(timeoutKey);
}
};
jasmine.getGlobal().clearInterval = function(timeoutKey) {
if (jasmine.Clock.installed.clearTimeout.apply) {
return jasmine.Clock.installed.clearInterval.apply(this, arguments);
} else {
return jasmine.Clock.installed.clearInterval(timeoutKey);
}
};
/**
* @constructor
*/
@@ -1885,6 +1605,10 @@ jasmine.PrettyPrinter = function() {
* @param value
*/
jasmine.PrettyPrinter.prototype.format = function(value) {
if (this.ppNestLevel_ > 40) {
throw new Error('jasmine.PrettyPrinter: format() nested too deeply!');
}
this.ppNestLevel_++;
try {
if (value === jasmine.undefined) {
@@ -1893,8 +1617,8 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
this.emitScalar('null');
} else if (value === jasmine.getGlobal()) {
this.emitScalar('<global>');
} else if (value.jasmineToString) {
this.emitScalar(value.jasmineToString());
} else if (value instanceof jasmine.Matchers.Any) {
this.emitScalar(value.toString());
} else if (typeof value === 'string') {
this.emitString(value);
} else if (jasmine.isSpy(value)) {
@@ -1927,7 +1651,6 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
for (var property in obj) {
if (!obj.hasOwnProperty(property)) continue;
if (property == '__Jasmine_been_here_before__') continue;
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined &&
obj.__lookupGetter__(property) !== null) : false);
@@ -1955,11 +1678,6 @@ jasmine.StringPrettyPrinter.prototype.emitString = function(value) {
};
jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
this.append("Array");
return;
}
this.append('[ ');
for (var i = 0; i < array.length; i++) {
if (i > 0) {
@@ -1971,11 +1689,6 @@ jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
};
jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) {
if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
this.append("Object");
return;
}
var self = this;
this.append('{ ');
var first = true;
@@ -2004,10 +1717,6 @@ jasmine.StringPrettyPrinter.prototype.append = function(value) {
};
jasmine.Queue = function(env) {
this.env = env;
// parallel to blocks. each true value in this array means the block will
// get executed even if we abort
this.ensured = [];
this.blocks = [];
this.running = false;
this.index = 0;
@@ -2015,30 +1724,15 @@ jasmine.Queue = function(env) {
this.abort = false;
};
jasmine.Queue.prototype.addBefore = function(block, ensure) {
if (ensure === jasmine.undefined) {
ensure = false;
}
jasmine.Queue.prototype.addBefore = function(block) {
this.blocks.unshift(block);
this.ensured.unshift(ensure);
};
jasmine.Queue.prototype.add = function(block, ensure) {
if (ensure === jasmine.undefined) {
ensure = false;
}
jasmine.Queue.prototype.add = function(block) {
this.blocks.push(block);
this.ensured.push(ensure);
};
jasmine.Queue.prototype.insertNext = function(block, ensure) {
if (ensure === jasmine.undefined) {
ensure = false;
}
this.ensured.splice((this.index + this.offset + 1), 0, ensure);
jasmine.Queue.prototype.insertNext = function(block) {
this.blocks.splice((this.index + this.offset + 1), 0, block);
this.offset++;
};
@@ -2062,7 +1756,7 @@ jasmine.Queue.prototype.next_ = function() {
while (goAgain) {
goAgain = false;
if (self.index < self.blocks.length && !(this.abort && !this.ensured[self.index])) {
if (self.index < self.blocks.length && !this.abort) {
var calledSynchronously = true;
var completedSynchronously = false;
@@ -2353,7 +2047,7 @@ jasmine.Spec.prototype.finish = function(onComplete) {
jasmine.Spec.prototype.after = function(doAfter) {
if (this.queue.isRunning()) {
this.queue.add(new jasmine.Block(this.env, doAfter, this), true);
this.queue.add(new jasmine.Block(this.env, doAfter, this));
} else {
this.afterCallbacks.unshift(doAfter);
}
@@ -2391,15 +2085,15 @@ jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {
this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this));
}
for (i = 0; i < this.afterCallbacks.length; i++) {
this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this), true);
this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this));
}
for (suite = this.suite; suite; suite = suite.parentSuite) {
for (i = 0; i < suite.after_.length; i++) {
this.queue.add(new jasmine.Block(this.env, suite.after_[i], this), true);
this.queue.add(new jasmine.Block(this.env, suite.after_[i], this));
}
}
for (i = 0; i < runner.after_.length; i++) {
this.queue.add(new jasmine.Block(this.env, runner.after_[i], this), true);
this.queue.add(new jasmine.Block(this.env, runner.after_[i], this));
}
};
@@ -2591,10 +2285,193 @@ jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
}, jasmine.WaitsForBlock.TIMEOUT_INCREMENT);
}
};
// Mock setTimeout, clearTimeout
// Contributed by Pivotal Computer Systems, www.pivotalsf.com
jasmine.FakeTimer = function() {
this.reset();
var self = this;
self.setTimeout = function(funcToCall, millis) {
self.timeoutsMade++;
self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false);
return self.timeoutsMade;
};
self.setInterval = function(funcToCall, millis) {
self.timeoutsMade++;
self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true);
return self.timeoutsMade;
};
self.clearTimeout = function(timeoutKey) {
self.scheduledFunctions[timeoutKey] = jasmine.undefined;
};
self.clearInterval = function(timeoutKey) {
self.scheduledFunctions[timeoutKey] = jasmine.undefined;
};
};
jasmine.FakeTimer.prototype.reset = function() {
this.timeoutsMade = 0;
this.scheduledFunctions = {};
this.nowMillis = 0;
};
jasmine.FakeTimer.prototype.tick = function(millis) {
var oldMillis = this.nowMillis;
var newMillis = oldMillis + millis;
this.runFunctionsWithinRange(oldMillis, newMillis);
this.nowMillis = newMillis;
};
jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) {
var scheduledFunc;
var funcsToRun = [];
for (var timeoutKey in this.scheduledFunctions) {
scheduledFunc = this.scheduledFunctions[timeoutKey];
if (scheduledFunc != jasmine.undefined &&
scheduledFunc.runAtMillis >= oldMillis &&
scheduledFunc.runAtMillis <= nowMillis) {
funcsToRun.push(scheduledFunc);
this.scheduledFunctions[timeoutKey] = jasmine.undefined;
}
}
if (funcsToRun.length > 0) {
funcsToRun.sort(function(a, b) {
return a.runAtMillis - b.runAtMillis;
});
for (var i = 0; i < funcsToRun.length; ++i) {
try {
var funcToRun = funcsToRun[i];
this.nowMillis = funcToRun.runAtMillis;
funcToRun.funcToCall();
if (funcToRun.recurring) {
this.scheduleFunction(funcToRun.timeoutKey,
funcToRun.funcToCall,
funcToRun.millis,
true);
}
} catch(e) {
}
}
this.runFunctionsWithinRange(oldMillis, nowMillis);
}
};
jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) {
this.scheduledFunctions[timeoutKey] = {
runAtMillis: this.nowMillis + millis,
funcToCall: funcToCall,
recurring: recurring,
timeoutKey: timeoutKey,
millis: millis
};
};
/**
* @namespace
*/
jasmine.Clock = {
defaultFakeTimer: new jasmine.FakeTimer(),
reset: function() {
jasmine.Clock.assertInstalled();
jasmine.Clock.defaultFakeTimer.reset();
},
tick: function(millis) {
jasmine.Clock.assertInstalled();
jasmine.Clock.defaultFakeTimer.tick(millis);
},
runFunctionsWithinRange: function(oldMillis, nowMillis) {
jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis);
},
scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {
jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring);
},
useMock: function() {
if (!jasmine.Clock.isInstalled()) {
var spec = jasmine.getEnv().currentSpec;
spec.after(jasmine.Clock.uninstallMock);
jasmine.Clock.installMock();
}
},
installMock: function() {
jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer;
},
uninstallMock: function() {
jasmine.Clock.assertInstalled();
jasmine.Clock.installed = jasmine.Clock.real;
},
real: {
setTimeout: jasmine.getGlobal().setTimeout,
clearTimeout: jasmine.getGlobal().clearTimeout,
setInterval: jasmine.getGlobal().setInterval,
clearInterval: jasmine.getGlobal().clearInterval
},
assertInstalled: function() {
if (!jasmine.Clock.isInstalled()) {
throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
}
},
isInstalled: function() {
return jasmine.Clock.installed == jasmine.Clock.defaultFakeTimer;
},
installed: null
};
jasmine.Clock.installed = jasmine.Clock.real;
//else for IE support
jasmine.getGlobal().setTimeout = function(funcToCall, millis) {
if (jasmine.Clock.installed.setTimeout.apply) {
return jasmine.Clock.installed.setTimeout.apply(this, arguments);
} else {
return jasmine.Clock.installed.setTimeout(funcToCall, millis);
}
};
jasmine.getGlobal().setInterval = function(funcToCall, millis) {
if (jasmine.Clock.installed.setInterval.apply) {
return jasmine.Clock.installed.setInterval.apply(this, arguments);
} else {
return jasmine.Clock.installed.setInterval(funcToCall, millis);
}
};
jasmine.getGlobal().clearTimeout = function(timeoutKey) {
if (jasmine.Clock.installed.clearTimeout.apply) {
return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
} else {
return jasmine.Clock.installed.clearTimeout(timeoutKey);
}
};
jasmine.getGlobal().clearInterval = function(timeoutKey) {
if (jasmine.Clock.installed.clearTimeout.apply) {
return jasmine.Clock.installed.clearInterval.apply(this, arguments);
} else {
return jasmine.Clock.installed.clearInterval(timeoutKey);
}
};
jasmine.version_= {
"major": 1,
"minor": 3,
"build": 1,
"revision": 1354556913
"minor": 2,
"build": 0,
"revision": 1315672648,
"release_candidate": 1
};

View File

@@ -1,6 +1,6 @@
module Jasmine
module Core
VERSION = "1.3.1"
VERSION = "1.2.0.rc1"
end
end

2
pages

Submodule pages updated: dae7b20e1c...a9d577eb45

View File

@@ -32,144 +32,118 @@ describe('Exceptions:', function() {
expect(jasmine.util.formatException(sampleWebkitException)).toEqual(expected);
});
describe('with break on exception', function() {
it('should not catch the exception', function() {
var suite = env.describe('suite for break on exceptions', function() {
env.it('should break when an exception is thrown', function() {
throw new Error('I should hit a breakpoint!');
it('should handle exceptions thrown, but continue', function() {
var fakeTimer = new jasmine.FakeTimer();
env.setTimeout = fakeTimer.setTimeout;
env.clearTimeout = fakeTimer.clearTimeout;
env.setInterval = fakeTimer.setInterval;
env.clearInterval = fakeTimer.clearInterval;
//we run two exception tests to make sure we continue after throwing an exception
var suite = env.describe('Suite for handles exceptions', function () {
env.it('should be a test that fails because it throws an exception', function() {
throw new Error('fake error 1');
});
env.it('should be another test that fails because it throws an exception', function() {
this.runs(function () {
throw new Error('fake error 2');
});
this.runs(function () {
this.expect(true).toEqual(true);
});
});
var runner = env.currentRunner();
var dont_change = 'I will never change!';
var oldCatch = jasmine.CATCH_EXCEPTIONS;
jasmine.CATCH_EXCEPTIONS = false;
try {
suite.execute();
dont_change = 'oops I changed';
}
catch (e) {}
finally {
jasmine.CATCH_EXCEPTIONS = oldCatch;
}
env.it('should be a passing test that runs after exceptions are thrown', function() {
this.expect(true).toEqual(true);
});
expect(dont_change).toEqual('I will never change!');
env.it('should be another test that fails because it throws an exception after a wait', function() {
this.runs(function () {
var foo = 'foo';
});
this.waits(250);
this.runs(function () {
throw new Error('fake error 3');
});
});
env.it('should be a passing test that runs after exceptions are thrown from a async test', function() {
this.expect(true).toEqual(true);
});
});
var runner = env.currentRunner();
suite.execute();
fakeTimer.tick(2500);
var suiteResults = suite.results();
var specResults = suiteResults.getItems();
expect(suiteResults.passed()).toEqual(false);
//
expect(specResults.length).toEqual(5);
expect(specResults[0].passed()).toMatch(false);
var blockResults = specResults[0].getItems();
expect(blockResults[0].passed()).toEqual(false);
expect(blockResults[0].message).toMatch(/fake error 1/);
expect(specResults[1].passed()).toEqual(false);
blockResults = specResults[1].getItems();
expect(blockResults[0].passed()).toEqual(false);
expect(blockResults[0].message).toMatch(/fake error 2/);
expect(blockResults[1].passed()).toEqual(true);
expect(specResults[2].passed()).toEqual(true);
expect(specResults[3].passed()).toEqual(false);
blockResults = specResults[3].getItems();
expect(blockResults[0].message).toMatch(/fake error 3/);
expect(specResults[4].passed()).toEqual(true);
});
describe("with catch on exception", function() {
it('should handle exceptions thrown, but continue', function() {
var fakeTimer = new jasmine.FakeTimer();
env.setTimeout = fakeTimer.setTimeout;
env.clearTimeout = fakeTimer.clearTimeout;
env.setInterval = fakeTimer.setInterval;
env.clearInterval = fakeTimer.clearInterval;
//we run two exception tests to make sure we continue after throwing an exception
var suite = env.describe('Suite for handles exceptions', function () {
env.it('should be a test that fails because it throws an exception', function() {
throw new Error('fake error 1');
});
env.it('should be another test that fails because it throws an exception', function() {
this.runs(function () {
throw new Error('fake error 2');
});
this.runs(function () {
this.expect(true).toEqual(true);
});
});
env.it('should be a passing test that runs after exceptions are thrown', function() {
this.expect(true).toEqual(true);
});
env.it('should be another test that fails because it throws an exception after a wait', function() {
this.runs(function () {
var foo = 'foo';
});
this.waits(250);
this.runs(function () {
throw new Error('fake error 3');
});
});
env.it('should be a passing test that runs after exceptions are thrown from a async test', function() {
this.expect(true).toEqual(true);
});
});
var runner = env.currentRunner();
suite.execute();
fakeTimer.tick(2500);
var suiteResults = suite.results();
var specResults = suiteResults.getItems();
expect(suiteResults.passed()).toEqual(false);
//
expect(specResults.length).toEqual(5);
expect(specResults[0].passed()).toMatch(false);
var blockResults = specResults[0].getItems();
expect(blockResults[0].passed()).toEqual(false);
expect(blockResults[0].message).toMatch(/fake error 1/);
expect(specResults[1].passed()).toEqual(false);
blockResults = specResults[1].getItems();
expect(blockResults[0].passed()).toEqual(false);
expect(blockResults[0].message).toMatch(/fake error 2/);
expect(blockResults[1].passed()).toEqual(true);
expect(specResults[2].passed()).toEqual(true);
expect(specResults[3].passed()).toEqual(false);
blockResults = specResults[3].getItems();
expect(blockResults[0].message).toMatch(/fake error 3/);
expect(specResults[4].passed()).toEqual(true);
});
it("should handle exceptions thrown directly in top-level describe blocks and continue", function () {
var suite = env.describe("a top level describe block that throws an exception", function () {
env.it("is a test that should pass", function () {
it("should handle exceptions thrown directly in top-level describe blocks and continue", function () {
var suite = env.describe("a top level describe block that throws an exception", function () {
env.it("is a test that should pass", function () {
this.expect(true).toEqual(true);
});
});
throw new Error("top level error");
});
throw new Error("top level error");
});
suite.execute();
var suiteResults = suite.results();
var specResults = suiteResults.getItems();
suite.execute();
var suiteResults = suite.results();
var specResults = suiteResults.getItems();
expect(suiteResults.passed()).toEqual(false);
expect(specResults.length).toEqual(2);
expect(suiteResults.passed()).toEqual(false);
expect(specResults.length).toEqual(2);
expect(specResults[1].description).toMatch(/encountered a declaration exception/);
});
expect(specResults[1].description).toMatch(/encountered a declaration exception/);
});
it("should handle exceptions thrown directly in nested describe blocks and continue", function () {
var suite = env.describe("a top level describe", function () {
env.describe("a mid-level describe that throws an exception", function () {
env.it("is a test that should pass", function () {
this.expect(true).toEqual(true);
});
it("should handle exceptions thrown directly in nested describe blocks and continue", function () {
var suite = env.describe("a top level describe", function () {
env.describe("a mid-level describe that throws an exception", function () {
env.it("is a test that should pass", function () {
this.expect(true).toEqual(true);
});
throw new Error("a mid-level error");
});
});
throw new Error("a mid-level error");
});
});
suite.execute();
var suiteResults = suite.results();
var specResults = suiteResults.getItems();
suite.execute();
var suiteResults = suite.results();
var specResults = suiteResults.getItems();
expect(suiteResults.passed()).toEqual(false);
expect(specResults.length).toEqual(1);
expect(suiteResults.passed()).toEqual(false);
expect(specResults.length).toEqual(1);
var nestedSpecResults = specResults[0].getItems();
var nestedSpecResults = specResults[0].getItems();
expect(nestedSpecResults.length).toEqual(2);
expect(nestedSpecResults[1].description).toMatch(/encountered a declaration exception/);
});
});
});
expect(nestedSpecResults.length).toEqual(2);
expect(nestedSpecResults[1].description).toMatch(/encountered a declaration exception/);
});
});

View File

@@ -75,18 +75,6 @@ describe("jasmine.Matchers", function() {
expect((match(parseInt('5', 10)).toEqual(5))).toPass();
expect((match(5).toNotEqual(5))).toFail();
expect((match(parseInt('5', 10)).toNotEqual(5))).toFail();
expect((match(/1/i).toEqual(/1/i))).toPass();
expect((match(/1/i).toNotEqual(/1/i))).toFail();
expect((match(/[abc]/gm).toEqual(/1/i))).toFail();
expect((match(/[abc]/gm).toNotEqual(/1/i))).toPass();
// only test if the browser supports the sticky option on a regExp see pull #234
if (RegExp.prototype.sticky !== undefined) {
var sticky_regexp = new RegExp("[abc]", "y");
expect((match(sticky_regexp).toEqual(/1/i))).toFail();
expect((match(sticky_regexp).toNotEqual(/1/i))).toPass();
}
});
it("toEqual to build an Expectation Result", function() {
@@ -293,29 +281,6 @@ describe("jasmine.Matchers", function() {
expect(result.actual).toEqual(actual);
});
it("toBeNaN", function() {
expect(match(Number.NaN).toBeNaN()).toPass();
expect(match(0).toBeNaN()).toFail();
expect(match(1).toBeNaN()).toFail();
expect(match(null).toBeNaN()).toFail();
expect(match(Number.POSITIVE_INFINITY).toBeNaN()).toFail();
expect(match(Number.NEGATIVE_INFINITY).toBeNaN()).toFail();
expect(match('NaN').toBeNaN()).toFail();
});
it("toBeNaN to build an ExpectationResult", function() {
var actual = 'a';
var matcher = match(actual);
matcher.toBeNaN();
var result = lastResult();
expect(result.matcherName).toEqual("toBeNaN");
expect(result.passed()).toFail();
expect(result.message).toMatch("Expected 'a' to be NaN.");
expect(result.actual).toMatch(actual);
});
it("toBeFalsy", function() {
expect(match(false).toBeFalsy()).toPass();
expect(match(true).toBeFalsy()).toFail();
@@ -387,33 +352,6 @@ describe("jasmine.Matchers", function() {
}]).toEqual(["a", jasmine.any(Function)])).toPass();
});
describe("toEqual with an object implementing jasmineMatches", function () {
var matcher;
beforeEach(function () {
matcher = {
jasmineMatches: jasmine.createSpy("jasmineMatches")
};
});
describe("on the left side", function () {
it("uses the jasmineMatches function", function () {
matcher.jasmineMatches.andReturn(false);
expect(match(matcher).toEqual("foo")).toFail();
matcher.jasmineMatches.andReturn(true);
expect(match(matcher).toEqual("foo")).toPass();
});
});
describe("on the right side", function () {
it("uses the jasmineMatches function", function () {
matcher.jasmineMatches.andReturn(false);
expect(match("foo").toEqual(matcher)).toFail();
matcher.jasmineMatches.andReturn(true);
expect(match("foo").toEqual(matcher)).toPass();
});
});
});
it("toEqual handles circular objects ok", function() {
expect(match({foo: "bar", baz: jasmine.undefined}).toEqual({foo: "bar", baz: jasmine.undefined})).toPass();
expect(match({foo:['bar','baz','quux']}).toEqual({foo:['bar','baz','quux']})).toPass();
@@ -545,11 +483,6 @@ describe("jasmine.Matchers", function() {
expect(-1.23).not.toBeCloseTo(-1.24);
});
it("expects close numbers to 'be close' and further numbers not to", function() {
expect(1.225).not.toBeCloseTo(1.234); // difference is 0.009
expect(1.225).toBeCloseTo(1.224); // difference is 0.001
});
it("accepts an optional precision argument", function() {
expect(1).toBeCloseTo(1.1, 0);
expect(1.2).toBeCloseTo(1.23, 1);
@@ -811,13 +744,7 @@ describe("jasmine.Matchers", function() {
TestClass.spyFunction('d', 'e', 'f');
var expected = match(TestClass.spyFunction);
expect(expected.toHaveBeenCalledWith('a', 'b')).toFail();
expect(lastResult().message).toEqual("Expected spy My spy to have been called with [ 'a', 'b' ] but actual calls were [ 'a', 'b', 'c' ], [ 'd', 'e', 'f' ]");
});
it("should return a decent message when it hasn't been called", function() {
var expected = match(TestClass.spyFunction);
expect(expected.toHaveBeenCalledWith('a', 'b')).toFail();
expect(lastResult().message).toEqual("Expected spy My spy to have been called with [ 'a', 'b' ] but it was never called.");
expect(lastResult().message).toEqual("Expected spy My spy to have been called with [ 'a', 'b' ] but was called with [ [ 'a', 'b', 'c' ], [ 'd', 'e', 'f' ] ]");
});
it("should return a decent message when inverted", function() {
@@ -825,7 +752,7 @@ describe("jasmine.Matchers", function() {
TestClass.spyFunction('d', 'e', 'f');
var expected = match(TestClass.spyFunction);
expect(expected.not.toHaveBeenCalledWith('a', 'b', 'c')).toFail();
expect(lastResult().message).toEqual("Expected spy My spy not to have been called with [ 'a', 'b', 'c' ] but it was.");
expect(lastResult().message).toEqual("Expected spy My spy not to have been called with [ 'a', 'b', 'c' ] but was called with [ [ 'a', 'b', 'c' ], [ 'd', 'e', 'f' ] ]");
});
it('should throw an exception when invoked on a non-spy', shouldThrowAnExceptionWhenInvokedOnANonSpy('toHaveBeenCalledWith'));
@@ -903,252 +830,6 @@ describe("jasmine.Matchers", function() {
});
});
describe("ObjectContaining", function () {
describe("with an empty object", function () {
var containing;
beforeEach(function () {
containing = new jasmine.Matchers.ObjectContaining({});
});
it("matches everything", function () {
expect(containing.jasmineMatches("foo", [], [])).toBe(true);
});
it("says it didn't expect to contain anything", function () {
expect(containing.jasmineToString()).toEqual("<jasmine.objectContaining({ })>");
});
});
describe("with an object with items in it", function () {
var containing, mismatchKeys, mismatchValues;
beforeEach(function () {
mismatchKeys = [];
mismatchValues = [];
containing = new jasmine.Matchers.ObjectContaining({foo: "fooVal", bar: "barVal"});
});
it("doesn't match an empty object", function () {
expect(containing.jasmineMatches({}, mismatchKeys, mismatchValues)).toBe(false);
});
it("doesn't match an object with none of the specified options", function () {
expect(containing.jasmineMatches({baz:"stuff"}, mismatchKeys, mismatchValues)).toBe(false);
});
it("adds a message for each missing key", function () {
containing.jasmineMatches({foo: "fooVal"}, mismatchKeys, mismatchValues);
expect(mismatchKeys.length).toEqual(1);
});
it("doesn't match an object when the values are different", function () {
expect(containing.jasmineMatches({foo:"notFoo", bar:"notBar"}, mismatchKeys, mismatchValues)).toBe(false);
});
it("adds a message when values don't match", function () {
containing.jasmineMatches({foo: "fooVal", bar: "notBar"}, mismatchKeys, mismatchValues);
expect(mismatchValues.length).toEqual(1);
});
it("doesn't match an object with only one of the values matching", function () {
expect(containing.jasmineMatches({foo:"notFoo", bar:"barVal"}, mismatchKeys, mismatchValues)).toBe(false);
});
it("matches when all the values are the same", function () {
expect(containing.jasmineMatches({foo: "fooVal", bar: "barVal"}, mismatchKeys, mismatchValues)).toBe(true);
});
it("matches when there are additional values", function () {
expect(containing.jasmineMatches({foo: "fooVal", bar: "barVal", baz: "bazVal"}, mismatchKeys, mismatchValues)).toBe(true);
});
it("doesn't modify missingKeys or missingValues when match is successful", function () {
containing.jasmineMatches({foo: "fooVal", bar: "barVal"}, mismatchKeys, mismatchValues);
expect(mismatchKeys.length).toEqual(0);
expect(mismatchValues.length).toEqual(0);
});
it("says what it expects to contain", function () {
expect(containing.jasmineToString()).toEqual("<jasmine.objectContaining(" + jasmine.pp({foo:"fooVal", bar:"barVal"}) + ")>");
});
});
describe("in real life", function () {
var method;
beforeEach(function () {
method = jasmine.createSpy("method");
method({a:"b", c:"d"});
});
it("works correctly for positive matches", function () {
expect(method).toHaveBeenCalledWith(jasmine.objectContaining({a:"b"}));
});
it("works correctly for negative matches", function () {
expect(method).not.toHaveBeenCalledWith(jasmine.objectContaining({z:"x"}));
});
});
});
describe("Matchers.Any", function () {
var any;
describe(".jasmineToString", function () {
describe("with Object", function () {
it("says it's looking for an object", function () {
any = jasmine.any(Object);
expect(any.jasmineToString().replace(/\n/g, "")).toMatch(/<jasmine\.any\(function Object.*\)>/);
});
});
describe("with Function", function () {
it("says it's looking for a function", function () {
any = jasmine.any(Function);
expect(any.jasmineToString().replace(/\n/g, "")).toMatch(/<jasmine\.any\(function Function.*\)>/);
});
});
describe("with String", function () {
it("says it's looking for a string", function () {
any = jasmine.any(String);
expect(any.jasmineToString().replace(/\n/g, "")).toMatch(/<jasmine\.any\(function String.*\)>/);
});
});
describe("with Number", function () {
it("says it's looking for a number", function () {
any = jasmine.any(Number);
expect(any.jasmineToString().replace(/\n/g, "")).toMatch(/<jasmine\.any\(function Number.*\)>/);
});
});
describe("with some other defined 'class'", function () {
it("says it's looking for an object", function () {
function MyClass () {}
any = jasmine.any(MyClass);
expect(any.jasmineToString().replace("\n", "")).toMatch(/<jasmine\.any\(function MyClass.*\)>/);
});
});
});
describe(".jasmineMatches", function () {
describe("with Object", function () {
beforeEach(function () {
any = jasmine.any(Object);
});
it("matches an empty object", function () {
expect(any.jasmineMatches({})).toEqual(true);
});
it("matches a newed up object", function () {
expect(any.jasmineMatches(new Object())).toEqual(true);
});
it("doesn't match a string", function () {
expect(any.jasmineMatches("")).toEqual(false);
});
it("doesn't match a number", function () {
expect(any.jasmineMatches(123)).toEqual(false);
});
it("doesn't match a function", function () {
expect(any.jasmineMatches(function () {})).toEqual(false);
});
});
describe("with Function", function () {
beforeEach(function () {
any = jasmine.any(Function);
});
it("doesn't match an object", function () {
expect(any.jasmineMatches({})).toEqual(false);
});
it("doesn't match a string", function () {
expect(any.jasmineMatches("")).toEqual(false);
});
it("doesn't match a number", function () {
expect(any.jasmineMatches(123)).toEqual(false);
});
it("matches a function", function () {
expect(any.jasmineMatches(function () {})).toEqual(true);
});
});
describe("with Number", function () {
beforeEach(function () {
any = jasmine.any(Number);
});
it("doesn't match an object", function () {
expect(any.jasmineMatches({})).toEqual(false);
});
it("doesn't match a string", function () {
expect(any.jasmineMatches("")).toEqual(false);
});
it("matches a number", function () {
expect(any.jasmineMatches(123)).toEqual(true);
});
it("doesn't match a function", function () {
expect(any.jasmineMatches(function () {})).toEqual(false);
});
});
describe("with String", function () {
beforeEach(function () {
any = jasmine.any(String);
});
it("doesn't match an object", function () {
expect(any.jasmineMatches({})).toEqual(false);
});
it("matches a string", function () {
expect(any.jasmineMatches("")).toEqual(true);
});
it("doesn't match a number", function () {
expect(any.jasmineMatches(123)).toEqual(false);
});
it("doesn't match a function", function () {
expect(any.jasmineMatches(function () {})).toEqual(false);
});
});
describe("with some defined 'class'", function () {
function MyClass () {}
beforeEach(function () {
any = jasmine.any(MyClass);
});
it("doesn't match an object", function () {
expect(any.jasmineMatches({})).toEqual(false);
});
it("doesn't match a string", function () {
expect(any.jasmineMatches("")).toEqual(false);
});
it("doesn't match a number", function () {
expect(any.jasmineMatches(123)).toEqual(false);
});
it("doesn't match a function", function () {
expect(any.jasmineMatches(function () {})).toEqual(false);
});
it("matches an instance of the defined class", function () {
expect(any.jasmineMatches(new MyClass())).toEqual(true);
});
});
});
});
describe("all matchers", function() {
it("should return null, for future-proofing, since we might eventually allow matcher chaining", function() {
expect(match(true).toBe(true)).toBeUndefined();

View File

@@ -32,36 +32,6 @@ describe("jasmine.pp", function () {
}, bar: [1, 2, 3]})).toEqual("{ foo : Function, bar : [ 1, 2, 3 ] }");
});
it("should not include inherited properties when stringifying an object", function() {
var SomeClass = function() {};
SomeClass.prototype.foo = "inherited foo";
var instance = new SomeClass();
instance.bar = "my own bar";
expect(jasmine.pp(instance)).toEqual("{ bar : 'my own bar' }");
});
it("should not recurse objects and arrays more deeply than jasmine.MAX_PRETTY_PRINT_DEPTH", function() {
var originalMaxDepth = jasmine.MAX_PRETTY_PRINT_DEPTH;
var nestedObject = { level1: { level2: { level3: { level4: "leaf" } } } };
var nestedArray = [1, [2, [3, [4, "leaf"]]]];
try {
jasmine.MAX_PRETTY_PRINT_DEPTH = 2;
expect(jasmine.pp(nestedObject)).toEqual("{ level1 : { level2 : Object } }");
expect(jasmine.pp(nestedArray)).toEqual("[ 1, [ 2, Array ] ]");
jasmine.MAX_PRETTY_PRINT_DEPTH = 3;
expect(jasmine.pp(nestedObject)).toEqual("{ level1 : { level2 : { level3 : Object } } }");
expect(jasmine.pp(nestedArray)).toEqual("[ 1, [ 2, [ 3, Array ] ] ]");
jasmine.MAX_PRETTY_PRINT_DEPTH = 4;
expect(jasmine.pp(nestedObject)).toEqual("{ level1 : { level2 : { level3 : { level4 : 'leaf' } } } }");
expect(jasmine.pp(nestedArray)).toEqual("[ 1, [ 2, [ 3, [ 4, 'leaf' ] ] ] ]");
} finally {
jasmine.MAX_PRETTY_PRINT_DEPTH = originalMaxDepth;
}
});
it("should stringify RegExp objects properly", function() {
expect(jasmine.pp(/x|y|z/)).toEqual("/x|y|z/");
});
@@ -113,12 +83,5 @@ describe("jasmine.pp", function () {
expect(jasmine.pp(jasmine.createSpy("something"))).toEqual("spy on something");
});
it("should stringify objects that implement jasmineToString", function () {
var obj = {
jasmineToString: function () { return "strung"; }
};
expect(jasmine.pp(obj)).toEqual("strung");
});
});

View File

@@ -105,19 +105,6 @@ describe('RunnerTest', function() {
expect(runnerResults.totalCount).toEqual(3);
expect(runnerResults.passedCount).toEqual(3);
});
it('should run after a failing spec', function () {
var afterEach = jasmine.createSpy();
env.afterEach(afterEach);
env.describe('suite', function () {
env.it('fails', function () {
this.explodes();
});
}).execute();
expect(afterEach).toHaveBeenCalled();
});
});

View File

@@ -398,123 +398,6 @@ describe("jasmine spec running", function () {
expect(timeoutSpec.results().getItems()[0].message).toEqual('timeout: timed out after 500 msec waiting for something to happen');
expect(subsequentSpecRan).toEqual(true);
});
it("runs afterEach after timing out", function() {
var afterEach = jasmine.createSpy('afterEach');
env.describe('foo', function () {
env.afterEach(afterEach);
env.it('waitsFor', function () {
this.waitsFor(100, function() {
return false;
});
});
}).execute();
fakeTimer.tick(500);
expect(afterEach).toHaveBeenCalled();
});
it("runs single-spec after functions after timing out", function() {
var after = jasmine.createSpy('after');
env.describe('foo', function () {
env.it('waitsFor', function () {
this.after(after);
this.waitsFor(100, function() {
return false;
});
});
}).execute();
fakeTimer.tick(500);
expect(after).toHaveBeenCalled();
});
describe('with consecutive calls', function () {
var foo;
beforeEach(function () {
foo = 0;
});
it('exits immediately (does not stack) if the latchFunction times out', function () {
var reachedFirstWaitsFor = false;
var reachedSecondWaitsFor = false;
env.describe('suite that waits', function () {
env.it('should stack timeouts', function() {
this.waitsFor(500, function () {
reachedFirstWaitsFor = true;
return false;
});
this.waitsFor(500, function () {
reachedSecondWaitsFor = true;
});
this.runs(function () {
foo++;
});
});
});
expect(reachedFirstWaitsFor).toEqual(false);
env.execute();
expect(reachedFirstWaitsFor).toEqual(true);
expect(foo).toEqual(0);
expect(reachedSecondWaitsFor).toEqual(false);
fakeTimer.tick(500);
expect(reachedSecondWaitsFor).toEqual(false);
expect(foo).toEqual(0);
fakeTimer.tick(500);
expect(reachedSecondWaitsFor).toEqual(false);
expect(foo).toEqual(0);
});
it('stacks latchFunctions', function () {
var firstWaitsResult = false;
var secondWaitsResult = false;
var waitsSuite = env.describe('suite that waits', function () {
env.it('spec with waitsFors', function() {
this.waitsFor(600, function () {
fakeTimer.setTimeout(function () {
firstWaitsResult = true;
}, 300);
return firstWaitsResult;
});
this.waitsFor(600, function () {
fakeTimer.setTimeout(function () {
secondWaitsResult = true;
}, 300);
return secondWaitsResult;
});
this.runs(function () {
foo++;
});
});
});
expect(firstWaitsResult).toEqual(false);
expect(secondWaitsResult).toEqual(false);
waitsSuite.execute();
expect(firstWaitsResult).toEqual(false);
expect(secondWaitsResult).toEqual(false);
expect(foo).toEqual(0);
fakeTimer.tick(300);
expect(firstWaitsResult).toEqual(true);
expect(secondWaitsResult).toEqual(false);
expect(foo).toEqual(0);
fakeTimer.tick(300);
expect(firstWaitsResult).toEqual(true);
expect(secondWaitsResult).toEqual(true);
expect(foo).toEqual(1);
});
});
});
it("testSpecAfter", function() {
@@ -696,6 +579,90 @@ describe("jasmine spec running", function () {
expect(quux).toEqual(1);
});
describe('#waitsFor should allow consecutive calls', function () {
var foo;
beforeEach(function () {
foo = 0;
});
it('exits immediately (does not stack) if the latchFunction times out', function () {
var reachedFirstWaitsFor = false;
var reachedSecondWaitsFor = false;
env.describe('suite that waits', function () {
env.it('should stack timeouts', function() {
this.waitsFor(500, function () {
reachedFirstWaitsFor = true;
return false;
});
this.waitsFor(500, function () {
reachedSecondWaitsFor = true;
});
this.runs(function () {
foo++;
});
});
});
expect(reachedFirstWaitsFor).toEqual(false);
env.execute();
expect(reachedFirstWaitsFor).toEqual(true);
expect(foo).toEqual(0);
expect(reachedSecondWaitsFor).toEqual(false);
fakeTimer.tick(500);
expect(reachedSecondWaitsFor).toEqual(false);
expect(foo).toEqual(0);
fakeTimer.tick(500);
expect(reachedSecondWaitsFor).toEqual(false);
expect(foo).toEqual(0);
});
it('stacks latchFunctions', function () {
var firstWaitsResult = false;
var secondWaitsResult = false;
var waitsSuite = env.describe('suite that waits', function () {
env.it('spec with waitsFors', function() {
this.waitsFor(600, function () {
fakeTimer.setTimeout(function () {
firstWaitsResult = true;
}, 300);
return firstWaitsResult;
});
this.waitsFor(600, function () {
fakeTimer.setTimeout(function () {
secondWaitsResult = true;
}, 300);
return secondWaitsResult;
});
this.runs(function () {
foo++;
});
});
});
expect(firstWaitsResult).toEqual(false);
expect(secondWaitsResult).toEqual(false);
waitsSuite.execute();
expect(firstWaitsResult).toEqual(false);
expect(secondWaitsResult).toEqual(false);
expect(foo).toEqual(0);
fakeTimer.tick(300);
expect(firstWaitsResult).toEqual(true);
expect(secondWaitsResult).toEqual(false);
expect(foo).toEqual(0);
fakeTimer.tick(300);
expect(firstWaitsResult).toEqual(true);
expect(secondWaitsResult).toEqual(true);
expect(foo).toEqual(1);
});
});
it("#beforeEach should be able to eval runs and waits blocks", function () {
var foo = 0;
var bar = 0;

View File

@@ -165,21 +165,6 @@ describe('Spies', function () {
expect(exception).toBeDefined();
});
it('to spy on an undefined method throws exception', function() {
var TestClass = {
someFunction : function() {
}
};
function efunc() {
this.spyOn(TestClass, 'someOtherFunction');
};
expect(function() {
efunc();
}).toThrow('someOtherFunction() method does not exist');
});
it('should be able to reset a spy', function() {
var TestClass = { someFunction: function() {} };
this.spyOn(TestClass, 'someFunction');

View File

@@ -44,23 +44,8 @@ describe("HtmlReporter", function() {
expect(htmlReporter.specFilter(fakeSpec("not run this"))).toBeFalsy();
});
describe("running without any specs", function() {
var runner;
beforeEach(function() {
runner = env.currentRunner();
env.addReporter(htmlReporter);
});
it("should not error", function() {
var exec = function() {
runner.execute();
};
expect(exec).not.toThrow();
});
});
describe('Matcher reporting', function() {
var getResultMessageDiv = function(body) {
describe('Matcher reporting', function () {
var getResultMessageDiv = function (body) {
var divs = body.getElementsByTagName("div");
for (var i = 0; i < divs.length; i++) {
if (divs[i].className.match(/resultMessage/)) {
@@ -70,7 +55,7 @@ describe("HtmlReporter", function() {
};
var runner, spec, fakeTimer;
beforeEach(function() {
beforeEach(function () {
fakeTimer = new jasmine.FakeTimer();
env.setTimeout = fakeTimer.setTimeout;
env.clearTimeout = fakeTimer.clearTimeout;
@@ -85,9 +70,9 @@ describe("HtmlReporter", function() {
env.addReporter(htmlReporter);
});
describe('toContain', function() {
it('should show actual and expected', function() {
spec.runs(function() {
describe('toContain', function () {
it('should show actual and expected', function () {
spec.runs(function () {
this.expect('foo').toContain('bar');
});
runner.execute();
@@ -100,7 +85,7 @@ describe("HtmlReporter", function() {
});
});
describe("failure messages (integration)", function() {
describe("failure messages (integration)", function () {
var spec, results, expectationResult;
it("should add the failure message to the DOM (non-toEquals matchers)", function() {
@@ -183,7 +168,7 @@ describe("HtmlReporter", function() {
});
describe('#reportSpecStarting', function() {
beforeEach(function() {
beforeEach(function () {
env.describe("suite 1", function() {
env.it("spec 1", function() {
});

View File

@@ -1,39 +0,0 @@
jasmine_dir:
- 'src'
#This 'magic' inclusion order allows the travis build to pass.
#TODO: search for the correct files to include to prevent
jasmine_files:
- 'core/base.js'
- 'core/util.js'
- 'core/Reporter.js'
#end of known dependencies
- 'core/Env.js'
- 'core/Block.js'
- 'core/JsApiReporter.js'
- 'core/Matchers.js'
- 'core/mock-timeout.js'
- 'core/MultiReporter.js'
- 'core/NestedResults.js'
- 'core/PrettyPrinter.js'
- 'core/Queue.js'
- 'core/Runner.js'
- 'core/Spec.js'
- 'core/Suite.js'
- 'core/WaitsBlock.js'
- 'core/WaitsForBlock.js'
- 'html/HtmlReporterHelpers.js'
- 'html/HtmlReporter.js'
- '**/*.js'
jasmine_css_files:
- 'html/jasmine.css'
src_files:
stylesheets:
helpers:
- 'helpers/**/*.js'
spec_files:
- '**/*[Ss]pec.js'
src_dir:
spec_dir:
- 'spec'

View File

@@ -1,23 +0,0 @@
require 'jasmine'
Jasmine.load_configuration_from_yaml(File.join(Dir.pwd, 'spec', 'jasmine.yml'))
config = Jasmine.config
server = Jasmine::Server.new(config.port, Jasmine::Application.app(config))
driver = Jasmine::SeleniumDriver.new(config.browser, "#{config.host}:#{config.port}/")
t = Thread.new do
begin
server.start
rescue ChildProcess::TimeoutError
end
# # ignore bad exits
end
t.abort_on_exception = true
Jasmine::wait_for_listener(config.port, "jasmine server")
puts "jasmine server started."
results_processor = Jasmine::ResultsProcessor.new(config)
results = Jasmine::Runners::HTTP.new(driver, results_processor, config.result_batch_size).run
formatter = Jasmine::RspecFormatter.new
formatter.format_results(results)

View File

@@ -1,5 +1,5 @@
var fs = require('fs');
var util = require('util');
var sys = require('sys');
var path = require('path');
// yes, really keep this here to keep us honest, but only for jasmine's own runner! [xw]
@@ -37,7 +37,7 @@ jasmine.executeSpecs = function(specs, done, isVerbose, showColors) {
}
var jasmineEnv = jasmine.getEnv();
var consoleReporter = new jasmine.ConsoleReporter(util.print, done, showColors);
var consoleReporter = new jasmine.ConsoleReporter(sys.print, done, showColors);
jasmineEnv.addReporter(consoleReporter);
jasmineEnv.execute();

View File

@@ -1,51 +0,0 @@
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper.rb"` to ensure that it is only
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered = true
config.filter_run :focus
end
require 'awesome_print'
require 'tmpdir'
require 'nokogiri'
def project_root
File.join(File.expand_path(File.dirname(__FILE__)), '..')
end
require "#{project_root}/tasks/jasmine_dev"
def capture_output(capture = true)
if capture
output = StringIO.new
$stdout = output
end
yield
if capture
output.string
end
ensure
$stdout = STDOUT
end
def reset_dir(dir)
FileUtils.rm_r dir if File.exists?(dir)
FileUtils.mkdir_p dir
end
def jasmine_version
version = jasmine_version_object
version_string = "#{version['major']}.#{version['minor']}.#{version['build']}"
version_string += ".rc#{version['release_candidate']}" if version['release_candidate']
version_string
end
def jasmine_version_object
@version_object ||= JSON.parse(File.read(File.join(JasmineDev.project_root, 'src', 'version.json')))
end

View File

@@ -1,33 +0,0 @@
require 'spec_helper.rb'
describe "Build Jasmine task" do
let(:jasmine_core_dir) { "#{Dir.tmpdir}/jasmine-core" }
let(:jasmine_dev) { JasmineDev.new }
before do
reset_dir jasmine_core_dir
@output = capture_output { jasmine_dev.build_distribution jasmine_core_dir }
end
it "should say that JSHint is running" do
@output.should match(/Running JSHint/)
@output.should match(/Jasmine JSHint PASSED/)
end
it "should tell the developer it is building the distribution" do
@output.should match(/Building Jasmine distribution/)
end
it "should build jasmine.js in the destination directory" do
File.exist?("#{jasmine_core_dir}/jasmine.js").should be_true
end
it "should build jasmine-html.js in the destination directory" do
File.exist?("#{jasmine_core_dir}/jasmine-html.js").should be_true
end
it "should build jasmine.css" do
File.exist?("#{jasmine_core_dir}/jasmine.css").should be_true
end
end

View File

@@ -1,60 +0,0 @@
require 'spec_helper.rb'
describe "Build Github Pages task" do
let(:pages_dir) { File.join(Dir.tmpdir, 'pages') }
let(:jasmine_dev) { JasmineDev.new }
before do
reset_dir pages_dir
end
describe "when the Github pages submodule is not present" do
before do
jasmine_dev.should_receive(:has_pages_submodule?).and_return(false)
@output = capture_output { jasmine_dev.build_github_pages pages_dir }
end
it "should tell the user the task is running" do
@output.should match(/Building Github Pages/)
end
it "should prompt the user to install the submodule" do
@output.should match(/Submodule for Github Pages isn't present/)
end
end
describe "when the Github pages submodule is present" do
before do
jasmine_dev.should_receive(:has_pages_submodule?).and_return(true)
@output = capture_output { jasmine_dev.build_github_pages pages_dir }
end
it "should tell the user the task is running" do
@output.should match(/Building Github Pages/)
end
it "should copy the latest jasmine files to the pages dir" do
['jasmine.js', 'jasmine.css', 'jasmine-html.js'].each do |lib_file|
source = File.read(File.join(project_root, 'lib', 'jasmine-core', lib_file))
dest = File.read(File.join(pages_dir, 'lib', lib_file))
source.should == dest
end
end
it "should build a new page" do
@output.should match(/rocco/)
File.exist?(File.join(pages_dir, 'introduction.html')).should be_true
end
it "should copy the rocco output to index.html" do
introduction = File.read(File.join(pages_dir, 'introduction.html'))
index = File.read(File.join(pages_dir, 'index.html'))
index.should == introduction
end
end
end

View File

@@ -1,109 +0,0 @@
require 'spec_helper.rb'
describe "Standalone Distribution tasks" do
let(:jasmine_dev) { JasmineDev.new }
let(:standalone_temp_dir) { File.join(Dir.tmpdir, 'jasmine_test') }
let(:download_dir) { File.join(standalone_temp_dir, 'download')}
describe "build_standalone_distribution" do
before do
reset_dir standalone_temp_dir
reset_dir download_dir
Dir.should_receive(:tmpdir).any_number_of_times.and_return(standalone_temp_dir)
@standalone_staging_dir = File.join(standalone_temp_dir, 'jasmine_standalone')
@version_dir = File.join(@standalone_staging_dir, "jasmine-standalone-#{jasmine_version}")
@lib_dir = File.join(@version_dir, 'lib')
@source_dir = File.join(@version_dir, 'src')
@spec_dir = File.join(@version_dir, 'spec')
@output = capture_output { jasmine_dev.build_standalone_distribution download_dir }
end
it "should build the distribution" do
@output.should match(/Building Jasmine distribution/)
end
it "should tell the developer the task has started" do
@output.should match(/Building standalone distribution/)
end
it "should copy the lib directory to the staging directory, under a versioned directory" do
lib_dir_files = Dir.glob(File.join(standalone_temp_dir, 'jasmine_standalone', '**', '*'))
staged_lib_files = %w{ jasmine.js jasmine-html.js jasmine.css MIT.LICENSE }
staged_lib_files.each do |filename|
lib_dir_files.should include(File.join(@lib_dir, "jasmine-#{jasmine_version}", filename))
end
end
it "should copy the sample project source to the staging directory" do
File.exist?(File.join(@source_dir, 'Player.js')).should be_true
File.exist?(File.join(@source_dir, 'Song.js')).should be_true
end
it "should copy the sample project specs to the staging directory" do
File.exist?(File.join(@spec_dir, 'PlayerSpec.js')).should be_true
File.exist?(File.join(@spec_dir, 'SpecHelper.js')).should be_true
end
it "should copy a build SpecRunner.html to the staging directory" do
File.exist?(File.join(@version_dir, 'SpecRunner.html')).should be_true
end
it "should zip up the contents of the staging directory" do
File.exist?(File.join(@standalone_staging_dir, "jasmine-standalone-#{jasmine_version}.zip")).should be_true
end
it "should copy the zip file to the pages sub directory" do
File.exist?(File.join(download_dir, "jasmine-standalone-#{jasmine_version}.zip")).should be_true
end
describe "when the zip file is unzipped" do
before do
@out_directory = File.join(standalone_temp_dir, 'unzip')
reset_dir @out_directory
FileUtils.cp File.join(@standalone_staging_dir, "jasmine-standalone-#{jasmine_version}.zip"),
@out_directory
Dir.chdir @out_directory do
system("unzip -qq jasmine-standalone-#{jasmine_version}.zip")
end
end
describe "the distirbution" do
before do
Dir.chdir @out_directory do
@files = Dir.glob(File.join('**', '*'))
end
end
it "should include the correct root files" do
@files.should include('SpecRunner.html')
end
it "should include the correct lib files" do
%w{ jasmine.js jasmine-html.js jasmine.css MIT.LICENSE }.each do |file|
@files.should include(File.join('lib', "jasmine-#{jasmine_version}", file))
end
end
it "should include the correct src files" do
%w{Player.js Song.js}.each do |file|
@files.should include(File.join('src', file))
end
end
it "should include the correct spec files" do
%w{PlayerSpec.js SpecHelper.js}.each do |file|
@files.should include(File.join('spec', file))
end
end
end
end
end
end

View File

@@ -1,63 +0,0 @@
require 'spec_helper.rb'
describe "Build Standalone runner HTML task" do
let(:jasmine_dev) { JasmineDev.new }
let(:standalone_temp_dir) { "#{Dir.tmpdir}/jasmine_test" }
describe "build_standalone_runner" do
before do
reset_dir standalone_temp_dir
Dir.should_receive(:tmpdir).any_number_of_times.and_return(standalone_temp_dir)
@standalone_staging_dir = File.join(standalone_temp_dir, 'jasmine_standalone')
@version_dir = File.join(@standalone_staging_dir, "jasmine-standalone-#{jasmine_version}")
@output = capture_output { jasmine_dev.build_standalone_runner }
end
it "should tell the developer the task has started" do
@output.should match(/Building standalone runner HTML/)
end
it "should copy a build SpecRunner.html to the staging directory" do
File.exist?(File.join(@version_dir, 'SpecRunner.html')).should be_true
end
describe "should build the file that has HTML that" do
before do
html = File.read(File.join(@version_dir, 'SpecRunner.html'))
@runner = Nokogiri(html)
end
it "should have the favicon tag" do
favicon_tag = @runner.css('link')[0]
favicon_tag['href'].should match("lib/jasmine-#{jasmine_version}/jasmine_favicon.png")
end
it "should have the stylesheet" do
css_tag = @runner.css('link')[1]
css_tag['href'].should match("lib/jasmine-#{jasmine_version}/jasmine.css")
end
it "should have the jasmine script tags" do
script_sources = @runner.css('script').collect {|tag| tag['src']}
script_sources.should include("lib/jasmine-#{jasmine_version}/jasmine.js")
script_sources.should include("lib/jasmine-#{jasmine_version}/jasmine-html.js")
end
it "should have the example source files" do
script_sources = @runner.css('script').collect {|tag| tag['src']}
script_sources.should include('src/Player.js')
script_sources.should include('src/Song.js')
end
it "should have the example source files" do
script_sources = @runner.css('script').collect {|tag| tag['src']}
script_sources.should include('spec/SpecHelper.js')
script_sources.should include('spec/PlayerSpec.js')
end
end
end
end

View File

@@ -1,26 +0,0 @@
require 'spec_helper.rb'
describe "Spec counting task" do
let(:jasmine_dev) { JasmineDev.new }
before do
@output = capture_output { jasmine_dev.count_specs }
end
it "should tell the developer that the specs are being counted" do
@output.should match(/Counting specs/)
end
it "should report the number of specs that will run in node" do
@output.should match(/\d+ \e\[0mspecs for Node.js/)
end
it "should report the number of specs that will run in the browser" do
@output.should match(/\d+ \e\[0mspecs for Browser/)
end
it "should remind the developer to check the count" do
@output.should match(/Please verify/)
end
end

View File

@@ -1,81 +0,0 @@
require 'spec_helper.rb'
describe "Spec tasks" do
let(:jasmine_dev) { JasmineDev.new }
describe "execute_specs_in_node" do
describe "when Node.js is not present" do
before do
jasmine_dev.should_receive(:has_node?).and_return(false)
@output = capture_output { jasmine_dev.execute_specs_in_node }
end
it "should prompt the user to install Node" do
@output.should match(/Node\.js is required/)
end
end
describe "when Node.js is present" do
before do
jasmine_dev.should_receive(:has_node?).and_return(true)
@output = capture_output { jasmine_dev.execute_specs_in_node }
end
it "should build the distribution" do
@output.should match(/Building Jasmine distribution/)
end
it "should tell the developer that the specs are being counted" do
@output.should match(/Counting specs/)
end
it "should tell the user that the specs are running in Node.js" do
@output.should match(/specs via Node/)
@output.should match(/Started/)
@output.should match(/\d+ specs, 0 failures/)
end
end
end
describe "execute_specs_in_browser" do
before do
jasmine_dev.should_receive(:run)
@output = capture_output { jasmine_dev.execute_specs_in_browser }
end
it "should build the distribution" do
@output.should match(/Building Jasmine distribution/)
end
it "should tell the developer that the specs are being counted" do
@output.should match(/Counting specs/)
end
it "should tell the user that the specs are running in the broswer" do
@output.should match(/specs via the default web browser/)
end
end
describe "execute_specs" do
before do
@output = capture_output { jasmine_dev.execute_specs }
end
it "should build the distribution" do
@output.should match(/Building Jasmine distribution/)
end
it "should tell the developer that the specs are being counted" do
@output.should match(/Counting specs/)
end
it "should tell the user that the specs are running in Node.js" do
@output.should match(/specs via Node/)
end
it "should tell the user that the specs are running in the broswer" do
@output.should match(/specs via the default web browser/)
end
end
end

View File

@@ -1,39 +0,0 @@
require 'spec_helper.rb'
describe "JSHint task" do
let(:tmp_dir) { "#{Dir.tmpdir}/jasmine_tasks_test" }
let(:jasmine_dev) { JasmineDev.new }
before do
reset_dir tmp_dir
end
describe "when Node is not present" do
before do
jasmine_dev.should_receive(:has_node?).and_return(false)
@output = capture_output { jasmine_dev.js_hint }
end
it "should not tell the user that lint is running" do
@output.should_not match(/Running JSHint/)
end
it "should prompt the user to install Node" do
@output.should match(/Node\.js is required/)
end
end
describe "when Node is present" do
before do
jasmine_dev.should_receive(:has_node?).and_return(true)
@output = capture_output { jasmine_dev.js_hint }
end
it "should tell the user that lint is running" do
@output.should match(/Running JSHint/)
@output.should match(/Jasmine JSHint PASSED/)
end
end
end

View File

@@ -1,39 +0,0 @@
require 'spec_helper.rb'
describe "Release task" do
let(:jasmine_dev) { JasmineDev.new }
describe "when the pages submodule is not present" do
before do
jasmine_dev.should_receive(:has_pages_submodule?).and_return(false)
@output = capture_output { jasmine_dev.release_prep }
end
it "should tell the user the task is running" do
@output.should match(/Building Release/)
end
it "should prompt the user to install the submodule" do
@output.should match(/Submodule for Github Pages isn't present/)
end
end
describe "when the pages submodule is present" do
before do
JasmineDev.any_instance.should_receive(:write_version_files)
JasmineDev.any_instance.should_receive(:build_distribution)
JasmineDev.any_instance.should_receive(:build_standalone_distribution)
JasmineDev.any_instance.should_receive(:build_github_pages)
jasmine_dev.should_receive(:has_pages_submodule?).and_return(true)
@output = capture_output { jasmine_dev.release_prep }
end
it "should tell the user the task is running" do
@output.should match(/Building Release/)
end
end
end

View File

@@ -1,55 +0,0 @@
require 'spec_helper.rb'
describe "Version tasks" do
let(:jasmine_dev) { JasmineDev.new }
describe "write_version_files" do
before do
@output = capture_output { jasmine_dev.write_version_files }
end
it "should tell the user that the task has started" do
@output.should match(/Building version files/)
end
it "should build the version.js file" do
js_version = File.read(File.join(project_root, 'src', 'version.js'))
js_version.should match(%Q{"build": #{jasmine_version_object["build"]}})
js_version.should match(%Q{"minor": #{jasmine_version_object["minor"]}})
js_version.should match(%Q{"build": #{jasmine_version_object["build"]}})
if jasmine_version_object["release_candidate"]
js_version.should match(%Q{"release_candidate": #{jasmine_version_object["release_candidate"]}})
end
js_version.should match(/"revision": \d+/)
end
it "should build the jasmine-core ruby gem version" do
ruby_version = File.read(File.join(project_root, 'lib', 'jasmine-core', 'version.rb'))
ruby_version.should match(%Q{VERSION = "#{jasmine_version}"})
end
end
describe "display_version" do
describe "when Node.js is not present" do
before do
@output = capture_output { jasmine_dev.display_version }
end
it "should display a version header" do
@output.should match(/Current version/)
end
it "should display the current version Object" do
@output.should match(/Display version: \e\[33m\d+\.\d+\.\d+/)
end
it "should display the current version string" do
@output.should match(/\{ "major": \d+, "minor": \d+, "build": \d+/)
end
end
end
end

7
src/SourcesList.json Normal file
View File

@@ -0,0 +1,7 @@
[
"base.js",
"util.js",
"Env.js",
"Reporter.js",
"Block.js"
]

View File

@@ -12,16 +12,11 @@ jasmine.Block = function(env, func, spec) {
this.spec = spec;
};
jasmine.Block.prototype.execute = function(onComplete) {
if (!jasmine.CATCH_EXCEPTIONS) {
jasmine.Block.prototype.execute = function(onComplete) {
try {
this.func.apply(this.spec);
}
else {
try {
this.func.apply(this.spec);
} catch (e) {
this.spec.fail(e);
}
} catch (e) {
this.spec.fail(e);
}
onComplete();
};

View File

@@ -168,25 +168,6 @@ jasmine.Env.prototype.xit = function(desc, func) {
};
};
jasmine.Env.prototype.compareRegExps_ = function(a, b, mismatchKeys, mismatchValues) {
if (a.source != b.source)
mismatchValues.push("expected pattern /" + b.source + "/ is not equal to the pattern /" + a.source + "/");
if (a.ignoreCase != b.ignoreCase)
mismatchValues.push("expected modifier i was" + (b.ignoreCase ? " " : " not ") + "set and does not equal the origin modifier");
if (a.global != b.global)
mismatchValues.push("expected modifier g was" + (b.global ? " " : " not ") + "set and does not equal the origin modifier");
if (a.multiline != b.multiline)
mismatchValues.push("expected modifier m was" + (b.multiline ? " " : " not ") + "set and does not equal the origin modifier");
if (a.sticky != b.sticky)
mismatchValues.push("expected modifier y was" + (b.sticky ? " " : " not ") + "set and does not equal the origin modifier");
return (mismatchValues.length === 0);
};
jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {
if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {
return true;
@@ -249,19 +230,11 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
return a.getTime() == b.getTime();
}
if (a.jasmineMatches) {
return a.jasmineMatches(b);
}
if (b.jasmineMatches) {
return b.jasmineMatches(a);
}
if (a instanceof jasmine.Matchers.ObjectContaining) {
if (a instanceof jasmine.Matchers.Any) {
return a.matches(b);
}
if (b instanceof jasmine.Matchers.ObjectContaining) {
if (b instanceof jasmine.Matchers.Any) {
return b.matches(a);
}
@@ -273,10 +246,6 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
return (a == b);
}
if (a instanceof RegExp && b instanceof RegExp) {
return this.compareRegExps_(a, b, mismatchKeys, mismatchValues);
}
if (typeof a === "object" && typeof b === "object") {
return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
}

View File

@@ -104,7 +104,7 @@ jasmine.Matchers.prototype.toEqual = function(expected) {
/**
* toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
* @param expected
* @deprecated as of 1.0. Use not.toEqual() instead.
* @deprecated as of 1.0. Use not.toNotEqual() instead.
*/
jasmine.Matchers.prototype.toNotEqual = function(expected) {
return !this.env.equals_(this.actual, expected);
@@ -150,17 +150,6 @@ jasmine.Matchers.prototype.toBeNull = function() {
return (this.actual === null);
};
/**
* Matcher that compares the actual to NaN.
*/
jasmine.Matchers.prototype.toBeNaN = function() {
this.message = function() {
return [ "Expected " + jasmine.pp(this.actual) + " to be NaN." ];
};
return (this.actual !== this.actual);
};
/**
* Matcher that boolean not-nots the actual.
*/
@@ -238,14 +227,18 @@ jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
}
this.message = function() {
var invertedMessage = "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was.";
var positiveMessage = "";
if (this.actual.callCount === 0) {
positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.";
// todo: what should the failure message for .not.toHaveBeenCalledWith() be? is this right? test better. [xw]
return [
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.",
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was."
];
} else {
positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but actual calls were " + jasmine.pp(this.actual.argsForCall).replace(/^\[ | \]$/g, '')
return [
"Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall),
"Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall)
];
}
return [positiveMessage, invertedMessage];
};
return this.env.contains_(this.actual.argsForCall, expectedArgs);
@@ -284,7 +277,7 @@ jasmine.Matchers.prototype.toContain = function(expected) {
* Matcher that checks that the expected item is NOT an element in the actual Array.
*
* @param {Object} expected
* @deprecated as of 1.0. Use not.toContain() instead.
* @deprecated as of 1.0. Use not.toNotContain() instead.
*/
jasmine.Matchers.prototype.toNotContain = function(expected) {
return !this.env.contains_(this.actual, expected);
@@ -303,19 +296,22 @@ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
* up to a given level of decimal precision (default 2).
*
* @param {Number} expected
* @param {Number} precision, as number of decimal places
* @param {Number} precision
*/
jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
if (!(precision === 0)) {
precision = precision || 2;
}
return Math.abs(expected - this.actual) < (Math.pow(10, -precision) / 2);
var multiplier = Math.pow(10, precision);
var actual = Math.round(this.actual * multiplier);
expected = Math.round(expected * multiplier);
return expected == actual;
};
/**
* Matcher that checks that the expected exception was thrown by the actual.
*
* @param {String} [expected]
* @param {String} expected
*/
jasmine.Matchers.prototype.toThrow = function(expected) {
var result = false;
@@ -349,7 +345,7 @@ jasmine.Matchers.Any = function(expectedClass) {
this.expectedClass = expectedClass;
};
jasmine.Matchers.Any.prototype.jasmineMatches = function(other) {
jasmine.Matchers.Any.prototype.matches = function(other) {
if (this.expectedClass == String) {
return typeof other == 'string' || other instanceof String;
}
@@ -369,36 +365,7 @@ jasmine.Matchers.Any.prototype.jasmineMatches = function(other) {
return other instanceof this.expectedClass;
};
jasmine.Matchers.Any.prototype.jasmineToString = function() {
jasmine.Matchers.Any.prototype.toString = function() {
return '<jasmine.any(' + this.expectedClass + ')>';
};
jasmine.Matchers.ObjectContaining = function (sample) {
this.sample = sample;
};
jasmine.Matchers.ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) {
mismatchKeys = mismatchKeys || [];
mismatchValues = mismatchValues || [];
var env = jasmine.getEnv();
var hasKey = function(obj, keyName) {
return obj != null && obj[keyName] !== jasmine.undefined;
};
for (var property in this.sample) {
if (!hasKey(other, property) && hasKey(this.sample, property)) {
mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
}
else if (!env.equals_(this.sample[property], other[property], mismatchKeys, mismatchValues)) {
mismatchValues.push("'" + property + "' was '" + (other[property] ? jasmine.util.htmlEscape(other[property].toString()) : other[property]) + "' in expected, but was '" + (this.sample[property] ? jasmine.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in actual.");
}
}
return (mismatchKeys.length === 0 && mismatchValues.length === 0);
};
jasmine.Matchers.ObjectContaining.prototype.jasmineToString = function () {
return "<jasmine.objectContaining(" + jasmine.pp(this.sample) + ")>";
};

View File

@@ -11,6 +11,10 @@ jasmine.PrettyPrinter = function() {
* @param value
*/
jasmine.PrettyPrinter.prototype.format = function(value) {
if (this.ppNestLevel_ > 40) {
throw new Error('jasmine.PrettyPrinter: format() nested too deeply!');
}
this.ppNestLevel_++;
try {
if (value === jasmine.undefined) {
@@ -19,8 +23,8 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
this.emitScalar('null');
} else if (value === jasmine.getGlobal()) {
this.emitScalar('<global>');
} else if (value.jasmineToString) {
this.emitScalar(value.jasmineToString());
} else if (value instanceof jasmine.Matchers.Any) {
this.emitScalar(value.toString());
} else if (typeof value === 'string') {
this.emitString(value);
} else if (jasmine.isSpy(value)) {
@@ -53,7 +57,6 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
for (var property in obj) {
if (!obj.hasOwnProperty(property)) continue;
if (property == '__Jasmine_been_here_before__') continue;
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined &&
obj.__lookupGetter__(property) !== null) : false);
@@ -81,11 +84,6 @@ jasmine.StringPrettyPrinter.prototype.emitString = function(value) {
};
jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
this.append("Array");
return;
}
this.append('[ ');
for (var i = 0; i < array.length; i++) {
if (i > 0) {
@@ -97,11 +95,6 @@ jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
};
jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) {
if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
this.append("Object");
return;
}
var self = this;
this.append('{ ');
var first = true;

View File

@@ -1,9 +1,5 @@
jasmine.Queue = function(env) {
this.env = env;
// parallel to blocks. each true value in this array means the block will
// get executed even if we abort
this.ensured = [];
this.blocks = [];
this.running = false;
this.index = 0;
@@ -11,30 +7,15 @@ jasmine.Queue = function(env) {
this.abort = false;
};
jasmine.Queue.prototype.addBefore = function(block, ensure) {
if (ensure === jasmine.undefined) {
ensure = false;
}
jasmine.Queue.prototype.addBefore = function(block) {
this.blocks.unshift(block);
this.ensured.unshift(ensure);
};
jasmine.Queue.prototype.add = function(block, ensure) {
if (ensure === jasmine.undefined) {
ensure = false;
}
jasmine.Queue.prototype.add = function(block) {
this.blocks.push(block);
this.ensured.push(ensure);
};
jasmine.Queue.prototype.insertNext = function(block, ensure) {
if (ensure === jasmine.undefined) {
ensure = false;
}
this.ensured.splice((this.index + this.offset + 1), 0, ensure);
jasmine.Queue.prototype.insertNext = function(block) {
this.blocks.splice((this.index + this.offset + 1), 0, block);
this.offset++;
};
@@ -58,7 +39,7 @@ jasmine.Queue.prototype.next_ = function() {
while (goAgain) {
goAgain = false;
if (self.index < self.blocks.length && !(this.abort && !this.ensured[self.index])) {
if (self.index < self.blocks.length && !this.abort) {
var calledSynchronously = true;
var completedSynchronously = false;

View File

@@ -154,7 +154,7 @@ jasmine.Spec.prototype.finish = function(onComplete) {
jasmine.Spec.prototype.after = function(doAfter) {
if (this.queue.isRunning()) {
this.queue.add(new jasmine.Block(this.env, doAfter, this), true);
this.queue.add(new jasmine.Block(this.env, doAfter, this));
} else {
this.afterCallbacks.unshift(doAfter);
}
@@ -192,15 +192,15 @@ jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {
this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this));
}
for (i = 0; i < this.afterCallbacks.length; i++) {
this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this), true);
this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this));
}
for (suite = this.suite; suite; suite = suite.parentSuite) {
for (i = 0; i < suite.after_.length; i++) {
this.queue.add(new jasmine.Block(this.env, suite.after_[i], this), true);
this.queue.add(new jasmine.Block(this.env, suite.after_[i], this));
}
}
for (i = 0; i < runner.after_.length; i++) {
this.queue.add(new jasmine.Block(this.env, runner.after_[i], this), true);
this.queue.add(new jasmine.Block(this.env, runner.after_[i], this));
}
};

32
src/core/base.js Normal file → Executable file
View File

@@ -1,4 +1,4 @@
var isCommonJS = typeof window == "undefined" && typeof exports == "object";
var isCommonJS = typeof window == "undefined";
/**
* Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
@@ -34,23 +34,11 @@ jasmine.VERBOSE = false;
*/
jasmine.DEFAULT_UPDATE_INTERVAL = 250;
/**
* Maximum levels of nesting that will be included when an object is pretty-printed
*/
jasmine.MAX_PRETTY_PRINT_DEPTH = 40;
/**
* Default timeout interval in milliseconds for waitsFor() blocks.
*/
jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
/**
* By default exceptions thrown in the context of a test are caught by jasmine so that it can run the remaining tests in the suite.
* Set to false to let the exception bubble up in the browser.
*
*/
jasmine.CATCH_EXCEPTIONS = true;
jasmine.getGlobal = function() {
function getGlobal() {
return this;
@@ -208,21 +196,6 @@ jasmine.any = function(clazz) {
return new jasmine.Matchers.Any(clazz);
};
/**
* Returns a matchable subset of a JSON object. For use in expectations when you don't care about all of the
* attributes on the object.
*
* @example
* // don't care about any other attributes than foo.
* expect(mySpy).toHaveBeenCalledWith(jasmine.objectContaining({foo: "bar"});
*
* @param sample {Object} sample
* @returns matchable object for the sample
*/
jasmine.objectContaining = function (sample) {
return new jasmine.Matchers.ObjectContaining(sample);
};
/**
* Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks.
*
@@ -475,7 +448,7 @@ jasmine.log = function() {
* @see jasmine.createSpy
* @param obj
* @param methodName
* @return {jasmine.Spy} a Jasmine spy that can be chained with all spy methods
* @returns a Jasmine spy that can be chained with all spy methods
*/
var spyOn = function(obj, methodName) {
return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
@@ -520,7 +493,6 @@ if (isCommonJS) exports.xit = xit;
* jasmine.Matchers functions.
*
* @param {Object} actual Actual value to test against and expected value
* @return {jasmine.Matchers}
*/
var expect = function(actual) {
return jasmine.getEnv().currentSpec.expect(actual);

0
src/core/mock-timeout.js Normal file → Executable file
View File

View File

@@ -18,14 +18,13 @@ jasmine.HtmlReporter = function(_doc) {
createReporterDom(runner.env.versionString());
doc.body.appendChild(dom.reporter);
setExceptionHandling();
reporterView = new jasmine.HtmlReporter.ReporterView(dom);
reporterView.addSpecs(specs, self.specFilter);
};
self.reportRunnerResults = function(runner) {
reporterView && reporterView.complete();
reporterView.complete();
};
self.reportSuiteResults = function(suite) {
@@ -72,7 +71,7 @@ jasmine.HtmlReporter = function(_doc) {
}
var paramMap = [];
var params = jasmine.HtmlReporter.parameters(doc);
var params = doc.location.search.substring(1).split('&');
for (var i = 0; i < params.length; i++) {
var p = params[i].split('=');
@@ -92,74 +91,11 @@ jasmine.HtmlReporter = function(_doc) {
self.createDom('span', { className: 'version' }, version)),
dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
dom.alert = self.createDom('div', {className: 'alert'},
self.createDom('span', { className: 'exceptions' },
self.createDom('label', { className: 'label', 'for': 'no_try_catch' }, 'No try/catch'),
self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
dom.alert = self.createDom('div', {className: 'alert'}),
dom.results = self.createDom('div', {className: 'results'},
dom.summary = self.createDom('div', { className: 'summary' }),
dom.details = self.createDom('div', { id: 'details' }))
);
}
function noTryCatch() {
return window.location.search.match(/catch=false/);
}
function searchWithCatch() {
var params = jasmine.HtmlReporter.parameters(window.document);
var removed = false;
var i = 0;
while (!removed && i < params.length) {
if (params[i].match(/catch=/)) {
params.splice(i, 1);
removed = true;
}
i++;
}
if (jasmine.CATCH_EXCEPTIONS) {
params.push("catch=false");
}
return params.join("&");
}
function setExceptionHandling() {
var chxCatch = document.getElementById('no_try_catch');
if (noTryCatch()) {
chxCatch.setAttribute('checked', true);
jasmine.CATCH_EXCEPTIONS = false;
}
chxCatch.onclick = function() {
window.location.search = searchWithCatch();
};
}
};
jasmine.HtmlReporter.parameters = function(doc) {
var paramStr = doc.location.search.substring(1);
var params = [];
if (paramStr.length > 0) {
params = paramStr.split('&');
}
return params;
}
jasmine.HtmlReporter.sectionLink = function(sectionName) {
var link = '?';
var params = [];
if (sectionName) {
params.push('spec=' + encodeURIComponent(sectionName));
}
if (!jasmine.CATCH_EXCEPTIONS) {
params.push("catch=false");
}
if (params.length > 0) {
link += params.join("&");
}
return link;
};
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);

View File

@@ -21,30 +21,8 @@ jasmine.HtmlReporter.ReporterView = function(dom) {
};
};
this.addSpecs = function(specs, specFilter) {
this.totalSpecCount = specs.length;
this.views = {
specs: {},
suites: {}
};
for (var i = 0; i < specs.length; i++) {
var spec = specs[i];
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
if (specFilter(spec)) {
this.runningSpecCount++;
}
}
};
this.specComplete = function(spec) {
this.completeSpecCount++;
if (isUndefined(this.views.specs[spec.id])) {
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
}
var specView = this.views.specs[spec.id];
switch (specView.status()) {
@@ -81,17 +59,17 @@ jasmine.HtmlReporter.ReporterView = function(dom) {
// currently running UI
if (isUndefined(this.runningAlert)) {
this.runningAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "runningAlert bar" });
this.runningAlert = this.createDom('a', {href: "?", className: "runningAlert bar"});
dom.alert.appendChild(this.runningAlert);
}
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + this.totalSpecCount + " spec" + (this.totalSpecCount == 1 ? "" : "s" );
// skipped specs UI
if (isUndefined(this.skippedAlert)) {
this.skippedAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "skippedAlert bar" });
this.skippedAlert = this.createDom('a', {href: "?", className: "skippedAlert bar"});
}
this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + this.totalSpecCount + " spec" + (this.totalSpecCount == 1 ? "" : "s" ) + " - run all";
if (this.skippedCount === 1 && isDefined(dom.alert)) {
dom.alert.appendChild(this.skippedAlert);
@@ -99,15 +77,15 @@ jasmine.HtmlReporter.ReporterView = function(dom) {
// passing specs UI
if (isUndefined(this.passedAlert)) {
this.passedAlert = this.createDom('span', { href: jasmine.HtmlReporter.sectionLink(), className: "passingAlert bar" });
this.passedAlert = this.createDom('span', {href: "?", className: "passingAlert bar"});
}
this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
this.passedAlert.innerHTML = "Passing " + this.passedCount + " spec" + (this.passedCount == 1 ? "" : "s" );
// failing specs UI
if (isUndefined(this.failedAlert)) {
this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
}
this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
this.failedAlert.innerHTML = "Failing " + this.failedCount + " spec" + (this.totalSpecCount == 1 ? "" : "s" );
if (this.failedCount === 1 && isDefined(dom.alert)) {
dom.alert.appendChild(this.failedAlert);
@@ -115,17 +93,17 @@ jasmine.HtmlReporter.ReporterView = function(dom) {
}
// summary info
this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
this.summaryMenuItem.innerHTML = "" + this.runningSpecCount + " spec" + (this.runningSpecCount == 1 ? "" : "s" );
this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
};
this.complete = function() {
dom.alert.removeChild(this.runningAlert);
this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + this.totalSpecCount + " spec" + (this.totalSpecCount == 1 ? "" : "s" ) + " - run all";
if (this.failedCount === 0) {
dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + this.passedCount + " spec" + (this.passedCount == 1 ? "" : "s" )));
} else {
showDetails();
}
@@ -133,6 +111,23 @@ jasmine.HtmlReporter.ReporterView = function(dom) {
dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
};
this.addSpecs = function(specs, specFilter) {
this.totalSpecCount = specs.length;
this.views = {
specs: {},
suites: {}
};
for (var i = 0; i < specs.length; i++) {
var spec = specs[i];
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
if (specFilter(spec)) {
this.runningSpecCount++;
}
}
};
return this;
function showDetails() {
@@ -148,15 +143,6 @@ jasmine.HtmlReporter.ReporterView = function(dom) {
function isDefined(obj) {
return !isUndefined(obj);
}
function specPluralizedFor(count) {
var str = count + " spec";
if (count > 1) {
str += "s"
}
return str;
}
};
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);

View File

@@ -7,11 +7,11 @@ jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
this.dom.symbolSummary.appendChild(this.symbol);
this.summary = this.createDom('div', { className: 'specSummary' },
this.createDom('a', {
className: 'description',
href: jasmine.HtmlReporter.sectionLink(this.spec.getFullName()),
title: this.spec.getFullName()
}, this.spec.description)
this.createDom('a', {
className: 'description',
href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
title: this.spec.getFullName()
}, this.spec.description)
);
this.detail = this.createDom('div', { className: 'specDetail' },

View File

@@ -4,7 +4,7 @@ jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
this.views = views;
this.element = this.createDom('div', { className: 'suite' },
this.createDom('a', { className: 'description', href: jasmine.HtmlReporter.sectionLink(this.suite.getFullName()) }, this.suite.description)
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(this.suite.getFullName()) }, this.suite.description)
);
this.appendToSummary(this.suite, this.element);

View File

@@ -1,9 +1,8 @@
/* @deprecated Use jasmine.HtmlReporter instead
*/
jasmine.TrivialReporter = function(doc) {
this.document = doc || document;
this.suiteDivs = {};
this.logRunningSpecs = false;
this.log("DEPRECATION WARNING: jasmine.TrivialReporter is deprecated as of v1.2 and will be removed in version 2.0. Please use (the vastly nicer) jasmine.HtmlReporter.")
};
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {

View File

@@ -1,5 +1,6 @@
@import "compass";
$line-height: 14px;
$margin-unit: 14px;
@@ -20,6 +21,7 @@ $neutral-color: #bababa;
$font-size: 11px;
$large-font-size: 14px;
body {
background-color: $page-background-color;
padding: 0;
@@ -69,6 +71,7 @@ body {
color: $feint-text-color;
}
//--- Banner ---//
.banner {
@@ -80,6 +83,8 @@ body {
float: right;
}
//--- Symbol summary ---//
.symbolSummary {
@@ -136,174 +141,185 @@ body {
}
}
}
.exceptions {
color: #fff;
float: right;
margin-top: 5px;
margin-right: 5px;
}
//--- Alert ---//
.bar {
line-height: $line-height * 2;
font-size: $large-font-size;
display: block;
color: #eee;
}
.runningAlert {
background-color: $light-text-color;
}
.skippedAlert {
background-color: $feint-text-color;
&:first-child {
background-color: $text-color;
}
&:hover {
text-decoration: none;
color: white;
text-decoration: underline;
}
}
.passingAlert {
background-color: $light-passing-color;
&:first-child {
background-color: $passing-color;
}
}
.failingAlert {
background-color: $light-failing-color;
&:first-child {
background-color: $failing-color
}
}
//--- Results ---//
.results {
margin-top: $line-height;
}
//--- Results menu ---//
#details {
display: none;
}
.resultsMenu,
.resultsMenu a {
background-color: #fff;
color: $text-color;
}
&.showDetails {
.summaryMenuItem {
font-weight: normal;
text-decoration: inherit;
&:hover {
text-decoration: underline;
}
}
.detailsMenuItem {
font-weight: bold;
text-decoration: underline;
text-decoration: underline;
}
.summary {
display: none;
}
#details {
display: block;
}
}
.summaryMenuItem {
.summaryMenuItem {
font-weight: bold;
text-decoration: underline;
}
//--- Results summary ---//
.summary {
margin-top: $margin-unit;
.suite .suite, .specSummary {
margin-left: $margin-unit;
}
.specSummary {
&.passed a {
color: $passing-color;
color: $passing-color;
}
&.failed a {
color: $failing-color;
}
}
}
.description+.suite {
margin-top: 0;
}
.suite {
margin-top: $margin-unit;
a {
color: $text-color;
}
}
//--- Results details ---//
#details {
.specDetail {
margin-bottom: $line-height * 2;
.description {
//line-height: $line-height * 2;
display: block;
color: white;
background-color: $failing-color;
//font-size: $large-font-size;
}
}
}
.resultMessage {
padding-top: $line-height;
color: $text-color;
}
.resultMessage span.result {
display: block;
}
.stackTrace {
margin: 5px 0 0 0;
max-height: $line-height * 16;
overflow: auto;
line-height: 18px;
color: $light-text-color;
border: 1px solid #ddd;
background: white;
white-space: pre;
}
}
}

View File

@@ -1,3 +1,4 @@
#TrivialReporter {
padding: 8px 13px;
position: absolute;
@@ -6,134 +7,134 @@
left: 0;
right: 0;
overflow-y: scroll;
background-color: white;
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
a:visited, a {
color: #303;
color: #303;
}
a:hover, a:active {
color: blue;
color: blue;
}
.run_spec {
float:right;
padding-right: 5px;
font-size: .8em;
text-decoration: none;
}
.banner {
color: #303;
background-color: #fef;
padding: 5px;
}
.logo {
float: left;
font-size: 1.1em;
padding-left: 5px;
}
.logo .version {
font-size: .6em;
padding-left: 1em;
}
.runner.running {
background-color: yellow;
}
.options {
text-align: right;
font-size: .8em;
}
.suite {
border: 1px outset gray;
margin: 5px 0;
padding-left: 1em;
}
.suite .suite {
margin: 5px;
margin: 5px;
}
.suite.passed {
background-color: #dfd;
}
.suite.failed {
background-color: #fdd;
}
.spec {
margin: 5px;
padding-left: 1em;
clear: both;
}
.spec.failed, .spec.passed, .spec.skipped {
padding-bottom: 5px;
border: 1px solid gray;
}
.spec.failed {
background-color: #fbb;
border-color: red;
}
.spec.passed {
background-color: #bfb;
border-color: green;
}
.spec.skipped {
background-color: #bbb;
}
.messages {
border-left: 1px dashed gray;
padding-left: 1em;
padding-right: 1em;
}
.passed {
background-color: #cfc;
display: none;
}
.failed {
background-color: #fbb;
}
.skipped {
color: #777;
background-color: #eee;
display: none;
}
/*.resultMessage {*/
/*white-space: pre;*/
/*}*/
.resultMessage span.result {
display: block;
line-height: 2em;
color: black;
}
.resultMessage .mismatch {
color: black;
}
.stackTrace {
white-space: pre;
font-size: .8em;
@@ -144,22 +145,23 @@
padding: 1em;
background: #eef;
}
.finished-at {
padding-left: 1em;
font-size: .6em;
}
&.show-passed .passed,
&.show-skipped .skipped {
display: block;
}
#jasmine_content {
position:fixed;
right: 100%;
}
.runner {
border: 1px solid gray;
display: block;

View File

@@ -1,82 +1,413 @@
body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
/* line 25, _HTMLReporter.scss */
body {
background-color: #eeeeee;
padding: 0;
margin: 5px;
overflow-y: scroll;
}
#HTMLReporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
#HTMLReporter a { text-decoration: none; }
#HTMLReporter a:hover { text-decoration: underline; }
#HTMLReporter p, #HTMLReporter h1, #HTMLReporter h2, #HTMLReporter h3, #HTMLReporter h4, #HTMLReporter h5, #HTMLReporter h6 { margin: 0; line-height: 14px; }
#HTMLReporter .banner, #HTMLReporter .symbolSummary, #HTMLReporter .summary, #HTMLReporter .resultMessage, #HTMLReporter .specDetail .description, #HTMLReporter .alert .bar, #HTMLReporter .stackTrace { padding-left: 9px; padding-right: 9px; }
#HTMLReporter #jasmine_content { position: fixed; right: 100%; }
#HTMLReporter .version { color: #aaaaaa; }
#HTMLReporter .banner { margin-top: 14px; }
#HTMLReporter .duration { color: #aaaaaa; float: right; }
#HTMLReporter .symbolSummary { overflow: hidden; *zoom: 1; margin: 14px 0; }
#HTMLReporter .symbolSummary li { display: block; float: left; height: 7px; width: 14px; margin-bottom: 7px; font-size: 16px; }
#HTMLReporter .symbolSummary li.passed { font-size: 14px; }
#HTMLReporter .symbolSummary li.passed:before { color: #5e7d00; content: "\02022"; }
#HTMLReporter .symbolSummary li.failed { line-height: 9px; }
#HTMLReporter .symbolSummary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; }
#HTMLReporter .symbolSummary li.skipped { font-size: 14px; }
#HTMLReporter .symbolSummary li.skipped:before { color: #bababa; content: "\02022"; }
#HTMLReporter .symbolSummary li.pending { line-height: 11px; }
#HTMLReporter .symbolSummary li.pending:before { color: #aaaaaa; content: "-"; }
#HTMLReporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
#HTMLReporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
#HTMLReporter .runningAlert { background-color: #666666; }
#HTMLReporter .skippedAlert { background-color: #aaaaaa; }
#HTMLReporter .skippedAlert:first-child { background-color: #333333; }
#HTMLReporter .skippedAlert:hover { text-decoration: none; color: white; text-decoration: underline; }
#HTMLReporter .passingAlert { background-color: #a6b779; }
#HTMLReporter .passingAlert:first-child { background-color: #5e7d00; }
#HTMLReporter .failingAlert { background-color: #cf867e; }
#HTMLReporter .failingAlert:first-child { background-color: #b03911; }
#HTMLReporter .results { margin-top: 14px; }
#HTMLReporter #details { display: none; }
#HTMLReporter .resultsMenu, #HTMLReporter .resultsMenu a { background-color: #fff; color: #333333; }
#HTMLReporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
#HTMLReporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
#HTMLReporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
#HTMLReporter.showDetails .summary { display: none; }
#HTMLReporter.showDetails #details { display: block; }
#HTMLReporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
#HTMLReporter .summary { margin-top: 14px; }
#HTMLReporter .summary .suite .suite, #HTMLReporter .summary .specSummary { margin-left: 14px; }
#HTMLReporter .summary .specSummary.passed a { color: #5e7d00; }
#HTMLReporter .summary .specSummary.failed a { color: #b03911; }
#HTMLReporter .description + .suite { margin-top: 0; }
#HTMLReporter .suite { margin-top: 14px; }
#HTMLReporter .suite a { color: #333333; }
#HTMLReporter #details .specDetail { margin-bottom: 28px; }
#HTMLReporter #details .specDetail .description { display: block; color: white; background-color: #b03911; }
#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
#HTMLReporter .resultMessage span.result { display: block; }
#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
/* line 32, _HTMLReporter.scss */
#HTMLReporter {
font-size: 11px;
font-family: Monaco, "Lucida Console", monospace;
line-height: 14px;
color: #333333;
}
/* line 39, _HTMLReporter.scss */
#HTMLReporter a {
text-decoration: none;
}
/* line 42, _HTMLReporter.scss */
#HTMLReporter a:hover {
text-decoration: underline;
}
/* line 47, _HTMLReporter.scss */
#HTMLReporter p, #HTMLReporter h1, #HTMLReporter h2, #HTMLReporter h3, #HTMLReporter h4, #HTMLReporter h5, #HTMLReporter h6 {
margin: 0;
line-height: 14px;
}
/* line 58, _HTMLReporter.scss */
#HTMLReporter .banner,
#HTMLReporter .symbolSummary,
#HTMLReporter .summary,
#HTMLReporter .resultMessage,
#HTMLReporter .specDetail .description,
#HTMLReporter .alert .bar,
#HTMLReporter .stackTrace {
padding-left: 9px;
padding-right: 9px;
}
/* line 65, _HTMLReporter.scss */
#HTMLReporter #jasmine_content {
position: fixed;
right: 100%;
}
/* line 70, _HTMLReporter.scss */
#HTMLReporter .version {
color: #aaaaaa;
}
/* line 77, _HTMLReporter.scss */
#HTMLReporter .banner {
margin-top: 14px;
}
/* line 81, _HTMLReporter.scss */
#HTMLReporter .duration {
color: #aaaaaa;
float: right;
}
/* line 90, _HTMLReporter.scss */
#HTMLReporter .symbolSummary {
overflow: hidden;
*zoom: 1;
margin: 14px 0;
}
/* line 94, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li {
display: block;
float: left;
height: 7px;
width: 14px;
margin-bottom: 7px;
font-size: 16px;
}
/* line 105, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li.passed {
font-size: 14px;
}
/* line 108, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li.passed:before {
color: #5e7d00;
content: "\02022";
}
/* line 114, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li.failed {
line-height: 9px;
}
/* line 117, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li.failed:before {
color: #b03911;
content: "x";
font-weight: bold;
margin-left: -1px;
}
/* line 125, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li.skipped {
font-size: 14px;
}
/* line 128, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li.skipped:before {
color: #bababa;
content: "\02022";
}
/* line 134, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li.pending {
line-height: 11px;
}
/* line 137, _HTMLReporter.scss */
#HTMLReporter .symbolSummary li.pending:before {
color: #aaaaaa;
content: "-";
}
/* line 149, _HTMLReporter.scss */
#HTMLReporter .bar {
line-height: 28px;
font-size: 14px;
display: block;
color: #eee;
}
/* line 158, _HTMLReporter.scss */
#HTMLReporter .runningAlert {
background-color: #666666;
}
/* line 162, _HTMLReporter.scss */
#HTMLReporter .skippedAlert {
background-color: #aaaaaa;
}
/* line 165, _HTMLReporter.scss */
#HTMLReporter .skippedAlert:first-child {
background-color: #333333;
}
/* line 169, _HTMLReporter.scss */
#HTMLReporter .skippedAlert:hover {
text-decoration: none;
color: white;
text-decoration: underline;
}
/* line 176, _HTMLReporter.scss */
#HTMLReporter .passingAlert {
background-color: #a6b779;
}
/* line 179, _HTMLReporter.scss */
#HTMLReporter .passingAlert:first-child {
background-color: #5e7d00;
}
/* line 184, _HTMLReporter.scss */
#HTMLReporter .failingAlert {
background-color: #cf867e;
}
/* line 187, _HTMLReporter.scss */
#HTMLReporter .failingAlert:first-child {
background-color: #b03911;
}
/* line 200, _HTMLReporter.scss */
#HTMLReporter .results {
margin-top: 14px;
}
/* line 208, _HTMLReporter.scss */
#HTMLReporter #details {
display: none;
}
/* line 213, _HTMLReporter.scss */
#HTMLReporter .resultsMenu,
#HTMLReporter .resultsMenu a {
background-color: #fff;
color: #333333;
}
/* line 220, _HTMLReporter.scss */
#HTMLReporter.showDetails .summaryMenuItem {
font-weight: normal;
text-decoration: inherit;
}
/* line 224, _HTMLReporter.scss */
#HTMLReporter.showDetails .summaryMenuItem:hover {
text-decoration: underline;
}
/* line 229, _HTMLReporter.scss */
#HTMLReporter.showDetails .detailsMenuItem {
font-weight: bold;
text-decoration: underline;
}
/* line 234, _HTMLReporter.scss */
#HTMLReporter.showDetails .summary {
display: none;
}
/* line 238, _HTMLReporter.scss */
#HTMLReporter.showDetails #details {
display: block;
}
/* line 243, _HTMLReporter.scss */
#HTMLReporter .summaryMenuItem {
font-weight: bold;
text-decoration: underline;
}
/* line 253, _HTMLReporter.scss */
#HTMLReporter .summary {
margin-top: 14px;
}
/* line 256, _HTMLReporter.scss */
#HTMLReporter .summary .suite .suite, #HTMLReporter .summary .specSummary {
margin-left: 14px;
}
/* line 261, _HTMLReporter.scss */
#HTMLReporter .summary .specSummary.passed a {
color: #5e7d00;
}
/* line 264, _HTMLReporter.scss */
#HTMLReporter .summary .specSummary.failed a {
color: #b03911;
}
/* line 270, _HTMLReporter.scss */
#HTMLReporter .description + .suite {
margin-top: 0;
}
/* line 274, _HTMLReporter.scss */
#HTMLReporter .suite {
margin-top: 14px;
}
/* line 277, _HTMLReporter.scss */
#HTMLReporter .suite a {
color: #333333;
}
/* line 288, _HTMLReporter.scss */
#HTMLReporter #details .specDetail {
margin-bottom: 28px;
}
/* line 291, _HTMLReporter.scss */
#HTMLReporter #details .specDetail .description {
display: block;
color: white;
background-color: #b03911;
}
/* line 303, _HTMLReporter.scss */
#HTMLReporter .resultMessage {
padding-top: 14px;
color: #333333;
}
/* line 309, _HTMLReporter.scss */
#HTMLReporter .resultMessage span.result {
display: block;
}
/* line 313, _HTMLReporter.scss */
#HTMLReporter .stackTrace {
margin: 5px 0 0 0;
max-height: 224px;
overflow: auto;
line-height: 18px;
color: #666666;
border: 1px solid #ddd;
background: white;
white-space: pre;
}
#TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ }
#TrivialReporter a:visited, #TrivialReporter a { color: #303; }
#TrivialReporter a:hover, #TrivialReporter a:active { color: blue; }
#TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; }
#TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; }
#TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; }
#TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; }
#TrivialReporter .runner.running { background-color: yellow; }
#TrivialReporter .options { text-align: right; font-size: .8em; }
#TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; }
#TrivialReporter .suite .suite { margin: 5px; }
#TrivialReporter .suite.passed { background-color: #dfd; }
#TrivialReporter .suite.failed { background-color: #fdd; }
#TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; }
#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; }
#TrivialReporter .spec.failed { background-color: #fbb; border-color: red; }
#TrivialReporter .spec.passed { background-color: #bfb; border-color: green; }
#TrivialReporter .spec.skipped { background-color: #bbb; }
#TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; }
#TrivialReporter .passed { background-color: #cfc; display: none; }
#TrivialReporter .failed { background-color: #fbb; }
#TrivialReporter .skipped { color: #777; background-color: #eee; display: none; }
#TrivialReporter .resultMessage span.result { display: block; line-height: 2em; color: black; }
#TrivialReporter .resultMessage .mismatch { color: black; }
#TrivialReporter .stackTrace { white-space: pre; font-size: .8em; margin-left: 10px; max-height: 5em; overflow: auto; border: 1px inset red; padding: 1em; background: #eef; }
#TrivialReporter .finished-at { padding-left: 1em; font-size: .6em; }
#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped { display: block; }
#TrivialReporter #jasmine_content { position: fixed; right: 100%; }
#TrivialReporter .runner { border: 1px solid gray; display: block; margin: 5px 0; padding: 2px 0 2px 10px; }
/* line 2, _TrivialReporter.scss */
#TrivialReporter {
padding: 8px 13px;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
overflow-y: scroll;
background-color: white;
font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif;
/*.resultMessage {*/
/*white-space: pre;*/
/*}*/
}
/* line 14, _TrivialReporter.scss */
#TrivialReporter a:visited, #TrivialReporter a {
color: #303;
}
/* line 18, _TrivialReporter.scss */
#TrivialReporter a:hover, #TrivialReporter a:active {
color: blue;
}
/* line 22, _TrivialReporter.scss */
#TrivialReporter .run_spec {
float: right;
padding-right: 5px;
font-size: .8em;
text-decoration: none;
}
/* line 29, _TrivialReporter.scss */
#TrivialReporter .banner {
color: #303;
background-color: #fef;
padding: 5px;
}
/* line 35, _TrivialReporter.scss */
#TrivialReporter .logo {
float: left;
font-size: 1.1em;
padding-left: 5px;
}
/* line 41, _TrivialReporter.scss */
#TrivialReporter .logo .version {
font-size: .6em;
padding-left: 1em;
}
/* line 46, _TrivialReporter.scss */
#TrivialReporter .runner.running {
background-color: yellow;
}
/* line 51, _TrivialReporter.scss */
#TrivialReporter .options {
text-align: right;
font-size: .8em;
}
/* line 59, _TrivialReporter.scss */
#TrivialReporter .suite {
border: 1px outset gray;
margin: 5px 0;
padding-left: 1em;
}
/* line 65, _TrivialReporter.scss */
#TrivialReporter .suite .suite {
margin: 5px;
}
/* line 69, _TrivialReporter.scss */
#TrivialReporter .suite.passed {
background-color: #dfd;
}
/* line 73, _TrivialReporter.scss */
#TrivialReporter .suite.failed {
background-color: #fdd;
}
/* line 77, _TrivialReporter.scss */
#TrivialReporter .spec {
margin: 5px;
padding-left: 1em;
clear: both;
}
/* line 83, _TrivialReporter.scss */
#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped {
padding-bottom: 5px;
border: 1px solid gray;
}
/* line 88, _TrivialReporter.scss */
#TrivialReporter .spec.failed {
background-color: #fbb;
border-color: red;
}
/* line 93, _TrivialReporter.scss */
#TrivialReporter .spec.passed {
background-color: #bfb;
border-color: green;
}
/* line 98, _TrivialReporter.scss */
#TrivialReporter .spec.skipped {
background-color: #bbb;
}
/* line 102, _TrivialReporter.scss */
#TrivialReporter .messages {
border-left: 1px dashed gray;
padding-left: 1em;
padding-right: 1em;
}
/* line 108, _TrivialReporter.scss */
#TrivialReporter .passed {
background-color: #cfc;
display: none;
}
/* line 113, _TrivialReporter.scss */
#TrivialReporter .failed {
background-color: #fbb;
}
/* line 117, _TrivialReporter.scss */
#TrivialReporter .skipped {
color: #777;
background-color: #eee;
display: none;
}
/* line 128, _TrivialReporter.scss */
#TrivialReporter .resultMessage span.result {
display: block;
line-height: 2em;
color: black;
}
/* line 134, _TrivialReporter.scss */
#TrivialReporter .resultMessage .mismatch {
color: black;
}
/* line 138, _TrivialReporter.scss */
#TrivialReporter .stackTrace {
white-space: pre;
font-size: .8em;
margin-left: 10px;
max-height: 5em;
overflow: auto;
border: 1px inset red;
padding: 1em;
background: #eef;
}
/* line 149, _TrivialReporter.scss */
#TrivialReporter .finished-at {
padding-left: 1em;
font-size: .6em;
}
/* line 155, _TrivialReporter.scss */
#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped {
display: block;
}
/* line 160, _TrivialReporter.scss */
#TrivialReporter #jasmine_content {
position: fixed;
right: 100%;
}
/* line 165, _TrivialReporter.scss */
#TrivialReporter .runner {
border: 1px solid gray;
display: block;
margin: 5px 0;
padding: 2px 0 2px 10px;
}

View File

@@ -1,4 +1,3 @@
jasmine.version_= {
"major": <%= major %>,
"minor": <%= minor %>,

View File

@@ -1,7 +1,7 @@
jasmine.version_= {
"major": 1,
"minor": 3,
"build": 1,
"revision": 1354556913
"minor": 2,
"build": 0,
"revision": 1315672648,
"release_candidate": 1
};

View File

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

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

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
['./src/html/HtmlReporterHelpers.js'] + 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,18 +0,0 @@
require 'thor'
require 'json'
require 'tilt'
require 'ostruct'
$:.unshift(File.join(File.dirname(__FILE__), "jasmine_dev"))
require "base"
require "sources"
require "js_hint"
require "build_distribution"
require "build_github_pages"
require "build_standalone_distribution"
require "build_standalone_runner"
require "count_specs"
require "execute_specs"
require "release"
require "version"

View File

@@ -1,54 +0,0 @@
class JasmineDev < Thor
include Thor::Actions
def self.source_root
File.dirname(__FILE__)
end
def self.source_paths
[
File.join(JasmineDev.project_root, 'lib', 'jasmine-core'),
JasmineDev.project_root
]
end
def self.project_root
File.join(JasmineDev.source_root, '..', '..')
end
def self.spacer
"\n--------------------"
end
no_tasks do
# allows merged stdout in test with low-harassment
def run_with_output(*run_args)
say run *run_args
end
def node_installed?
return true if has_node?
say "Node.js is required to develop Jasmine. Please visit http://nodejs.org to install.",
:red
false
end
def has_node?
run "which node", :verbose => false, :capture => true
$?.exitstatus == 0
end
def pages_submodule_installed?
return true if has_pages_submodule?
say "Submodule for Github Pages isn't present. Run git submodule update --init",
:red
false
end
def has_pages_submodule?
File.exist?(File.join(JasmineDev.project_root, 'pages', 'index.html'))
end
end
end

View File

@@ -1,53 +0,0 @@
class JasmineDev < Thor
desc "build_distribution", "Build Jasmine js & css files"
def build_distribution(directory = "./lib/jasmine-core")
invoke :js_hint
say JasmineDev.spacer
say "Building Jasmine distribution from source into #{directory}", :cyan
say 'Building JavaScript...', :yellow
inside directory do
create_file "jasmine.js",
concat_contents_of(jasmine_js_paths),
:force => true
create_file "jasmine-html.js",
concat_contents_of(jasmine_html_js_paths),
:force => true
end
say 'Building CSS...', :yellow
run "compass compile", :capture => true
copy_file File.join("#{JasmineDev.project_root}", 'src', 'html', 'jasmine.css'),
File.join(directory, 'jasmine.css')
end
no_tasks do
def jasmine_js_paths
paths = JasmineDev::JASMINE_SOURCES[:core].collect do |f|
File.join(JasmineDev.project_root, 'src', 'core', f)
end
paths << File.join(JasmineDev.project_root, 'src', 'version.js')
paths
end
def jasmine_html_js_paths
JasmineDev::JASMINE_SOURCES[:html].collect do |f|
File.join(JasmineDev.project_root, 'src', 'html', f)
end
end
def concat_contents_of(paths)
paths.inject("") do |string, path|
string << File.read(path)
string
end
end
end
end

View File

@@ -1,28 +0,0 @@
class JasmineDev < Thor
desc "build_github_pages", "Build static pages for pivotal.github.com/jasmine"
def build_github_pages(pages_dir = File.expand_path(File.join('.', 'pages')))
say JasmineDev.spacer
say "Building Github Pages...", :cyan
return unless pages_submodule_installed?
project_lib_dir = File.join(JasmineDev.project_root, 'lib', 'jasmine-core')
pages_lib_dir = File.join(pages_dir, 'lib')
FileUtils.rm_r(pages_lib_dir) if File.exist?(pages_lib_dir)
['jasmine.js', 'jasmine-html.js', 'jasmine.css'].each do |file|
copy_file File.join(project_lib_dir, file), File.join(pages_lib_dir, file)
end
inside File.join(JasmineDev.project_root, 'pages', 'src') do
run_with_output "bundle exec rocco -l js introduction.js -t layout.mustache -o #{pages_dir}"
end
inside pages_dir do
copy_file File.join(pages_dir,'introduction.html'), File.join(pages_dir,'index.html')
end
end
end

View File

@@ -1,50 +0,0 @@
class JasmineDev < Thor
include Thor::Actions
desc "build_standalone_distribution", "Build Jasmine standalone distribution"
def build_standalone_distribution(download_dir = File.expand_path(File.join('.', 'pages', 'downloads')))
invoke :build_distribution
say JasmineDev.spacer
say "Building standalone distribution...", :cyan
say "Staging files...", :yellow
lib_files.each do |f|
copy_file f, File.join(standalone_temp_dir, 'lib', "jasmine-#{version_string}", f)
end
['src', 'spec'].each do |dir|
directory File.join('lib', 'jasmine-core', 'example', dir),
File.join(standalone_temp_dir, dir)
end
invoke :build_standalone_runner
say "Zipping distribution...", :yellow
inside standalone_temp_dir do
run_with_output "zip -rq ../jasmine-standalone-#{version_string}.zip ."
say "Copying Zip file to downloads directory", :yellow
run "mkdir -p #{download_dir}"
run "cp ../jasmine-standalone-#{version_string}.zip #{download_dir}/"
end
end
no_tasks do
def standalone_temp_dir
@standalone_temp_dir ||= File.join(Dir.tmpdir, 'jasmine_standalone', "jasmine-standalone-#{version_string}")
end
def lib_files
%w{ jasmine.js jasmine-html.js jasmine.css MIT.LICENSE }
end
def example_path
File.join('lib', "jasmine-#{version_string}")
end
end
end

View File

@@ -1,59 +0,0 @@
class JasmineDev < Thor
include Thor::Actions
desc "build_standalone_runner", "Build HTML spec runner for Jasmine standalone distribution"
def build_standalone_runner
say JasmineDev.spacer
say "Building standalone runner HTML...", :cyan
create_file File.join(standalone_temp_dir, 'SpecRunner.html') do
template = Tilt.new(File.join('spec', 'templates','runner.html.erb'))
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)
template.render(scope)
end
end
no_tasks do
def standalone_temp_dir
@standalone_temp_dir ||= File.join(Dir.tmpdir, 'jasmine_standalone', "jasmine-standalone-#{version_string}")
end
def example_path
File.join('lib', "jasmine-#{version_string}")
end
def example_favicon
%Q{<link rel="shortcut icon" type="image/png" href="#{example_path}/jasmine_favicon.png">}
end
def script_tags_for(files)
srcs = (files.is_a?(String) ? [files] : files)
srcs.inject([]) do |tags, file|
tags << %Q{<script type="text/javascript" src="#{file}"></script>}
tags
end.join("\n ")
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 ['src/Player.js', 'src/Song.js']
end
def example_spec_tags
script_tags_for ['spec/SpecHelper.js', 'spec/PlayerSpec.js']
end
end
end

View File

@@ -1,29 +0,0 @@
class JasmineDev < Thor
desc "count_specs", "Count the number of specs for each test runner"
def count_specs
say JasmineDev.spacer
say "Counting specs...", :cyan
core_spec_count = count_specs_in(File.join('spec', 'core'))
console_spec_count = count_specs_in(File.join('spec', 'console'))
html_spec_count = count_specs_in(File.join('spec', 'html'))
say "#{(core_spec_count + console_spec_count).to_s} ", :yellow
say "specs for Node.js runner (exclude DOM-related specs)"
say "#{(core_spec_count + console_spec_count + html_spec_count).to_s} ", :yellow
say "specs for Browser runner (all specs)"
say "\n"
say "Please verify that these numbers match the runner output."
end
no_tasks do
def count_specs_in(relative_path)
files = Dir.glob(File.join(JasmineDev.project_root, relative_path, '*.js'))
files.inject(0) do |count, file|
File.read(file).scan(/\sit\s*\(/) { |s| count += 1 }
count
end
end
end
end

View File

@@ -1,52 +0,0 @@
class JasmineDev < Thor
desc "execute_specs_in_node", "Run all relevant specs in Node.js"
def execute_specs_in_node
return unless node_installed?
invoke :build_distribution
invoke :count_specs
say JasmineDev.spacer
say "Running all appropriate specs via Node.js...", :cyan
with_color_option = STDOUT.isatty ? "--color" : "--noColor"
run_with_output "node spec/node_suite.js #{with_color_option}", :capture => true
end
desc "execute_specs_in_browser", "Run all relevent specs in your default browser"
def execute_specs_in_browser
invoke :build_distribution
invoke :count_specs
say JasmineDev.spacer
say "Running all appropriate specs via the default web browser...", :cyan
open_specs_in_browser
end
desc "execute_specs", "Run all of Jasmine's JavaScript specs"
def execute_specs
invoke :execute_specs_in_node
invoke :execute_specs_in_browser
end
no_tasks do
def open_specs_in_browser
require 'rbconfig'
case Object.const_get(defined?(RbConfig) ? :RbConfig : :Config)::CONFIG['host_os']
when /linux/
run "xdg-open spec/runner.html"
else
run "open spec/runner.html"
end
end
end
end

View File

@@ -1,13 +0,0 @@
class JasmineDev < Thor
desc "js_hint", "Run Jasmine source through JSHint"
def js_hint
say JasmineDev.spacer
return unless node_installed?
say "Running JSHint on Jasmine source and specs...", :cyan
run_with_output "node jshint/run.js", :capture => true
end
end

View File

@@ -1,16 +0,0 @@
class JasmineDev < Thor
desc 'release_prep', "Update version and build distributions"
def release_prep
say JasmineDev.spacer
say "Building Release...", :cyan
return unless pages_submodule_installed?
invoke :write_version_files
invoke :build_distribution
invoke :build_standalone_distribution
invoke :build_github_pages
end
end

View File

@@ -1,32 +0,0 @@
class JasmineDev < Thor
JASMINE_SOURCES = {
:core => [
"base.js",
"util.js",
"Env.js",
"Reporter.js",
"Block.js",
"JsApiReporter.js",
"Matchers.js",
"mock-timeout.js",
"MultiReporter.js",
"NestedResults.js",
"PrettyPrinter.js",
"Queue.js",
"Runner.js",
"Spec.js",
"Suite.js",
"WaitsBlock.js",
"WaitsForBlock.js"
],
:html => [
"HtmlReporterHelpers.js",
"HtmlReporter.js",
"ReporterView.js",
"SpecView.js",
"SuiteView.js",
"TrivialReporter.js"
]
}
end

View File

@@ -1,62 +0,0 @@
class JasmineDev < Thor
desc "write_version_files", "Write out version files"
def write_version_files
say JasmineDev.spacer
say "Building version files", :cyan
scope = OpenStruct.new(:major => version_object["major"],
:minor => version_object["minor"],
:build => version_object["build"],
:release_candidate => version_object["release_candidate"],
:revision => Time.now.to_i)
js_template = Tilt.new(File.join(JasmineDev.project_root, 'src', 'templates', 'version.js.erb'))
create_file File.join(JasmineDev.project_root, 'src', 'version.js'), :force => true do
js_template.render(scope)
end
rb_template = Tilt.new(File.join(JasmineDev.project_root, 'src', 'templates', 'version.rb.erb'))
create_file File.join(JasmineDev.project_root, 'lib', 'jasmine-core', 'version.rb'), :force => true do
rb_template.render(scope)
end
end
desc "display_version", "Display version currently stored in source"
def display_version
say "Current version information from src/version.json", :cyan
say "Display version: "
say "#{version_string}", :yellow
say "Version object: "
say "#{version_object_old}", :yellow
end
no_tasks do
def version
@version ||= File.read(File.join(JasmineDev.project_root, 'src', 'version.json'))
end
def version_string
display = "#{version_object['major']}.#{version_object['minor']}.#{version_object['build']}"
display += ".rc#{version_object['release_candidate']}" if version_object['release_candidate']
display
end
def version_object
@version_object ||= JSON.parse(version)
end
def version_object_old
version.gsub("\n", " ").
gsub(/\s+/, " ").
gsub(/\}\s+$/, "}")
end
end
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