diff --git a/Contribute.markdown b/Contribute.markdown index 8c0ffd18..a0491368 100644 --- a/Contribute.markdown +++ b/Contribute.markdown @@ -4,6 +4,36 @@ We welcome your contributions - Thanks for helping make Jasmine a better project for everyone. Please review the backlog and discussion lists (the main group - [http://groups.google.com/group/jasmine-js](http://groups.google.com/group/jasmine-js) and the developer's list - [http://groups.google.com/group/jasmine-js-dev](http://groups.google.com/group/jasmine-js-dev)) before starting work - what you're looking for may already have been done. If it hasn't, the community can help make your contribution better. +## General Workflow + +Please submit pull requests via feature branches using the semi-standard workflow of: + +1. Fork it +1. Create your feature branch (`git checkout -b my-new-feature`) +1. Commit your changes (`git commit -am 'Add some feature'`) +1. Push to the branch (`git push origin my-new-feature`) +1. Create new Pull Request + +## Install Dependencies + +Jasmine Core relies on Ruby and Node.js. + +To install the Ruby dependencies, you will need Ruby, Rubygems, and Bundler available. Then: + + $ bundle + +...will install all of the Ruby dependencies. + +To install the Node dependencies, you will need Node.js, Npm, and [Grunt](http://gruntjs.com/) (including the grunt-cli). + + $ npm install --local + +...will install all of the node modules locally. If when you run + + $ grunt + +...you see that JSHint runs your system is ready. + ## How to write new Jasmine code Or, How to make a successful pull request @@ -12,24 +42,29 @@ 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 +* _Write code in the style of the rest of the repo_ - Jasmine should look like a cohesive whole * _Ensure the *entire* test suite is green_ in all the big browsers, Node, and JSHint - your contribution shouldn't break Jasmine for other users Follow these tips and your pull request, patch, or suggestion is much more likely to be integrated. -## Environment - -Ruby, RubyGems and Rake are used in order to script the various file interactions. You will need to run on a system that supports Ruby in order to run Jasmine's specs. - -Node.js is used to run most of the specs (the HTML-independent code) and should be present. Additionally, the JS Hint project scrubs the source code as part of the spec process. - ## Development All source code belongs in `src/`. The `core/` directory contains the bulk of Jasmine's functionality. This code should remain browser- and environment-agnostic. If your feature or fix cannot be, as mentioned above, please degrade gracefully. Any code that should only be in a non-browser environment should live in `src/console/`. Any code that depends on a browser (specifically, it expects `window` to be the global or `document` is present) should live in `src/html/`. -Please respect the code patterns as possible. For example, using `jasmine.getGlobal()` to get the global object so as to remain environment agnostic. - ## Running Specs +Jasmine uses the Jasmine Ruby gem to test itself in browser. + + $ rake jasmine + +...and then visit `http://localhost:8888` to run specs. + +Jasmine uses a Node + + and uses a custom runner for node. + +Tests in Bro + As in all good projects, the `spec/` directory mirrors `src/` and follows the same rules. The browser runner will include and attempt to run all specs. The node runner will exclude any html-dependent specs (those in `spec/html/`). You will notice that all specs are run against the built `jasmine.js` instead of the component source files. This is intentional as a way to ensure that the concatenation code is working correctly. diff --git a/Gruntfile.js b/Gruntfile.js index cf27b91f..1dc6824d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -17,18 +17,24 @@ module.exports = function(grunt) { grunt.registerTask('default', ['jshint:all']); + var version = require('./grunt/tasks/version.js'); + var standaloneBuilder = require('./grunt/tasks/build_standalone.js'); + + grunt.registerTask('build:copyVersionToGem', + "Propagates the version from package.json to version.rb", + version.copyToGem); + grunt.registerTask('buildDistribution', 'Builds and lints jasmine.js, jasmine-html.js, jasmine.css', [ 'compass', 'jshint:beforeConcat', 'concat', - 'jshint:afterConcat' + 'jshint:afterConcat', + 'build:copyVersionToGem' ] ); - var standaloneBuilder = require('./grunt/tasks/build_standalone.js'); - grunt.registerTask("build:compileSpecRunner", "Processes the spec runner template and writes to a tmp file", standaloneBuilder.compileSpecRunner @@ -47,4 +53,12 @@ module.exports = function(grunt) { "build:cleanSpecRunner" ] ); + + var spec = require('./grunt/tasks/spec.js'); + + grunt.registerTask("execSpecsInNode", + "Run Jasmine core specs in Node.js", + spec.execSpecsInNode + ); + }; \ No newline at end of file diff --git a/README.markdown b/README.markdown index 04a899b3..3953cb0c 100644 --- a/README.markdown +++ b/README.markdown @@ -7,11 +7,9 @@ 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/) -# DEV GUIDE +## Contributing -Dependencies for this repo -* Ruby > 1.9, Rubygems, Bundler -* Node.js, npm +Please read the [contributors' guide](https://github.com/pivotal/jasmine/blob/master/Contribute.markdown) ## Support @@ -20,11 +18,10 @@ Dependencies for this repo * 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) - ## Maintainers * [Davis W. Frank](mailto:dwfrank@pivotallabs.com), Pivotal Labs * [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-2013 Pivotal Labs. This software is licensed under the MIT License. diff --git a/Rakefile b/Rakefile index 98621037..19072dbf 100644 --- a/Rakefile +++ b/Rakefile @@ -1,49 +1,12 @@ require "bundler" Bundler::GemHelper.install_tasks require "json" -require "tilt" require "jasmine" 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 :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 -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" -end - # TODO: Is there better way to invoke this using Jasmine gem??? task :core_spec do exec "ruby spec/jasmine_self_test_spec.rb" @@ -74,5 +37,3 @@ end desc "Run specs via server" task :jasmine => ['jasmine:server'] - - diff --git a/dist/jasmine-standalone-2.0.0-alpha.zip b/dist/jasmine-standalone-2.0.0-alpha.zip new file mode 100644 index 00000000..0df49dc7 Binary files /dev/null and b/dist/jasmine-standalone-2.0.0-alpha.zip differ diff --git a/grunt/config/compress.js b/grunt/config/compress.js index 8c02cdda..eb7db650 100644 --- a/grunt/config/compress.js +++ b/grunt/config/compress.js @@ -29,7 +29,7 @@ module.exports = { cwd: lib("") }, { - src: [ "boot.js"], + src: [ "boot.js" ], dest: standaloneLibDir, expand: true, cwd: lib("boot") diff --git a/grunt/config/concat.js b/grunt/config/concat.js index a8b9ae2f..b86e4196 100644 --- a/grunt/config/concat.js +++ b/grunt/config/concat.js @@ -1,3 +1,13 @@ +var grunt = require('grunt'); + +function license() { + var currentYear = "" + new Date(Date.now()).getFullYear(); + + return grunt.template.process( + grunt.file.read("grunt/templates/licenseBanner.js.jst"), + { data: { currentYear: currentYear}}); +} + module.exports = { 'jasmine-html': { src: [ @@ -23,7 +33,12 @@ module.exports = { ], dest: 'lib/jasmine-core/jasmine.js' }, + boot: { + src: ['lib/jasmine-core/boot/boot.js'], + dest: 'lib/jasmine-core/boot.js' + }, options: { + banner: license(), process: { data: { version: global.jasmineVersion diff --git a/grunt/tasks/build_standalone.js b/grunt/tasks/build_standalone.js index 285b57b6..84482b8d 100644 --- a/grunt/tasks/build_standalone.js +++ b/grunt/tasks/build_standalone.js @@ -1,14 +1,14 @@ var grunt = require("grunt"); -var _ = require("underscore"); function standaloneTmpDir(path) { return "dist/tmp/" + path; } module.exports = { compileSpecRunner: function() { - var runnerTemplate = _.template(grunt.file.read("lib/templates/SpecRunner.html.jst")), - runner = runnerTemplate({ jasmineVersion: global.jasmineVersion }); + var runnerHtml = grunt.template.process( + grunt.file.read("grunt/templates/SpecRunner.html.jst"), + { data: { jasmineVersion: global.jasmineVersion }}); - grunt.file.write(standaloneTmpDir("SpecRunner.html"), runner); + grunt.file.write(standaloneTmpDir("SpecRunner.html"), runnerHtml); }, cleanSpecRunner: function() { diff --git a/grunt/tasks/spec.js b/grunt/tasks/spec.js new file mode 100644 index 00000000..ceb49465 --- /dev/null +++ b/grunt/tasks/spec.js @@ -0,0 +1,7 @@ +var shell = require('shelljs'); + +module.exports = { + execSpecsInNode: function() { + shell.exec("node spec/node_suite.js --color=true") + } +}; \ No newline at end of file diff --git a/grunt/tasks/version.js b/grunt/tasks/version.js new file mode 100644 index 00000000..f8ff6a10 --- /dev/null +++ b/grunt/tasks/version.js @@ -0,0 +1,14 @@ +var grunt = require("grunt"); + +function gemLib(path) { return './lib/jasmine-core/' + path; } +function nodeToRuby(version) { return version.replace('-', '.'); } + +module.exports = { + copyToGem: function() { + var versionRb = grunt.template.process( + grunt.file.read("grunt/templates/version.rb.jst"), + { data: { jasmineVersion: nodeToRuby(global.jasmineVersion) }}); + + grunt.file.write(gemLib("version.rb"), versionRb); + } +}; diff --git a/lib/templates/SpecRunner.html.jst b/grunt/templates/SpecRunner.html.jst similarity index 100% rename from lib/templates/SpecRunner.html.jst rename to grunt/templates/SpecRunner.html.jst diff --git a/grunt/templates/licenseBanner.js.jst b/grunt/templates/licenseBanner.js.jst new file mode 100644 index 00000000..2b28f223 --- /dev/null +++ b/grunt/templates/licenseBanner.js.jst @@ -0,0 +1,22 @@ +/* +Copyright (c) 2008-<%= currentYear %> Pivotal Labs + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ diff --git a/grunt/templates/version.rb.jst b/grunt/templates/version.rb.jst new file mode 100644 index 00000000..411403c2 --- /dev/null +++ b/grunt/templates/version.rb.jst @@ -0,0 +1,9 @@ +# +# DO NOT Edit this file. Canonical version of Jasmine lives in the repo's package.json. This file is generated +# by a grunt task when the standalone release is built. +# +module Jasmine + module Core + VERSION = "<%= jasmineVersion %>" + end +end diff --git a/jasmine-core.gemspec b/jasmine-core.gemspec index 7f4711e3..2a63cde4 100644 --- a/jasmine-core.gemspec +++ b/jasmine-core.gemspec @@ -17,16 +17,11 @@ Gem::Specification.new do |s| s.files = Dir.glob("./lib/**/*") + Dir.glob("./lib/jasmine-core/spec/**/*.js") s.require_paths = ["lib"] 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 "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 diff --git a/jasmine_dev.thor b/jasmine_dev.thor deleted file mode 100644 index 7fe0ca71..00000000 --- a/jasmine_dev.thor +++ /dev/null @@ -1 +0,0 @@ -require "#{File.expand_path(File.dirname(__FILE__))}/tasks/jasmine_dev" \ No newline at end of file diff --git a/lib/jasmine-core/boot.js b/lib/jasmine-core/boot.js new file mode 100644 index 00000000..c8977021 --- /dev/null +++ b/lib/jasmine-core/boot.js @@ -0,0 +1,126 @@ +/* +Copyright (c) 2008-2013 Pivotal Labs + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +// Jasmine boot.js for browser runners - exposes external/global interface, builds the Jasmine environment and executes it. +(function() { + var env = jasmine.getEnv(); + + var jasmineInterface = { + describe: function(description, specDefinitions) { + return env.describe(description, specDefinitions); + }, + + xdescribe: function(description, specDefinitions) { + return env.xdescribe(description, specDefinitions); + }, + + it: function(desc, func) { + return env.it(desc, func); + }, + + xit: function(desc, func) { + return env.xit(desc, func); + }, + + beforeEach: function(beforeEachFunction) { + return env.beforeEach(beforeEachFunction); + }, + + afterEach: function(afterEachFunction) { + return env.afterEach(afterEachFunction); + }, + + expect: function(actual) { + return env.expect(actual); + }, + + pending: function() { + return env.pending(); + }, + + addMatchers: function(matchers) { + return env.addMatchers(matchers); + }, + + spyOn: function(obj, methodName) { + return env.spyOn(obj, methodName); + }, + + clock: env.clock, + setTimeout: env.clock.setTimeout, + clearTimeout: env.clock.clearTimeout, + setInterval: env.clock.setInterval, + clearInterval: env.clock.clearInterval, + + jsApiReporter: new jasmine.JsApiReporter(jasmine) + }; + + if (typeof window == "undefined" && typeof exports == "object") { + extend(exports, jasmineInterface); + } else { + extend(window, jasmineInterface); + } + + var queryString = new jasmine.QueryString({ + getWindowLocation: function() { return window.location; } + }); + + // TODO: move all of catching to raise so we don't break our brains + var catchingExceptions = queryString.getParam("catch"); + env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions); + + var htmlReporter = new jasmine.HtmlReporter({ + env: env, + queryString: queryString, + onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); }, + getContainer: function() { return document.body; }, + createElement: function() { return document.createElement.apply(document, arguments); }, + createTextNode: function() { return document.createTextNode.apply(document, arguments); } + }); + + env.addReporter(jasmineInterface.jsApiReporter); + env.addReporter(htmlReporter); + + var specFilter = new jasmine.HtmlSpecFilter({ + filterString: function() { return queryString.getParam("spec"); } + }); + + env.specFilter = function(spec) { + return specFilter.matches(spec.getFullName()); + }; + + var currentWindowOnload = window.onload; + + window.onload = function() { + if (currentWindowOnload) { + currentWindowOnload(); + } + htmlReporter.initialize(); + env.execute(); + }; + + function extend(destination, source) { + for (var property in source) destination[property] = source[property]; + return destination; + } + +}()); diff --git a/lib/jasmine-core/boot/boot.js b/lib/jasmine-core/boot/boot.js index aa29f812..aea8e00c 100644 --- a/lib/jasmine-core/boot/boot.js +++ b/lib/jasmine-core/boot/boot.js @@ -1,3 +1,4 @@ +// Jasmine boot.js for browser runners - exposes external/global interface, builds the Jasmine environment and executes it. (function() { var env = jasmine.getEnv(); diff --git a/lib/jasmine-core/jasmine-html.js b/lib/jasmine-core/jasmine-html.js index 4f75e167..dcc89137 100644 --- a/lib/jasmine-core/jasmine-html.js +++ b/lib/jasmine-core/jasmine-html.js @@ -1,3 +1,25 @@ +/* +Copyright (c) 2008-2013 Pivotal Labs + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ jasmine.HtmlReporter = function(options) { var env = options.env || {}, getContainer = options.getContainer, diff --git a/lib/jasmine-core/jasmine.js b/lib/jasmine-core/jasmine.js index 622dc452..32c580e9 100644 --- a/lib/jasmine-core/jasmine.js +++ b/lib/jasmine-core/jasmine.js @@ -1,3 +1,25 @@ +/* +Copyright (c) 2008-2013 Pivotal Labs + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ /** * Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework. @@ -372,22 +394,9 @@ jasmine.createSpyObj = function(baseName, methodNames) { return obj; }; -/** - * @namespace - */ jasmine.util = {}; -/** - * Declare that a child class inherit it's prototype from the parent class. - * - * @private - * @param {Function} childClass - * @param {Function} parentClass - */ jasmine.util.inherit = function(childClass, parentClass) { - /** - * @private - */ var subclass = function() { }; subclass.prototype = parentClass.prototype; diff --git a/lib/jasmine-core/version.rb b/lib/jasmine-core/version.rb index 2dafd0eb..e9afa67a 100644 --- a/lib/jasmine-core/version.rb +++ b/lib/jasmine-core/version.rb @@ -1,6 +1,9 @@ +# +# DO NOT Edit this file. Canonical version of Jasmine lives in the repo's package.json. This file is generated +# by a grunt task when the standalone release is built. +# module Jasmine module Core - VERSION = "1.3.1" + VERSION = "2.0.0.alpha" end end - diff --git a/package.json b/package.json index b350cd47..cfd29227 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,11 @@ "license": "MIT", "version": "2.0.0-alpha", "devDependencies": { + "grunt": "~0.4.1", "grunt-contrib-jshint": "~0.2.0", "grunt-contrib-concat": "~0.1.3", "grunt-contrib-compass": "~0.1.3", "grunt-contrib-compress": "~0.4.1", - "underscore": "~1.4.4" + "shelljs": "~0.1.2" } } diff --git a/spec/runner.html b/spec/runner.html deleted file mode 100644 index ef77db8d..00000000 --- a/spec/runner.html +++ /dev/null @@ -1,50 +0,0 @@ - -
-