├── .gitignore ├── .travis.yml ├── Gemfile ├── MIT-LICENSE ├── README.md ├── Rakefile ├── app ├── assets │ ├── javascripts │ │ ├── jasmine │ │ │ └── boot.js │ │ └── test_squad │ │ │ ├── jasmine-phantom.js │ │ │ ├── mocha-reporter.js │ │ │ └── qunit-phantom.js │ └── stylesheets │ │ └── test_squad │ │ └── ember.css ├── controllers │ └── test_squad_controller.rb └── views │ └── test_squad │ ├── ember.html.erb │ ├── jasmine.html.erb │ ├── mocha.html.erb │ └── qunit.html.erb ├── config └── routes.rb ├── gemfiles ├── rails_4.2.6.gemfile └── rails_5.0.0.gemfile ├── lib ├── generators │ └── test_squad │ │ └── install │ │ ├── USAGE │ │ ├── install_generator.rb │ │ └── templates │ │ ├── ember │ │ ├── router_test.js │ │ └── test_helper.js.erb │ │ ├── jasmine │ │ ├── answer_spec.js │ │ └── spec_helper.js.erb │ │ ├── mocha │ │ ├── answer_spec.js │ │ └── spec_helper.js.erb │ │ ├── qunit │ │ ├── answer_test.js │ │ └── test_helper.js.erb │ │ └── test_squad.rb.erb ├── tasks │ └── test_squad_tasks.rake ├── test_squad.rb └── test_squad │ ├── configuration.rb │ ├── engine.rb │ ├── runner.rb │ └── version.rb ├── phantomjs ├── helpers.js └── runner.js ├── screenshots ├── jasmine.png ├── mocha.png ├── qunit.png ├── terminal-ember.png └── terminal.png ├── test ├── controllers │ └── test_squad_controller_test.rb ├── lib │ ├── generators │ │ └── test_squad │ │ │ ├── install_generator │ │ │ ├── ember_test.rb │ │ │ ├── jasmine_test.rb │ │ │ ├── mocha_test.rb │ │ │ └── qunit_test.rb │ │ │ └── install_generator_test.rb │ └── test_squad │ │ ├── configuration_test.rb │ │ └── runner_test.rb ├── support │ └── app.rb ├── test_helper.rb └── test_squad_test.rb ├── test_squad.gemspec └── vendor └── assets └── libs └── jasmine ├── boot.js ├── console.js ├── jasmine-html.js ├── jasmine.css ├── jasmine.js └── jasmine_favicon.png /.gitignore: -------------------------------------------------------------------------------- 1 | .bundle/ 2 | log/*.log 3 | pkg/ 4 | test/dummy/db/*.sqlite3 5 | test/dummy/db/*.sqlite3-journal 6 | test/dummy/log/*.log 7 | test/dummy/tmp/ 8 | test/dummy/.sass-cache 9 | coverage 10 | *.lock 11 | tmp 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | cache: bundler 3 | sudo: false 4 | gemfile: 5 | - gemfiles/rails_5.0.0.gemfile 6 | - gemfiles/rails_4.2.6.gemfile 7 | notifications: 8 | email: false 9 | rvm: 10 | - '2.2.5' 11 | - '2.3.1' 12 | addons: 13 | code_climate: 14 | repo_token: 15 | secure: KXqFGWlQlIeoVgySE7gUxXgXMcbJkd6/ckX4Achq3mjCk7WDBPe9ZcObjz89QLoa14bUBnyJpJBXG+KcDlQkZpERfIShiub9OoWejr172/59HThqFJ7j4Xidpt366icUkEAEa53cZhCZl1mgSlaIJy7277LDENWICyeme8fZoT0= 16 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | gemspec 3 | 4 | gem "rails-controller-testing" 5 | -------------------------------------------------------------------------------- /MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2015 Nando Vieira 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TestSquad 2 | 3 | [![Travis-CI](https://travis-ci.org/fnando/test_squad.png)](https://travis-ci.org/fnando/test_squad) 4 | [![Code Climate](https://codeclimate.com/github/fnando/test_squad/badges/gpa.svg)](https://codeclimate.com/github/fnando/test_squad) 5 | [![Test Coverage](https://codeclimate.com/github/fnando/test_squad/badges/coverage.svg)](https://codeclimate.com/github/fnando/test_squad/coverage) 6 | [![Gem](https://img.shields.io/gem/v/test_squad.svg)](https://rubygems.org/gems/test_squad) 7 | [![Gem](https://img.shields.io/gem/dt/test_squad.svg)](https://rubygems.org/gems/test_squad) 8 | 9 | Running JavaScript tests on your Rails app, the easy way. 10 | 11 | - Supports [QUnit](http://qunitjs.com), [Ember.js](http://emberjs.com), [Mocha](http://mochajs.org) and [Jasmine](http://jasmine.github.io/) 12 | - Go headless with [Phantom.js](http://phantomjs.org) 13 | - Colored output 14 | - Asset pipeline support 15 | - [Rails Assets](http://rails-assets.org) support (Bower Proxy) 16 | 17 | ## Installation 18 | 19 | Add these lines to your application's `Gemfile`: 20 | 21 | ```ruby 22 | group :development, :test do 23 | gem "test_squad" 24 | end 25 | ``` 26 | 27 | And then execute: 28 | 29 | ```console 30 | $ bundle 31 | ``` 32 | 33 | ## Usage 34 | 35 | After installing TestSquad, generate your tests skeleton. The generator will detect if you're using RSpec or TestUnit and will generate the `javascript` directory based on that detection. Just use the command `rails generate test_squad:install --framework FRAMEWORK`. 36 | 37 | ```console 38 | $ rails generate test_squad:install --framework jasmine 39 | create test/javascript/squad_sample 40 | create test/javascript/squad_sample/.keep 41 | create test/javascript/spec_helper.js 42 | source https://rails-assets.org 43 | exist test/javascript 44 | create test/javascript/test_squad.rb 45 | ``` 46 | 47 | If you're already using , you can skip the Gemfile entry with `--skip-source`. 48 | 49 | ## Running tests 50 | 51 | You can run your tests with `rake test_squad`. You can also visit `http://localhost:3000/tests` for in-browser testing. 52 | 53 | ![Jasmine](https://github.com/fnando/test_squad/raw/master/screenshots/jasmine.png) 54 | 55 | ![Mocha](https://github.com/fnando/test_squad/raw/master/screenshots/mocha.png) 56 | 57 | ![QUnit](https://github.com/fnando/test_squad/raw/master/screenshots/qunit.png) 58 | 59 | ![Terminal](https://github.com/fnando/test_squad/raw/master/screenshots/terminal.png) 60 | 61 | ![Ember](https://github.com/fnando/test_squad/raw/master/screenshots/terminal-ember.png) 62 | 63 | ### Configure Ember 64 | 65 | When using the Ember framework, you must configure your application name. It'll default to your Rails application name. 66 | 67 | ```javascript 68 | //= require application 69 | //= require_self 70 | //= require_tree ./components 71 | //= require_tree ./models 72 | //= require_tree ./routes 73 | //= require_tree ./unit 74 | //= require_tree ./views 75 | 76 | // Set the application. 77 | App = SquadSample; 78 | 79 | // Set up Ember testing. 80 | App.rootElement = "#ember-testing"; 81 | App.setupForTesting(); 82 | App.injectTestHelpers(); 83 | ``` 84 | 85 | To disable all Ember logging, add the following line to `test_helper.js`, just before the `//= require application` line. 86 | 87 | ```javascript 88 | //= require ./logging 89 | ``` 90 | 91 | Then create the file `spec/javascript/logging.js` with this content: 92 | 93 | ```javascript 94 | Ember = {ENV: { 95 | LOG_TRANSITIONS: false, 96 | LOG_VIEW_LOOKUPS: false, 97 | LOG_ACTIVE_GENERATION: false, 98 | LOG_RESOLVER: false, 99 | LOG_TRANSITIONS: false, 100 | LOG_TRANSITIONS_INTERNAL: false, 101 | LOG_VERSION: false 102 | }}; 103 | ``` 104 | 105 | ### Configure Mocha 106 | 107 | By default, Mocha is configured with [expect.js](https://github.com/Automattic/expect.js). You can use different libraries like [should.js](https://github.com/visionmedia/should.js) or [chai](http://chaijs.com/). 108 | 109 | Just add the dependency to your `Gemfile`. Use `rails-assets-chai` or `rails-assets-should`: 110 | 111 | ```ruby 112 | source "https://rubygems.org" 113 | source "https://rails-assets.org" 114 | 115 | gem "rails", "4.2.0" 116 | gem "sass-rails", "~> 5.0" 117 | gem "uglifier", ">= 1.3.0" 118 | 119 | gem "ember-rails" 120 | gem "rails-assets-jquery" 121 | 122 | group :development, :test do 123 | gem "test_squad", path: "../../test_squad" 124 | gem "rails-assets-mocha" 125 | gem "rails-assets-chai" 126 | end 127 | ``` 128 | 129 | Install the dependency with `bundle install`. Then require the library on `{test/spec}/javascript/spec_helper.js`. 130 | 131 | ```javascript 132 | //= require application 133 | //= require chai 134 | //= require_self 135 | //= require_tree ./squad_sample 136 | 137 | var assert = chai.assert; 138 | 139 | mocha.setup("bdd"); 140 | mocha.checkLeaks(); 141 | mocha.globals(["jQuery"]); 142 | mocha.reporter(mocha.TestSquad); 143 | window.onload = function(){ 144 | mocha.run(); 145 | }; 146 | ``` 147 | 148 | ## Troubleshooting 149 | 150 | ### Route is not available 151 | 152 | If you have a catch-all route, add the following line to your `config/routes.rb` file. This will be required if you configure Ember.js to use `history.pushState`. 153 | 154 | ```ruby 155 | get :tests, to: "test_squad#tests" unless Rails.env.production? 156 | ``` 157 | 158 | Otherwise you won't be able to to run your in-browser tests. 159 | 160 | ### Using NPM/Bower instead of rails-assets 161 | 162 | You may want to use something else (NPM, Bower directly, etc). In this case, the easiest way is adding QUnit's directory to the load path. 163 | 164 | Let's configure QUnit from NPM. Create the file `package.json` like the following: 165 | 166 | ```json 167 | { 168 | "name": "myapp", 169 | "version": "0.0.0", 170 | "private": true 171 | } 172 | ``` 173 | 174 | Run the command `npm install qunitjs --save-dev` to install QUnit. The library will be available at `node_modules/qunitjs/qunit`. Now modify `config/initializers/assets.rb`, adding this directory to the load path. 175 | 176 | ```ruby 177 | # ... 178 | 179 | if Rails.env.development? 180 | Rails.application.config.assets << Rails.root.join("node_modules/qunitjs/qunit").to_s 181 | end 182 | ``` 183 | 184 | That's it! 185 | 186 | ## Configuration 187 | 188 | The rake task accepts some env variables. 189 | 190 | - `TEST_SQUAD_SERVER_HOST`: the binding host. Defaults to `localhost`. 191 | - `TEST_SQUAD_SERVER_PORT`: the server port. Defaults to `42424`. 192 | - `TEST_SQUAD_SERVER_PATH`: the server path. Defaults to `/tests`. 193 | - `TEST_SQUAD_TIMEOUT`: how much time a test can take. Defaults to `10` (seconds). 194 | - `TEST_SQUAD_PHANTOMJS_BIN`: set the PhantomJS binary. Defaults to `phantomjs`. 195 | 196 | You can configure these options using the `{test,spec}/javascript/test_squad.rb` file. 197 | 198 | ```ruby 199 | TestSquad.configure do |config| 200 | config.framework = "qunit" 201 | config.server_host = "127.0.0.1" 202 | config.server_port = 42424 203 | config.server_path = "/tests" 204 | config.timeout = 10 205 | config.phantomjs_bin = "phantomjs" 206 | end 207 | ``` 208 | 209 | ## Contributing 210 | 211 | Before starting, create an issue asking if it'd be a useful/wanted feature. This will avoid wasting your time. 212 | 213 | 1. Fork it ( http://github.com/fnando/test_squad/fork ) 214 | 2. Create your feature branch (`git checkout -b my-new-feature`) 215 | 3. Commit your changes (`git commit -am 'Add some feature'`) 216 | 4. Push to the branch (`git push origin my-new-feature`) 217 | 5. Create new Pull Request 218 | 219 | Remember: 220 | 221 | - Don't mess with versioning. 222 | - Follow the code style already present. 223 | - Opening an issue asking if your feature/change will be merged it's recommended, so that you don't waste your time. 224 | 225 | ## License 226 | 227 | (The MIT License) 228 | 229 | Permission is hereby granted, free of charge, to any person obtaining 230 | a copy of this software and associated documentation files (the 231 | 'Software'), to deal in the Software without restriction, including 232 | without limitation the rights to use, copy, modify, merge, publish, 233 | distribute, sublicense, and/or sell copies of the Software, and to 234 | permit persons to whom the Software is furnished to do so, subject to 235 | the following conditions: 236 | 237 | The above copyright notice and this permission notice shall be 238 | included in all copies or substantial portions of the Software. 239 | 240 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 241 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 242 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 243 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 244 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 245 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 246 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 247 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rake/testtask" 3 | 4 | Rake::TestTask.new(:test) do |t| 5 | t.libs << "test" 6 | t.test_files = FileList["test/**/*_test.rb"] 7 | t.warning = false 8 | end 9 | 10 | task default: :test 11 | -------------------------------------------------------------------------------- /app/assets/javascripts/jasmine/boot.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | window.jasmine = jasmineRequire.core(jasmineRequire); 3 | jasmineRequire.html(jasmine); 4 | jasmineRequire.phantom(jasmine); 5 | var env = jasmine.getEnv(); 6 | var jasmineInterface = jasmineRequire.interface(jasmine, env); 7 | 8 | if (typeof window == "undefined" && typeof exports == "object") { 9 | extend(exports, jasmineInterface); 10 | } else { 11 | extend(window, jasmineInterface); 12 | } 13 | 14 | var queryString = new jasmine.QueryString({ 15 | getWindowLocation: function() { return window.location; } 16 | }); 17 | 18 | var catchingExceptions = queryString.getParam("catch"); 19 | env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions); 20 | 21 | var htmlReporter = new jasmine.HtmlReporter({ 22 | env: env, 23 | onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); }, 24 | getContainer: function() { return document.body; }, 25 | createElement: function() { return document.createElement.apply(document, arguments); }, 26 | createTextNode: function() { return document.createTextNode.apply(document, arguments); }, 27 | timer: new jasmine.Timer() 28 | }); 29 | 30 | var phantomReporter = new jasmine.PhantomReporter({ 31 | env: env, 32 | onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); }, 33 | timer: new jasmine.Timer() 34 | }); 35 | 36 | env.addReporter(jasmineInterface.jsApiReporter); 37 | env.addReporter(htmlReporter); 38 | env.addReporter(phantomReporter); 39 | 40 | var specFilter = new jasmine.HtmlSpecFilter({ 41 | filterString: function() { return queryString.getParam("spec"); } 42 | }); 43 | 44 | env.specFilter = function(spec) { 45 | return specFilter.matches(spec.getFullName()); 46 | }; 47 | 48 | window.setTimeout = window.setTimeout; 49 | window.setInterval = window.setInterval; 50 | window.clearTimeout = window.clearTimeout; 51 | window.clearInterval = window.clearInterval; 52 | 53 | var currentWindowOnload = window.onload; 54 | 55 | window.onload = function() { 56 | if (currentWindowOnload) { 57 | currentWindowOnload(); 58 | } 59 | htmlReporter.initialize(); 60 | env.execute(); 61 | }; 62 | 63 | function extend(destination, source) { 64 | for (var property in source) destination[property] = source[property]; 65 | return destination; 66 | } 67 | }()); 68 | -------------------------------------------------------------------------------- /app/assets/javascripts/test_squad/jasmine-phantom.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | jasmineRequire.phantom = function(j$) { 3 | if (!navigator.userAgent.match(/phantomjs/i)) { 4 | j$.PhantomReporter = function() { /* noop */ }; 5 | } else { 6 | j$.PhantomReporter = jasmineRequire.PhantomReporter(); 7 | } 8 | }; 9 | 10 | jasmineRequire.PhantomReporter = function() { 11 | function PhantomReporter(options) { 12 | var stats = { 13 | passes: 0, 14 | fails: 0, 15 | pending: 0, 16 | elapsed: 0, 17 | assertions: 0, 18 | tests: 0 19 | }; 20 | 21 | var start; 22 | 23 | this.jasmineStarted = function() { 24 | start = new Date().getTime(); 25 | }; 26 | 27 | this.jasmineDone = function() { 28 | stats.elapsed = new Date().getTime() - start; 29 | 30 | callPhantom({ 31 | name: "end", 32 | stats: stats 33 | }); 34 | }; 35 | 36 | this.specStarted = function(result) { 37 | stats.tests += 1; 38 | 39 | callPhantom({ 40 | name: "test start", 41 | title: result.description 42 | }); 43 | }; 44 | 45 | this.specDone = function(result) { 46 | var pending = result.status === "pending"; 47 | var passed = result.status === "passed"; 48 | var failed = result.status === "failed"; 49 | var error, assertion; 50 | 51 | stats.assertions += result.failedExpectations.length; 52 | stats.assertions += result.passedExpectations.length; 53 | stats.pending += (pending ? 1 : 0); 54 | stats.passes += (passed ? 1 : 0); 55 | stats.fails += (failed ? 1 : 0); 56 | 57 | if (failed) { 58 | assertion = result.failedExpectations[0]; 59 | error = assertion.stack.replace(/^\s*/gm, " "); 60 | error = error.replace(/^\s+at .*?assets\/jasmine\/(jasmine|boot).*?\.js.*?$/mg, ""); 61 | error = error.replace(/\n+$/, ""); 62 | } 63 | 64 | callPhantom({ 65 | name: "test end", 66 | title: result.description, 67 | passed: passed, 68 | pending: pending, 69 | failure: error 70 | }); 71 | }; 72 | 73 | this.suiteStarted = function(result) { 74 | callPhantom({ 75 | name: "suite start", 76 | title: result.description 77 | }); 78 | }; 79 | 80 | return this; 81 | } 82 | 83 | return PhantomReporter; 84 | }; 85 | })(); 86 | -------------------------------------------------------------------------------- /app/assets/javascripts/test_squad/mocha-reporter.js: -------------------------------------------------------------------------------- 1 | Mocha.reporters.PhantomJS = function(runner) { 2 | if (!navigator.userAgent.match(/phantomjs/i)) { 3 | return; 4 | } 5 | 6 | var stats = { 7 | passes: 0, 8 | fails: 0, 9 | pending: 0, 10 | elapsed: 0, 11 | assertions: 0, 12 | tests: 0 13 | }; 14 | 15 | var start; 16 | 17 | runner.on("pass", function(test){ 18 | stats.passes += 1; 19 | }); 20 | 21 | runner.on("fail", function(test, err){ 22 | stats.fails += 1; 23 | }); 24 | 25 | runner.on("pending", function(suite){ 26 | stats.pending += 1; 27 | }); 28 | 29 | runner.on("start", function(test){ 30 | start = new Date().getTime(); 31 | }); 32 | 33 | runner.on("end", function(){ 34 | stats.elapsed = new Date().getTime() - start; 35 | callPhantom({ 36 | name: "end", 37 | stats: stats 38 | }); 39 | }); 40 | 41 | runner.on("test", function(test){ 42 | stats.tests += 1; 43 | 44 | callPhantom({ 45 | name: "test start", 46 | title: test.title 47 | }); 48 | }); 49 | 50 | runner.on("test end", function(test){ 51 | if (test.state === "failed") { 52 | var error = test.err.stack || test.err.toString(); 53 | 54 | // FF / Opera do not add the message 55 | if (!~error.indexOf(test.err.message)) { 56 | error = test.err.message + "\n" + error; 57 | } 58 | 59 | // <=IE7 stringifies to [Object Error]. Since it can be overloaded, we 60 | // check for the result of the stringifying. 61 | if ("[object Error]" == error) { 62 | error = test.err.message; 63 | } 64 | 65 | // Safari doesn"t give you a stack. Let"s at least provide a source line. 66 | if (!test.err.stack && test.err.sourceURL && test.err.line !== undefined) { 67 | error += "\n(" + test.err.sourceURL + ":" + test.err.line + ")"; 68 | } 69 | 70 | error = error.replace(/^\s+at .*?assets\/mocha\/.*?\.js.*?$/mg, ""); 71 | error = error.replace(/^\s+at .*?assets\/expect\/.*?\.js.*?$/mg, ""); 72 | error = error.replace(/^\s+at .*?assets\/should\/.*?\.js.*?$/mg, ""); 73 | error = error.replace(/^\s+at .*?assets\/chai\/.*?\.js.*?$/mg, ""); 74 | error = error.replace(/\n+$/, ""); 75 | } 76 | 77 | callPhantom({ 78 | name: "test end", 79 | title: test.title, 80 | passed: test.state === "passed", 81 | pending: test.pending, 82 | failure: error 83 | }); 84 | }); 85 | 86 | runner.on("suite", function(suite){ 87 | callPhantom({ 88 | name: "suite start", 89 | title: suite.title 90 | }); 91 | }); 92 | 93 | runner.on("suite end", function(suite){ 94 | callPhantom({ 95 | name: "suite end", 96 | title: suite.title 97 | }); 98 | }); 99 | }; 100 | 101 | mocha.TestSquad = function(runner) { 102 | new Mocha.reporters.HTML(runner); 103 | new Mocha.reporters.PhantomJS(runner); 104 | }; 105 | -------------------------------------------------------------------------------- /app/assets/javascripts/test_squad/qunit-phantom.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | if (!navigator.userAgent.match(/phantomjs/i)) { 3 | return; 4 | } 5 | 6 | var stats = { 7 | passes: 0, 8 | fails: 0, 9 | pending: 0, 10 | elapsed: 0, 11 | assertions: 0, 12 | tests: 0 13 | }; 14 | 15 | var start, assertion; 16 | 17 | QUnit.testStart(function(data){ 18 | assertion = null; 19 | stats.tests += 1; 20 | 21 | callPhantom({ 22 | name: "test start", 23 | title: data.name 24 | }); 25 | }); 26 | 27 | QUnit.log(function(data){ 28 | stats.assertions += 1; 29 | 30 | if (!assertion && !data.result) { 31 | assertion = data; 32 | } 33 | }); 34 | 35 | QUnit.moduleStart(function(data){ 36 | callPhantom({ 37 | name: "suite start", 38 | title: data.name 39 | }); 40 | }); 41 | 42 | QUnit.testDone(function(data){ 43 | var error; 44 | 45 | if (data.failed) { 46 | stats.fails += 1; 47 | error = assertion.message; 48 | 49 | if (assertion.source) { 50 | error += "\n" + assertion.source; 51 | } 52 | 53 | error = error.replace(/(Died on test #\d+)/gmi, "$1\n"); 54 | error = error.replace(/^\s*/gm, " "); 55 | error = error.replace(/^\s+at .*?assets\/qunit\/qunit.*?\.js.*?$/mg, ""); 56 | error = error.replace(/\n+$/, ""); 57 | } else if (data.skipped) { 58 | stats.pending += 1; 59 | } else { 60 | stats.passes += 1; 61 | } 62 | 63 | callPhantom({ 64 | name: "test end", 65 | title: data.name, 66 | passed: data.failed === 0 && !data.skipped, 67 | pending: data.skipped, 68 | failure: error 69 | }); 70 | }); 71 | 72 | QUnit.begin(function(data){ 73 | start = new Date().getTime(); 74 | }); 75 | 76 | QUnit.done(function(data){ 77 | stats.elapsed = new Date().getTime() - start; 78 | 79 | callPhantom({ 80 | name: "end", 81 | stats: stats 82 | }); 83 | }); 84 | })(); 85 | -------------------------------------------------------------------------------- /app/assets/stylesheets/test_squad/ember.css: -------------------------------------------------------------------------------- 1 | #ember-testing-container { 2 | position: absolute; 3 | background: white; 4 | width: 640px; 5 | height: 384px; 6 | overflow: auto; 7 | z-index: 9999; 8 | border: 1px solid #ccc; 9 | right: 50px; 10 | bottom: 50px; 11 | padding: 5px; 12 | } 13 | 14 | #ember-testing { 15 | zoom: 50%; 16 | } 17 | -------------------------------------------------------------------------------- /app/controllers/test_squad_controller.rb: -------------------------------------------------------------------------------- 1 | class TestSquadController < ActionController::Base 2 | def tests 3 | load Rails.root.join(TestSquad.test_directory, "test_squad.rb").to_s 4 | render TestSquad.configuration.framework 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /app/views/test_squad/ember.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Ember: <%= TestSquad.app_class_name %> 6 | <%= stylesheet_link_tag "qunit", "test_squad/ember" %> 7 | 8 | 9 |
10 |
11 |
12 | <%= javascript_include_tag "qunit", "test_squad/qunit-phantom", "test_helper" %> 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/views/test_squad/jasmine.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Jasmine: <%= TestSquad.app_class_name %> 6 | 7 | <%= favicon_link_tag "jasmine/jasmine_favicon.png" %> 8 | <%= stylesheet_link_tag "jasmine/jasmine" %> 9 | <%= javascript_include_tag "jasmine/jasmine", "jasmine/jasmine-html", "test_squad/jasmine-phantom", "jasmine/boot", "spec_helper" %> 10 | 11 | 12 | 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /app/views/test_squad/mocha.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Mocha: <%= TestSquad.app_class_name %> 6 | <%= stylesheet_link_tag "mocha" %> 7 | 8 | 9 |
10 | <%= javascript_include_tag "mocha", "test_squad/mocha-reporter", "spec_helper" %> 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/views/test_squad/qunit.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | QUnit: <%= TestSquad.app_class_name %> 6 | <%= stylesheet_link_tag "qunit" %> 7 | 8 | 9 |
10 |
11 | <%= javascript_include_tag "qunit", "test_squad/qunit-phantom", "test_helper" %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | unless Rails.env.production? 3 | get "tests" => "test_squad#tests", format: false, as: nil 4 | end 5 | end 6 | -------------------------------------------------------------------------------- /gemfiles/rails_4.2.6.gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | gemspec path: ".." 3 | 4 | gem "rails", "~> 4.2.6" 5 | -------------------------------------------------------------------------------- /gemfiles/rails_5.0.0.gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | gemspec path: ".." 3 | 4 | gem "rails", "~> 5.0.0" 5 | gem "rails-controller-testing" 6 | -------------------------------------------------------------------------------- /lib/generators/test_squad/install/USAGE: -------------------------------------------------------------------------------- 1 | Description: 2 | Generates the JavaScript test directory. 3 | 4 | Example: 5 | rails generate squad:install -f qunit 6 | 7 | This will create: 8 | {spec,test}/javascript 9 | -------------------------------------------------------------------------------- /lib/generators/test_squad/install/install_generator.rb: -------------------------------------------------------------------------------- 1 | require "test_squad" 2 | 3 | module TestSquad 4 | class InstallGenerator < Rails::Generators::Base 5 | source_root File.expand_path("../templates", __FILE__) 6 | 7 | SKIP_RAILS_ASSETS = %w[jasmine] 8 | 9 | class_option :framework, 10 | type: "string", 11 | desc: "Select the JavaScript framework. Can be jasmine, qunit, mocha or ember.", 12 | aliases: "-f", 13 | required: true 14 | 15 | class_option :skip_source, 16 | type: "boolean", 17 | desc: "Skip adding gem source to Gemfile", 18 | aliases: "-s" 19 | 20 | def generate 21 | send "generate_#{framework}" 22 | end 23 | 24 | def generate_defaults 25 | empty_directory test_directory 26 | template "test_squad.rb.erb", "#{test_directory}/test_squad.rb" 27 | end 28 | 29 | private 30 | 31 | def framework 32 | options[:framework] 33 | end 34 | 35 | def test_directory 36 | if File.exist?(File.join(destination_root, "spec")) 37 | "spec/javascript" 38 | else 39 | "test/javascript" 40 | end 41 | end 42 | 43 | def app_name 44 | app_class_name.underscore 45 | end 46 | 47 | def app_class_name 48 | TestSquad.app_class_name 49 | end 50 | 51 | def generate_qunit 52 | empty_directory "#{test_directory}/#{app_name}" 53 | create_file "#{test_directory}/#{app_name}/.keep" 54 | template "qunit/test_helper.js.erb", "#{test_directory}/test_helper.js" 55 | copy_file "qunit/answer_test.js", "#{test_directory}/#{app_name}/answer_test.js" 56 | 57 | rails_assets do 58 | gem "rails-assets-qunit" 59 | end unless options[:skip_source] 60 | end 61 | 62 | def generate_jasmine 63 | empty_directory "#{test_directory}/#{app_name}" 64 | create_file "#{test_directory}/#{app_name}/.keep" 65 | template "jasmine/spec_helper.js.erb", "#{test_directory}/spec_helper.js" 66 | copy_file "jasmine/answer_spec.js", "#{test_directory}/#{app_name}/answer_spec.js" 67 | end 68 | 69 | def generate_mocha 70 | empty_directory "#{test_directory}/#{app_name}" 71 | create_file "#{test_directory}/#{app_name}/.keep" 72 | template "mocha/spec_helper.js.erb", "#{test_directory}/spec_helper.js" 73 | copy_file "mocha/answer_spec.js", "#{test_directory}/#{app_name}/answer_spec.js" 74 | 75 | rails_assets do 76 | gem_group :development, :test do 77 | gem "rails-assets-mocha" 78 | gem "rails-assets-expect" 79 | end 80 | end unless options[:skip_source] 81 | end 82 | 83 | def generate_ember 84 | empty_directory "#{test_directory}/unit" 85 | copy_file "ember/router_test.js", "#{test_directory}/unit/router_test.js" 86 | 87 | empty_directory "#{test_directory}/routes" 88 | create_file "#{test_directory}/routes/.keep" 89 | 90 | empty_directory "#{test_directory}/components" 91 | create_file "#{test_directory}/components/.keep" 92 | 93 | empty_directory "#{test_directory}/views" 94 | create_file "#{test_directory}/views/.keep" 95 | 96 | empty_directory "#{test_directory}/models" 97 | create_file "#{test_directory}/models/.keep" 98 | 99 | template "ember/test_helper.js.erb", "#{test_directory}/test_helper.js" 100 | 101 | rails_assets do 102 | gem_group :development, :test do 103 | gem "rails-assets-qunit" 104 | end 105 | end unless options[:skip_source] 106 | end 107 | 108 | def rails_assets(&block) 109 | in_root do 110 | append_file "Gemfile", %[\nsource "https://rails-assets.org" do], force: true 111 | 112 | instance_eval(&block) 113 | 114 | append_file "Gemfile", "\nend\n", force: true 115 | end 116 | end 117 | end 118 | end 119 | -------------------------------------------------------------------------------- /lib/generators/test_squad/install/templates/ember/router_test.js: -------------------------------------------------------------------------------- 1 | module("Router", {setup: function(){ 2 | App.reset(); 3 | }}); 4 | 5 | test("root route", function() { 6 | visit("/"); 7 | 8 | andThen(function(){ 9 | equal(currentRouteName(), "index"); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /lib/generators/test_squad/install/templates/ember/test_helper.js.erb: -------------------------------------------------------------------------------- 1 | //= require application 2 | //= require_self 3 | //= require_tree ./components 4 | //= require_tree ./models 5 | //= require_tree ./routes 6 | //= require_tree ./unit 7 | //= require_tree ./views 8 | 9 | // Set the application. 10 | App = <%= app_class_name %>; 11 | 12 | // Set up Ember testing. 13 | App.rootElement = '#ember-testing'; 14 | App.setupForTesting(); 15 | App.injectTestHelpers(); 16 | -------------------------------------------------------------------------------- /lib/generators/test_squad/install/templates/jasmine/answer_spec.js: -------------------------------------------------------------------------------- 1 | describe("The answer to life the universe and everything", function(){ 2 | it("is 42", function(){ 3 | var answer = 42; 4 | expect(answer).toEqual(42); 5 | }); 6 | }); 7 | -------------------------------------------------------------------------------- /lib/generators/test_squad/install/templates/jasmine/spec_helper.js.erb: -------------------------------------------------------------------------------- 1 | //= require application 2 | //= require_self 3 | //= require_tree ./<%= app_name %> 4 | -------------------------------------------------------------------------------- /lib/generators/test_squad/install/templates/mocha/answer_spec.js: -------------------------------------------------------------------------------- 1 | describe("The answer to life the universe and everything", function(){ 2 | it("is 42", function(){ 3 | var answer = 42; 4 | expect(answer).to.eql(42); 5 | }); 6 | }); 7 | -------------------------------------------------------------------------------- /lib/generators/test_squad/install/templates/mocha/spec_helper.js.erb: -------------------------------------------------------------------------------- 1 | //= require application 2 | //= require expect 3 | //= require_self 4 | //= require_tree ./<%= app_name %> 5 | 6 | mocha.setup('bdd'); 7 | mocha.checkLeaks(); 8 | mocha.globals(['jQuery']); 9 | mocha.reporter(mocha.TestSquad); 10 | window.onload = function(){ 11 | mocha.run(); 12 | }; 13 | -------------------------------------------------------------------------------- /lib/generators/test_squad/install/templates/qunit/answer_test.js: -------------------------------------------------------------------------------- 1 | module("The answer to life the universe and everything"); 2 | 3 | test("the answer is 42", function() { 4 | var answer = 42; 5 | equal(answer, 42); 6 | }); 7 | -------------------------------------------------------------------------------- /lib/generators/test_squad/install/templates/qunit/test_helper.js.erb: -------------------------------------------------------------------------------- 1 | //= require application 2 | //= require_self 3 | //= require_tree ./<%= app_name %> 4 | -------------------------------------------------------------------------------- /lib/generators/test_squad/install/templates/test_squad.rb.erb: -------------------------------------------------------------------------------- 1 | TestSquad.configure do |config| 2 | # Set the testing framework. 3 | # Can be jasmine, qunit, mocha or ember. 4 | config.framework = "<%= options[:framework] %>" 5 | 6 | # Set the test server host. 7 | # This can also be set through the TEST_SQUAD_SEVER_HOST env var. 8 | # config.server_host = "127.0.0.1" 9 | 10 | # Set the test server port. 11 | # This can also be set through the TEST_SQUAD_SERVER_PORT env var. 12 | # config.server_port = 50000 13 | 14 | # Set the test server path. 15 | # You may map the tests path to something else. This change 16 | # must be reflected here. This can also be set through the 17 | # TEST_SQUAD_SERVER_PATH env var. 18 | # config.server_path = "/tests" 19 | 20 | # Set the test timeout. 21 | # This can also be set through the TEST_SQUAD_TIMEOUT env var. 22 | # It defaults to 10 seconds. 23 | # config.timeout = 10 24 | 25 | # Set the phantomjs bin path. 26 | # This can also be set through the TEST_SQUAD_PHANTOMJS_BIN env var. 27 | # config.phantomjs_bin = "phantomjs" 28 | end 29 | -------------------------------------------------------------------------------- /lib/tasks/test_squad_tasks.rake: -------------------------------------------------------------------------------- 1 | desc "Run JavaScript tests" 2 | task :test_squad do 3 | ENV["RAILS_ENV"] = "test" 4 | ENV["RACK_ENV"] = "test" 5 | 6 | require "./config/environment" 7 | config_file = Rails.root.join(TestSquad.test_directory, "test_squad.rb") 8 | load config_file if config_file.exist? 9 | 10 | TestSquad::Runner.run 11 | end 12 | -------------------------------------------------------------------------------- /lib/test_squad.rb: -------------------------------------------------------------------------------- 1 | require "test_squad/engine" 2 | require "test_squad/runner" 3 | require "test_squad/configuration" 4 | 5 | module TestSquad 6 | def self.configuration 7 | @configuration ||= Configuration.new 8 | end 9 | 10 | def self.configure(&block) 11 | configuration.tap(&block) 12 | end 13 | 14 | def self.app_class_name 15 | Rails.application.class.name.split("::").first 16 | end 17 | 18 | def self.test_directory 19 | @test_directory ||= begin 20 | if Rails.root.join("spec").exist? 21 | "spec/javascript" 22 | else 23 | "test/javascript" 24 | end 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /lib/test_squad/configuration.rb: -------------------------------------------------------------------------------- 1 | module TestSquad 2 | class Configuration 3 | # Set the enabled JavaScript library. 4 | attr_accessor :framework 5 | 6 | # Set the phantomjs bin path. 7 | # This can also be set through the TEST_SQUAD_PHANTOMJS_BIN env var. 8 | # It defaults to `phantomjs`. 9 | attr_writer :phantomjs_bin 10 | 11 | # Set the test server host. 12 | # This can also be set through the TEST_SQUAD_SERVER_HOST env var. 13 | # It defaults to `127.0.0.1` 14 | attr_writer :server_host 15 | 16 | # Set the test server port. 17 | # This can also be set through the TEST_SQUAD_SERVER_PORT env var. 18 | # It defaults to `42424` 19 | attr_writer :server_port 20 | 21 | # Set the test server path. 22 | # You may map the tests path to something else. This change 23 | # must be reflected here. This can also be set through the 24 | # TEST_SQUAD_SERVER_PATH env var. 25 | # It defaults to `/tests`. 26 | attr_writer :server_path 27 | 28 | # Set the test timeout. 29 | # This can also be set through the TEST_SQUAD_TIMEOUT env var. 30 | # It defaults to `10` seconds. 31 | attr_writer :timeout 32 | 33 | def server_uri 34 | File.join("http://#{server_host}:#{server_port}", server_path) 35 | end 36 | 37 | def phantomjs_bin 38 | get_value("TEST_SQUAD_PHANTOMJS_BIN", __method__, "phantomjs") 39 | end 40 | 41 | def server_host 42 | get_value("TEST_SQUAD_SERVER_HOST", __method__, "127.0.0.1") 43 | end 44 | 45 | def server_port 46 | get_value("TEST_SQUAD_SERVER_PORT", __method__, 42_424) 47 | end 48 | 49 | def server_path 50 | get_value("TEST_SQUAD_SERVER_PATH", __method__, "/tests") 51 | end 52 | 53 | def timeout 54 | get_value("TEST_SQUAD_TIMEOUT", __method__, 10) 55 | end 56 | 57 | private 58 | 59 | def get_value(env_var, option_name, default_value) 60 | ENV[env_var] || 61 | instance_variable_get("@#{option_name}") || 62 | default_value 63 | end 64 | end 65 | end 66 | -------------------------------------------------------------------------------- /lib/test_squad/engine.rb: -------------------------------------------------------------------------------- 1 | module TestSquad 2 | class Engine < ::Rails::Engine 3 | initializer "test_squad" do 4 | next unless %w[development test].include?(Rails.env) 5 | 6 | config = Rails.application.config 7 | 8 | config.assets.paths += [ 9 | Rails.root.join(TestSquad.test_directory).to_s 10 | ] 11 | 12 | config.assets.precompile += %W[ 13 | test_helper.js 14 | spec_helper.js 15 | 16 | test_squad/qunit-phantom.js 17 | test_squad/jasmine-phantom.js 18 | test_squad/mocha-phantom.js 19 | test_squad/ember.css 20 | test_squad/mocha-reporter.js 21 | 22 | qunit.css 23 | qunit.js 24 | 25 | jasmine/jasmine_favicon.png 26 | jasmine/jasmine.js 27 | jasmine/jasmine.css 28 | jasmine/jasmine-html.js 29 | jasmine/boot.js 30 | 31 | mocha.js 32 | mocha.css 33 | ] 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /lib/test_squad/runner.rb: -------------------------------------------------------------------------------- 1 | require "stringio" 2 | require "logger" 3 | require "open3" 4 | 5 | module TestSquad 6 | class Runner 7 | def self.run 8 | new.run 9 | end 10 | 11 | def initialize 12 | Rails.configuration.logger = logger 13 | end 14 | 15 | def config 16 | TestSquad.configuration 17 | end 18 | 19 | def logger 20 | @logger ||= Logger.new(StringIO.new) 21 | end 22 | 23 | def app_server 24 | Rack::Handler.pick(["puma", "thin", "webrick"]) 25 | end 26 | 27 | def run 28 | run_server 29 | run_tests 30 | end 31 | 32 | def run_server 33 | Thread.new do 34 | app_server.run Rails.application, 35 | Port: config.server_port, 36 | Host: config.server_host, 37 | Logger: logger, 38 | AccessLog: [], 39 | Silent: true 40 | end 41 | end 42 | 43 | def runner_script 44 | File.expand_path("../../../phantomjs/runner.js", __FILE__) 45 | end 46 | 47 | def run_tests 48 | system( 49 | config.phantomjs_bin, 50 | runner_script, 51 | config.server_uri, 52 | config.timeout.to_s 53 | ) 54 | 55 | exit_code = $? ? $?.exitstatus : 0 56 | exit(exit_code) 57 | end 58 | end 59 | end 60 | -------------------------------------------------------------------------------- /lib/test_squad/version.rb: -------------------------------------------------------------------------------- 1 | module TestSquad 2 | VERSION = "0.1.3" 3 | end 4 | -------------------------------------------------------------------------------- /phantomjs/helpers.js: -------------------------------------------------------------------------------- 1 | var system = require('system'); 2 | 3 | var COLORS = { 4 | red: '\033[31m', 5 | green: '\033[32m', 6 | yellow: '\033[33m', 7 | gray: '\033[0;37m', 8 | clear: '\033[0m' 9 | }; 10 | 11 | function colored(message, color) { 12 | var color = COLORS[color] || COLORS.clear; 13 | 14 | return color + message + COLORS.clear; 15 | } 16 | 17 | function output(message, color) { 18 | system.stdout.write(colored(message, color)); 19 | } 20 | 21 | function textForSelector(page, selector) { 22 | return page.evaluate(function(selector){ 23 | return document.querySelector(selector).textContent.replace(/\s+/mg, ' ').trim(); 24 | }, selector); 25 | } 26 | 27 | module.exports = { 28 | colored: colored, 29 | output: output, 30 | textForSelector: textForSelector 31 | }; 32 | -------------------------------------------------------------------------------- /phantomjs/runner.js: -------------------------------------------------------------------------------- 1 | /* jshint -W100 */ 2 | /* global phantom */ 3 | (function () { 4 | 'use strict'; 5 | 6 | var system = require('system'); 7 | var webpage = require('webpage'); 8 | var helpers = require('./helpers'); 9 | var output = helpers.output; 10 | var colored = helpers.colored; 11 | var textForSelector = helpers.textForSelector; 12 | 13 | var args = system.args; 14 | var url = args[1]; 15 | var timeout = parseInt(args[2], 10); 16 | var page = webpage.create(); 17 | var suites = []; 18 | var suite, test; 19 | var errorBuffer = []; 20 | var pendingBuffer = []; 21 | var resourceErrors = []; 22 | 23 | page.viewportSize = { 24 | width: 800, 25 | height: 800 26 | }; 27 | 28 | var testOutput = function(test) { 29 | if (test.passed) { 30 | output('•', 'green'); 31 | } else if (test.pending) { 32 | output('*', 'yellow'); 33 | pendingBuffer.push(testDescription(test, 'yellow')); 34 | } else { 35 | output('×', 'red'); 36 | errorBuffer.push(testDescription(test, 'red')); 37 | } 38 | }; 39 | 40 | var testDescription = function(test, color) { 41 | var status = test.pending? '[PENDING]' : '[FAILURE]'; 42 | 43 | var description = test.suites.map(function(suite) { 44 | return suite.title; 45 | }).join(' ') + ' ' + test.title; 46 | 47 | description = status + ' ' + description.replace(/^\s+/gm, ''); 48 | 49 | if (test.failure) { 50 | description += '\n'; 51 | description += test.failure.replace(/^\s*/gm, ' '); 52 | } 53 | 54 | description = colored(description, color); 55 | 56 | if (test.logging.length) { 57 | description += '\n'; 58 | 59 | for (var i = 0; i < test.logging.length; i++) { 60 | var lines = test.logging[i].split(/\r?\n/); 61 | description += '\n'; 62 | description += colored(' => ' + lines.shift(), 'gray'); 63 | 64 | if (lines.length > 0) { 65 | description += '\n'; 66 | description += colored(lines.join('\n').replace(/^/gm, ' '), 'gray'); 67 | } 68 | } 69 | } 70 | 71 | return description; 72 | }; 73 | 74 | var pluralize = function(count, singular, plural) { 75 | if (!plural) { 76 | plural = singular + 's'; 77 | } 78 | 79 | return count + ' ' + (count === 1 ? singular : plural); 80 | }; 81 | 82 | page.onConsoleMessage = function(message) { 83 | if (test) { 84 | test.logging.push(message); 85 | } else { 86 | console.log(colored('=> ' + message, 'gray')); 87 | } 88 | }; 89 | 90 | page.onResourceError = function(error) { 91 | resourceErrors.push(error); 92 | }; 93 | 94 | page.onCallback = function(message){ 95 | if (message.name === 'suite start') { 96 | suite = {tests: []}; 97 | suite.title = message.title; 98 | 99 | if (message.title) { 100 | suites.push(suite); 101 | } 102 | } else if (message.name === 'suite end') { 103 | suites = []; 104 | } else if (message.name === 'test start') { 105 | test = {logging: []}; 106 | test.suites = suites; 107 | suite.tests.push(test); 108 | } else if (message.name === 'test end') { 109 | test.title = message.title; 110 | test.passed = message.passed; 111 | test.pending = message.pending; 112 | test.failure = message.failure; 113 | testOutput(test); 114 | test = null; 115 | } else if (message.name === 'end') { 116 | var stats = message.stats; 117 | var summary = []; 118 | var color; 119 | var hasErrorBuffer = errorBuffer.length > 0; 120 | var hasPendingBuffer = pendingBuffer.length > 0; 121 | 122 | if (hasErrorBuffer || hasPendingBuffer) { 123 | console.log(''); 124 | } 125 | 126 | if (hasErrorBuffer) { 127 | console.log('\n' + errorBuffer.join('\n\n')); 128 | } 129 | 130 | if (hasPendingBuffer) { 131 | console.log('\n' + pendingBuffer.join('\n')); 132 | } 133 | 134 | console.log(''); 135 | 136 | if (stats.tests > 0) { 137 | summary.push(pluralize(stats.tests, 'test')); 138 | 139 | if (stats.assertions) { 140 | summary.push(pluralize(stats.assertions, 'assertion')); 141 | } 142 | 143 | if (stats.pending) { 144 | summary.push(pluralize(stats.pending, 'test') + ' pending'); 145 | } 146 | 147 | if (stats.fails) { 148 | summary.push(pluralize(stats.fails, 'test') + ' failed'); 149 | } 150 | } else { 151 | summary.push('No tests were found.'); 152 | } 153 | 154 | if (stats.fails) { 155 | color = 'red'; 156 | } else if (stats.pending) { 157 | color = 'yellow'; 158 | } else { 159 | console.log(''); 160 | color = 'green'; 161 | } 162 | 163 | summary = colored(summary.join(', '), color); 164 | summary += colored(' (' + (stats.elapsed / 1000) + 's)', 'gray'); 165 | 166 | console.log(summary); 167 | exit(stats.fails ? 1 : 0); 168 | } 169 | }; 170 | 171 | page.open(url, function(status){ 172 | if (status === 'fail') { 173 | console.error('Unable to access network: ' + status); 174 | exit(1); 175 | } else { 176 | if (resourceErrors.length === 1 && resourceErrors[0].url === url) { 177 | var errorHeader = textForSelector(page, 'header > h1'); 178 | var errorDescription = textForSelector(page, '#container > pre'); 179 | var matches = errorDescription.match(/^(.*?) \(in (.*?)\)$/) 180 | 181 | console.error(colored('ERROR:', 'red'), errorHeader, '-', matches[1]); 182 | console.error(colored(matches[2], 'gray')); 183 | exit(1); 184 | } else { 185 | setTimeout(function(){ 186 | console.error(colored('ERROR:', 'red'), 'The specified timeout of ' + timeout + ' seconds has expired. Aborting...'); 187 | exit(1); 188 | }, timeout * 1000); 189 | } 190 | } 191 | }); 192 | 193 | function exit(code) { 194 | if (page) { 195 | page.close(); 196 | } 197 | 198 | setTimeout(function(){ 199 | phantom.exit(code); 200 | }, 0); 201 | } 202 | })(); 203 | -------------------------------------------------------------------------------- /screenshots/jasmine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fnando/test_squad/69c4f88e401e9a0e3077a86ef45b632676ff7f85/screenshots/jasmine.png -------------------------------------------------------------------------------- /screenshots/mocha.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fnando/test_squad/69c4f88e401e9a0e3077a86ef45b632676ff7f85/screenshots/mocha.png -------------------------------------------------------------------------------- /screenshots/qunit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fnando/test_squad/69c4f88e401e9a0e3077a86ef45b632676ff7f85/screenshots/qunit.png -------------------------------------------------------------------------------- /screenshots/terminal-ember.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fnando/test_squad/69c4f88e401e9a0e3077a86ef45b632676ff7f85/screenshots/terminal-ember.png -------------------------------------------------------------------------------- /screenshots/terminal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fnando/test_squad/69c4f88e401e9a0e3077a86ef45b632676ff7f85/screenshots/terminal.png -------------------------------------------------------------------------------- /test/controllers/test_squad_controller_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class TestSquadControllerTest < ActionController::TestCase 4 | def create_helper_file(framework) 5 | File.open(@destination_root.join("test_squad.rb"), "w") do |file| 6 | file << "TestSquad.configuration.framework = '#{framework}'" 7 | end 8 | end 9 | 10 | setup do 11 | @destination_root = Rails.root.join("test/javascript") 12 | FileUtils.mkdir_p(@destination_root) 13 | end 14 | 15 | teardown do 16 | FileUtils.rm_rf @destination_root 17 | end 18 | 19 | test "view for mocha framework" do 20 | create_helper_file "mocha" 21 | get :tests 22 | 23 | assert_response :ok 24 | assert_template "mocha" 25 | end 26 | 27 | test "view for jasmine framework" do 28 | create_helper_file "jasmine" 29 | get :tests 30 | 31 | assert_response :ok 32 | assert_template "jasmine" 33 | end 34 | 35 | test "view for qunit framework" do 36 | create_helper_file "qunit" 37 | get :tests 38 | 39 | assert_response :ok 40 | assert_template "qunit" 41 | end 42 | 43 | test "view for ember framework" do 44 | create_helper_file "ember" 45 | get :tests 46 | 47 | assert_response :ok 48 | assert_template "ember" 49 | end 50 | end 51 | -------------------------------------------------------------------------------- /test/lib/generators/test_squad/install_generator/ember_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | require "generators/test_squad/install/install_generator" 3 | 4 | class TestSquadEmberTest < Rails::Generators::TestCase 5 | tests TestSquad::InstallGenerator 6 | destination Rails.root.join("tmp/generators") 7 | setup :prepare_destination 8 | 9 | setup do 10 | @destination_root = self.class.destination_root 11 | @gemfile_path = @destination_root.join("Gemfile").to_s 12 | FileUtils.rm_rf(@gemfile_path) 13 | FileUtils.touch(@gemfile_path) 14 | end 15 | 16 | teardown do 17 | FileUtils.rm_rf Rails.root.join("spec") 18 | end 19 | 20 | test "copy test_squad.rb" do 21 | run_generator %w[--framework ember] 22 | assert_file @destination_root.join("test/javascript/test_squad.rb"), /config.framework = "ember"/ 23 | end 24 | 25 | test "create dirs" do 26 | run_generator %w[--framework ember] 27 | assert_directory @destination_root.join("test/javascript/unit") 28 | assert_directory @destination_root.join("test/javascript/routes") 29 | assert_directory @destination_root.join("test/javascript/models") 30 | assert_directory @destination_root.join("test/javascript/components") 31 | assert_directory @destination_root.join("test/javascript/views") 32 | end 33 | 34 | test "create test helper file" do 35 | run_generator %w[--framework ember] 36 | assert_file @destination_root.join("test/javascript/test_helper.js") 37 | end 38 | 39 | test "copy sample test file" do 40 | run_generator %w[--framework ember] 41 | assert_file @destination_root.join("test/javascript/unit/router_test.js") 42 | end 43 | 44 | test "add gems" do 45 | run_generator %w[--framework ember] 46 | assert_file @gemfile_path, /gem 'rails-assets-qunit'/ 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /test/lib/generators/test_squad/install_generator/jasmine_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | require "generators/test_squad/install/install_generator" 3 | 4 | class TestSquadJasmineTest < Rails::Generators::TestCase 5 | tests TestSquad::InstallGenerator 6 | destination Rails.root.join("tmp/generators") 7 | setup :prepare_destination 8 | 9 | setup do 10 | @destination_root = self.class.destination_root 11 | @gemfile_path = @destination_root.join("Gemfile").to_s 12 | FileUtils.rm_rf(@gemfile_path) 13 | FileUtils.touch(@gemfile_path) 14 | end 15 | 16 | teardown do 17 | FileUtils.rm_rf Rails.root.join("spec") 18 | end 19 | 20 | test "skip rails assets source" do 21 | run_generator %w[--framework jasmine] 22 | refute File.read(@gemfile_path).include?(%[source 'https://rails-assets.org']) 23 | end 24 | 25 | test "copy test_squad.rb" do 26 | run_generator %w[--framework jasmine] 27 | assert_file @destination_root.join("test/javascript/test_squad.rb"), /config.framework = "jasmine"/ 28 | end 29 | 30 | test "create app dir" do 31 | run_generator %w[--framework jasmine] 32 | assert_directory @destination_root.join("test/javascript/dummy") 33 | end 34 | 35 | test "create spec helper file" do 36 | run_generator %w[--framework jasmine] 37 | assert_file @destination_root.join("test/javascript/spec_helper.js") 38 | end 39 | 40 | test "copy sample test file" do 41 | run_generator %w[--framework jasmine] 42 | assert_file @destination_root.join("test/javascript/dummy/answer_spec.js") 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /test/lib/generators/test_squad/install_generator/mocha_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | require "generators/test_squad/install/install_generator" 3 | 4 | class TestSquadMochaTest < Rails::Generators::TestCase 5 | tests TestSquad::InstallGenerator 6 | destination Rails.root.join("tmp/generators") 7 | setup :prepare_destination 8 | 9 | setup do 10 | @destination_root = self.class.destination_root 11 | @gemfile_path = @destination_root.join("Gemfile").to_s 12 | FileUtils.rm_rf(@gemfile_path) 13 | FileUtils.touch(@gemfile_path) 14 | end 15 | 16 | teardown do 17 | FileUtils.rm_rf Rails.root.join("spec") 18 | end 19 | 20 | test "copy test_squad.rb" do 21 | run_generator %w[--framework mocha] 22 | assert_file @destination_root.join("test/javascript/test_squad.rb"), /config.framework = "mocha"/ 23 | end 24 | 25 | test "create app dir" do 26 | run_generator %w[--framework mocha] 27 | assert_directory @destination_root.join("test/javascript/dummy") 28 | end 29 | 30 | test "create spec helper file" do 31 | run_generator %w[--framework mocha] 32 | assert_file @destination_root.join("test/javascript/spec_helper.js") 33 | end 34 | 35 | test "copy sample test file" do 36 | run_generator %w[--framework mocha] 37 | assert_file @destination_root.join("test/javascript/dummy/answer_spec.js") 38 | end 39 | 40 | test "add gems" do 41 | run_generator %w[--framework mocha] 42 | assert_file @gemfile_path, /gem 'rails-assets-mocha'/ 43 | assert_file @gemfile_path, /gem 'rails-assets-expect'/ 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /test/lib/generators/test_squad/install_generator/qunit_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | require "generators/test_squad/install/install_generator" 3 | 4 | class TestSquadQunitTest < Rails::Generators::TestCase 5 | tests TestSquad::InstallGenerator 6 | destination Rails.root.join("tmp/generators") 7 | setup :prepare_destination 8 | 9 | setup do 10 | @destination_root = self.class.destination_root 11 | @gemfile_path = @destination_root.join("Gemfile").to_s 12 | FileUtils.rm_rf(@gemfile_path) 13 | FileUtils.touch(@gemfile_path) 14 | end 15 | 16 | teardown do 17 | FileUtils.rm_rf Rails.root.join("spec") 18 | end 19 | 20 | test "copy test_squad.rb" do 21 | run_generator %w[--framework qunit] 22 | assert_file @destination_root.join("test/javascript/test_squad.rb"), /config.framework = "qunit"/ 23 | end 24 | 25 | test "add gem" do 26 | run_generator %w[--framework qunit] 27 | assert_file @gemfile_path, /gem 'rails-assets-qunit'/ 28 | end 29 | 30 | test "create app dir" do 31 | run_generator %w[--framework qunit] 32 | assert_directory @destination_root.join("test/javascript/dummy") 33 | end 34 | 35 | test "create test helper file" do 36 | run_generator %w[--framework qunit] 37 | assert_file @destination_root.join("test/javascript/test_helper.js") 38 | end 39 | 40 | test "copy sample test file" do 41 | run_generator %w[--framework qunit] 42 | assert_file @destination_root.join("test/javascript/dummy/answer_test.js") 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /test/lib/generators/test_squad/install_generator_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | require "generators/test_squad/install/install_generator" 3 | 4 | class TestSquadInstallGeneratorTest < Rails::Generators::TestCase 5 | tests TestSquad::InstallGenerator 6 | destination Rails.root.join("tmp/generators") 7 | setup :prepare_destination 8 | 9 | setup do 10 | @destination_root = self.class.destination_root 11 | @gemfile_path = @destination_root.join("Gemfile").to_s 12 | FileUtils.rm_rf(@gemfile_path) 13 | FileUtils.touch(@gemfile_path) 14 | end 15 | 16 | teardown do 17 | FileUtils.rm_rf Rails.root.join("spec") 18 | end 19 | 20 | test "detect spec directory" do 21 | FileUtils.mkdir_p @destination_root.join("spec") 22 | run_generator %w[--framework qunit] 23 | assert_directory @destination_root.join("spec/javascript") 24 | end 25 | 26 | test "detect test directory" do 27 | run_generator %w[--framework qunit] 28 | assert_directory @destination_root.join("test/javascript") 29 | end 30 | 31 | test "add rails-assets.org source" do 32 | run_generator %w[--framework qunit] 33 | assert_file @gemfile_path, %r[source "https://rails-assets.org"] 34 | end 35 | 36 | test "skip source" do 37 | run_generator %w[--framework qunit --skip-source] 38 | refute File.read(@gemfile_path).match(%r[source "https://rails-assets.org"]) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /test/lib/test_squad/configuration_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class TestSquadConfigurationTest < ActiveSupport::TestCase 4 | def with_env(options, &block) 5 | options.each do |name, value| 6 | ENV[name] = value.to_s 7 | end 8 | 9 | yield 10 | ensure 11 | options.each do |name, _| 12 | ENV.delete(name) 13 | end 14 | end 15 | 16 | def assert_configuration(env_var, option_name, default_value) 17 | assert_env_var(env_var, option_name) 18 | assert_option_value(option_name) 19 | assert_default_value(option_name, default_value) 20 | end 21 | 22 | def assert_env_var(env_var, option_name) 23 | custom_value = "#{env_var}_CUSTOM_VALUE" 24 | 25 | with_env(env_var => custom_value) do 26 | assert_equal custom_value, @config.public_send(option_name) 27 | end 28 | end 29 | 30 | def assert_option_value(option_name) 31 | custom_value = "#{option_name}_custom_value" 32 | @config.public_send("#{option_name}=", custom_value) 33 | assert_equal custom_value, @config.public_send(option_name) 34 | end 35 | 36 | def assert_default_value(option_name, default_value) 37 | @config.public_send("#{option_name}=", nil) 38 | assert_equal default_value, @config.public_send(option_name) 39 | end 40 | 41 | setup do 42 | @config = TestSquad::Configuration.new 43 | end 44 | 45 | test "phantomjs_bin option" do 46 | assert_configuration "TEST_SQUAD_PHANTOMJS_BIN", "phantomjs_bin", "phantomjs" 47 | end 48 | 49 | test "server_host option" do 50 | assert_configuration "TEST_SQUAD_SERVER_HOST", "server_host", "127.0.0.1" 51 | end 52 | 53 | test "server_port option" do 54 | assert_configuration "TEST_SQUAD_SERVER_PORT", "server_port", 42424 55 | end 56 | 57 | test "server_path option" do 58 | assert_configuration "TEST_SQUAD_SERVER_PATH", "server_path", "/tests" 59 | end 60 | 61 | test "timeout option" do 62 | assert_configuration "TEST_SQUAD_TIMEOUT", "timeout", 10 63 | end 64 | 65 | test "server uri" do 66 | assert_equal @config.server_uri, "http://127.0.0.1:42424/tests" 67 | end 68 | end 69 | -------------------------------------------------------------------------------- /test/lib/test_squad/runner_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class TestSquadRunnerTest < ActiveSupport::TestCase 4 | test "server adapter" do 5 | server = TestSquad::Runner.new.app_server 6 | assert_equal Rack::Handler::WEBrick, server 7 | end 8 | 9 | test "starts server" do 10 | runner = TestSquad::Runner.new 11 | config = runner.config 12 | app_server = mock 13 | app_server_options = { 14 | Port: config.server_port, 15 | Host: config.server_host, 16 | Logger: runner.logger, 17 | AccessLog: [], 18 | Silent: true 19 | } 20 | 21 | app_server 22 | .expects(:run) 23 | .with(Rails.application, app_server_options) 24 | 25 | runner 26 | .expects(:app_server) 27 | .returns(app_server) 28 | 29 | thread = runner.run_server 30 | thread.join 31 | thread.kill 32 | end 33 | 34 | test "execute tests" do 35 | runner = TestSquad::Runner.new 36 | config = runner.config 37 | calls = sequence("calls") 38 | 39 | runner 40 | .expects(:system) 41 | .with( 42 | config.phantomjs_bin, 43 | runner.runner_script, 44 | config.server_uri, 45 | config.timeout.to_s 46 | ) 47 | .in_sequence(calls) 48 | 49 | runner 50 | .expects(:exit) 51 | .with(0) 52 | .in_sequence(calls) 53 | 54 | runner.run_tests 55 | end 56 | end 57 | -------------------------------------------------------------------------------- /test/support/app.rb: -------------------------------------------------------------------------------- 1 | module Dummy 2 | class Application < Rails::Application 3 | config.active_support.test_order = :random 4 | config.secret_token = SecureRandom.hex(100) 5 | config.secret_key_base = SecureRandom.hex(100) 6 | config.eager_load = false 7 | end 8 | end 9 | 10 | Dummy::Application.initialize! 11 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | # Set up Codeclimate. 2 | require "codeclimate-test-reporter" 3 | CodeClimate::TestReporter.start 4 | 5 | $LOAD_PATH.unshift File.expand_path("#{__dir__}/../lib") 6 | 7 | # Configure Rails Environment 8 | ENV["RAILS_ENV"] = "test" 9 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__) 10 | require "rails" 11 | require "bundler/setup" 12 | require "action_controller/railtie" 13 | require "action_view/railtie" 14 | require "sprockets/railtie" 15 | require "rails/test_unit/railtie" 16 | 17 | Bundler.require(*Rails.groups) 18 | require "test_squad" 19 | 20 | app_file = File.join(__dir__, "support/app_#{Rails::VERSION::STRING}.rb") 21 | 22 | if File.file?(app_file) 23 | require app_file 24 | else 25 | require File.join(__dir__, "support/app.rb") 26 | end 27 | 28 | require "rails/test_help" 29 | require "mocha" 30 | require "mocha/mini_test" 31 | require "minitest/utils" 32 | require "minitest/autorun" 33 | -------------------------------------------------------------------------------- /test/test_squad_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class TestSquadTest < ActiveSupport::TestCase 4 | test "truth" do 5 | assert_kind_of Module, TestSquad 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /test_squad.gemspec: -------------------------------------------------------------------------------- 1 | require "./lib/test_squad/version" 2 | 3 | Gem::Specification.new do |s| 4 | s.name = "test_squad" 5 | s.version = TestSquad::VERSION 6 | s.authors = ["Nando Vieira"] 7 | s.email = ["fnando.vieira@gmail.com"] 8 | s.homepage = "http://github.com/fnando/test_squad" 9 | s.summary = "Rails and JavaScript testing, the easy way. Supports QUnit, Jasmine, Mocha and Ember." 10 | s.description = s.summary 11 | s.license = "MIT" 12 | 13 | s.files = Dir["{app,config,db,lib,phantomjs,vendor}/**/*", "MIT-LICENSE", "Rakefile", "README.md"] 14 | s.test_files = Dir["test/**/*"] 15 | 16 | s.add_dependency "rails" 17 | s.add_development_dependency "pry-meta" 18 | s.add_development_dependency "codeclimate-test-reporter" 19 | s.add_development_dependency "mocha" 20 | s.add_development_dependency "minitest-utils" 21 | end 22 | -------------------------------------------------------------------------------- /vendor/assets/libs/jasmine/boot.js: -------------------------------------------------------------------------------- 1 | /** 2 | Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js` and `jasmine_html.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project. 3 | 4 | If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms. 5 | 6 | The location of `boot.js` can be specified and/or overridden in `jasmine.yml`. 7 | 8 | [jasmine-gem]: http://github.com/pivotal/jasmine-gem 9 | */ 10 | 11 | (function() { 12 | 13 | /** 14 | * ## Require & Instantiate 15 | * 16 | * Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference. 17 | */ 18 | window.jasmine = jasmineRequire.core(jasmineRequire); 19 | 20 | /** 21 | * Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference. 22 | */ 23 | jasmineRequire.html(jasmine); 24 | 25 | /** 26 | * Create the Jasmine environment. This is used to run all specs in a project. 27 | */ 28 | var env = jasmine.getEnv(); 29 | 30 | /** 31 | * ## The Global Interface 32 | * 33 | * Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged. 34 | */ 35 | var jasmineInterface = jasmineRequire.interface(jasmine, env); 36 | 37 | /** 38 | * Add all of the Jasmine global/public interface to the proper global, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`. 39 | */ 40 | if (typeof window == "undefined" && typeof exports == "object") { 41 | extend(exports, jasmineInterface); 42 | } else { 43 | extend(window, jasmineInterface); 44 | } 45 | 46 | /** 47 | * ## Runner Parameters 48 | * 49 | * More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface. 50 | */ 51 | 52 | var queryString = new jasmine.QueryString({ 53 | getWindowLocation: function() { return window.location; } 54 | }); 55 | 56 | var catchingExceptions = queryString.getParam("catch"); 57 | env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions); 58 | 59 | /** 60 | * ## Reporters 61 | * The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any). 62 | */ 63 | var htmlReporter = new jasmine.HtmlReporter({ 64 | env: env, 65 | onRaiseExceptionsClick: function() { queryString.navigateWithNewParam("catch", !env.catchingExceptions()); }, 66 | addToExistingQueryString: function(key, value) { return queryString.fullStringWithNewParam(key, value); }, 67 | getContainer: function() { return document.body; }, 68 | createElement: function() { return document.createElement.apply(document, arguments); }, 69 | createTextNode: function() { return document.createTextNode.apply(document, arguments); }, 70 | timer: new jasmine.Timer() 71 | }); 72 | 73 | /** 74 | * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript. 75 | */ 76 | env.addReporter(jasmineInterface.jsApiReporter); 77 | env.addReporter(htmlReporter); 78 | 79 | /** 80 | * Filter which specs will be run by matching the start of the full name against the `spec` query param. 81 | */ 82 | var specFilter = new jasmine.HtmlSpecFilter({ 83 | filterString: function() { return queryString.getParam("spec"); } 84 | }); 85 | 86 | env.specFilter = function(spec) { 87 | return specFilter.matches(spec.getFullName()); 88 | }; 89 | 90 | /** 91 | * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack. 92 | */ 93 | window.setTimeout = window.setTimeout; 94 | window.setInterval = window.setInterval; 95 | window.clearTimeout = window.clearTimeout; 96 | window.clearInterval = window.clearInterval; 97 | 98 | /** 99 | * ## Execution 100 | * 101 | * Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded. 102 | */ 103 | var currentWindowOnload = window.onload; 104 | 105 | window.onload = function() { 106 | if (currentWindowOnload) { 107 | currentWindowOnload(); 108 | } 109 | htmlReporter.initialize(); 110 | env.execute(); 111 | }; 112 | 113 | /** 114 | * Helper function for readability above. 115 | */ 116 | function extend(destination, source) { 117 | for (var property in source) destination[property] = source[property]; 118 | return destination; 119 | } 120 | 121 | }()); 122 | -------------------------------------------------------------------------------- /vendor/assets/libs/jasmine/console.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2008-2015 Pivotal Labs 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | function getJasmineRequireObj() { 24 | if (typeof module !== 'undefined' && module.exports) { 25 | return exports; 26 | } else { 27 | window.jasmineRequire = window.jasmineRequire || {}; 28 | return window.jasmineRequire; 29 | } 30 | } 31 | 32 | getJasmineRequireObj().console = function(jRequire, j$) { 33 | j$.ConsoleReporter = jRequire.ConsoleReporter(); 34 | }; 35 | 36 | getJasmineRequireObj().ConsoleReporter = function() { 37 | 38 | var noopTimer = { 39 | start: function(){}, 40 | elapsed: function(){ return 0; } 41 | }; 42 | 43 | function ConsoleReporter(options) { 44 | var print = options.print, 45 | showColors = options.showColors || false, 46 | onComplete = options.onComplete || function() {}, 47 | timer = options.timer || noopTimer, 48 | specCount, 49 | failureCount, 50 | failedSpecs = [], 51 | pendingCount, 52 | ansi = { 53 | green: '\x1B[32m', 54 | red: '\x1B[31m', 55 | yellow: '\x1B[33m', 56 | none: '\x1B[0m' 57 | }, 58 | failedSuites = []; 59 | 60 | print('ConsoleReporter is deprecated and will be removed in a future version.'); 61 | 62 | this.jasmineStarted = function() { 63 | specCount = 0; 64 | failureCount = 0; 65 | pendingCount = 0; 66 | print('Started'); 67 | printNewline(); 68 | timer.start(); 69 | }; 70 | 71 | this.jasmineDone = function() { 72 | printNewline(); 73 | for (var i = 0; i < failedSpecs.length; i++) { 74 | specFailureDetails(failedSpecs[i]); 75 | } 76 | 77 | if(specCount > 0) { 78 | printNewline(); 79 | 80 | var specCounts = specCount + ' ' + plural('spec', specCount) + ', ' + 81 | failureCount + ' ' + plural('failure', failureCount); 82 | 83 | if (pendingCount) { 84 | specCounts += ', ' + pendingCount + ' pending ' + plural('spec', pendingCount); 85 | } 86 | 87 | print(specCounts); 88 | } else { 89 | print('No specs found'); 90 | } 91 | 92 | printNewline(); 93 | var seconds = timer.elapsed() / 1000; 94 | print('Finished in ' + seconds + ' ' + plural('second', seconds)); 95 | printNewline(); 96 | 97 | for(i = 0; i < failedSuites.length; i++) { 98 | suiteFailureDetails(failedSuites[i]); 99 | } 100 | 101 | onComplete(failureCount === 0); 102 | }; 103 | 104 | this.specDone = function(result) { 105 | specCount++; 106 | 107 | if (result.status == 'pending') { 108 | pendingCount++; 109 | print(colored('yellow', '*')); 110 | return; 111 | } 112 | 113 | if (result.status == 'passed') { 114 | print(colored('green', '.')); 115 | return; 116 | } 117 | 118 | if (result.status == 'failed') { 119 | failureCount++; 120 | failedSpecs.push(result); 121 | print(colored('red', 'F')); 122 | } 123 | }; 124 | 125 | this.suiteDone = function(result) { 126 | if (result.failedExpectations && result.failedExpectations.length > 0) { 127 | failureCount++; 128 | failedSuites.push(result); 129 | } 130 | }; 131 | 132 | return this; 133 | 134 | function printNewline() { 135 | print('\n'); 136 | } 137 | 138 | function colored(color, str) { 139 | return showColors ? (ansi[color] + str + ansi.none) : str; 140 | } 141 | 142 | function plural(str, count) { 143 | return count == 1 ? str : str + 's'; 144 | } 145 | 146 | function repeat(thing, times) { 147 | var arr = []; 148 | for (var i = 0; i < times; i++) { 149 | arr.push(thing); 150 | } 151 | return arr; 152 | } 153 | 154 | function indent(str, spaces) { 155 | var lines = (str || '').split('\n'); 156 | var newArr = []; 157 | for (var i = 0; i < lines.length; i++) { 158 | newArr.push(repeat(' ', spaces).join('') + lines[i]); 159 | } 160 | return newArr.join('\n'); 161 | } 162 | 163 | function specFailureDetails(result) { 164 | printNewline(); 165 | print(result.fullName); 166 | 167 | for (var i = 0; i < result.failedExpectations.length; i++) { 168 | var failedExpectation = result.failedExpectations[i]; 169 | printNewline(); 170 | print(indent(failedExpectation.message, 2)); 171 | print(indent(failedExpectation.stack, 2)); 172 | } 173 | 174 | printNewline(); 175 | } 176 | 177 | function suiteFailureDetails(result) { 178 | for (var i = 0; i < result.failedExpectations.length; i++) { 179 | printNewline(); 180 | print(colored('red', 'An error was thrown in an afterAll')); 181 | printNewline(); 182 | print(colored('red', 'AfterAll ' + result.failedExpectations[i].message)); 183 | 184 | } 185 | printNewline(); 186 | } 187 | } 188 | 189 | return ConsoleReporter; 190 | }; 191 | -------------------------------------------------------------------------------- /vendor/assets/libs/jasmine/jasmine-html.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2008-2015 Pivotal Labs 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | jasmineRequire.html = function(j$) { 24 | j$.ResultsNode = jasmineRequire.ResultsNode(); 25 | j$.HtmlReporter = jasmineRequire.HtmlReporter(j$); 26 | j$.QueryString = jasmineRequire.QueryString(); 27 | j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter(); 28 | }; 29 | 30 | jasmineRequire.HtmlReporter = function(j$) { 31 | 32 | var noopTimer = { 33 | start: function() {}, 34 | elapsed: function() { return 0; } 35 | }; 36 | 37 | function HtmlReporter(options) { 38 | var env = options.env || {}, 39 | getContainer = options.getContainer, 40 | createElement = options.createElement, 41 | createTextNode = options.createTextNode, 42 | onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {}, 43 | addToExistingQueryString = options.addToExistingQueryString || defaultQueryString, 44 | timer = options.timer || noopTimer, 45 | results = [], 46 | specsExecuted = 0, 47 | failureCount = 0, 48 | pendingSpecCount = 0, 49 | htmlReporterMain, 50 | symbols, 51 | failedSuites = []; 52 | 53 | this.initialize = function() { 54 | clearPrior(); 55 | htmlReporterMain = createDom('div', {className: 'jasmine_html-reporter'}, 56 | createDom('div', {className: 'banner'}, 57 | createDom('a', {className: 'title', href: 'http://jasmine.github.io/', target: '_blank'}), 58 | createDom('span', {className: 'version'}, j$.version) 59 | ), 60 | createDom('ul', {className: 'symbol-summary'}), 61 | createDom('div', {className: 'alert'}), 62 | createDom('div', {className: 'results'}, 63 | createDom('div', {className: 'failures'}) 64 | ) 65 | ); 66 | getContainer().appendChild(htmlReporterMain); 67 | 68 | symbols = find('.symbol-summary'); 69 | }; 70 | 71 | var totalSpecsDefined; 72 | this.jasmineStarted = function(options) { 73 | totalSpecsDefined = options.totalSpecsDefined || 0; 74 | timer.start(); 75 | }; 76 | 77 | var summary = createDom('div', {className: 'summary'}); 78 | 79 | var topResults = new j$.ResultsNode({}, '', null), 80 | currentParent = topResults; 81 | 82 | this.suiteStarted = function(result) { 83 | currentParent.addChild(result, 'suite'); 84 | currentParent = currentParent.last(); 85 | }; 86 | 87 | this.suiteDone = function(result) { 88 | if (result.status == 'failed') { 89 | failedSuites.push(result); 90 | } 91 | 92 | if (currentParent == topResults) { 93 | return; 94 | } 95 | 96 | currentParent = currentParent.parent; 97 | }; 98 | 99 | this.specStarted = function(result) { 100 | currentParent.addChild(result, 'spec'); 101 | }; 102 | 103 | var failures = []; 104 | this.specDone = function(result) { 105 | if(noExpectations(result) && typeof console !== 'undefined' && typeof console.error !== 'undefined') { 106 | console.error('Spec \'' + result.fullName + '\' has no expectations.'); 107 | } 108 | 109 | if (result.status != 'disabled') { 110 | specsExecuted++; 111 | } 112 | 113 | symbols.appendChild(createDom('li', { 114 | className: noExpectations(result) ? 'empty' : result.status, 115 | id: 'spec_' + result.id, 116 | title: result.fullName 117 | } 118 | )); 119 | 120 | if (result.status == 'failed') { 121 | failureCount++; 122 | 123 | var failure = 124 | createDom('div', {className: 'spec-detail failed'}, 125 | createDom('div', {className: 'description'}, 126 | createDom('a', {title: result.fullName, href: specHref(result)}, result.fullName) 127 | ), 128 | createDom('div', {className: 'messages'}) 129 | ); 130 | var messages = failure.childNodes[1]; 131 | 132 | for (var i = 0; i < result.failedExpectations.length; i++) { 133 | var expectation = result.failedExpectations[i]; 134 | messages.appendChild(createDom('div', {className: 'result-message'}, expectation.message)); 135 | messages.appendChild(createDom('div', {className: 'stack-trace'}, expectation.stack)); 136 | } 137 | 138 | failures.push(failure); 139 | } 140 | 141 | if (result.status == 'pending') { 142 | pendingSpecCount++; 143 | } 144 | }; 145 | 146 | this.jasmineDone = function() { 147 | var banner = find('.banner'); 148 | banner.appendChild(createDom('span', {className: 'duration'}, 'finished in ' + timer.elapsed() / 1000 + 's')); 149 | 150 | var alert = find('.alert'); 151 | 152 | alert.appendChild(createDom('span', { className: 'exceptions' }, 153 | createDom('label', { className: 'label', 'for': 'raise-exceptions' }, 'raise exceptions'), 154 | createDom('input', { 155 | className: 'raise', 156 | id: 'raise-exceptions', 157 | type: 'checkbox' 158 | }) 159 | )); 160 | var checkbox = find('#raise-exceptions'); 161 | 162 | checkbox.checked = !env.catchingExceptions(); 163 | checkbox.onclick = onRaiseExceptionsClick; 164 | 165 | if (specsExecuted < totalSpecsDefined) { 166 | var skippedMessage = 'Ran ' + specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all'; 167 | alert.appendChild( 168 | createDom('span', {className: 'bar skipped'}, 169 | createDom('a', {href: '?', title: 'Run all specs'}, skippedMessage) 170 | ) 171 | ); 172 | } 173 | var statusBarMessage = ''; 174 | var statusBarClassName = 'bar '; 175 | 176 | if (totalSpecsDefined > 0) { 177 | statusBarMessage += pluralize('spec', specsExecuted) + ', ' + pluralize('failure', failureCount); 178 | if (pendingSpecCount) { statusBarMessage += ', ' + pluralize('pending spec', pendingSpecCount); } 179 | statusBarClassName += (failureCount > 0) ? 'failed' : 'passed'; 180 | } else { 181 | statusBarClassName += 'skipped'; 182 | statusBarMessage += 'No specs found'; 183 | } 184 | 185 | alert.appendChild(createDom('span', {className: statusBarClassName}, statusBarMessage)); 186 | 187 | for(i = 0; i < failedSuites.length; i++) { 188 | var failedSuite = failedSuites[i]; 189 | for(var j = 0; j < failedSuite.failedExpectations.length; j++) { 190 | var errorBarMessage = 'AfterAll ' + failedSuite.failedExpectations[j].message; 191 | var errorBarClassName = 'bar errored'; 192 | alert.appendChild(createDom('span', {className: errorBarClassName}, errorBarMessage)); 193 | } 194 | } 195 | 196 | var results = find('.results'); 197 | results.appendChild(summary); 198 | 199 | summaryList(topResults, summary); 200 | 201 | function summaryList(resultsTree, domParent) { 202 | var specListNode; 203 | for (var i = 0; i < resultsTree.children.length; i++) { 204 | var resultNode = resultsTree.children[i]; 205 | if (resultNode.type == 'suite') { 206 | var suiteListNode = createDom('ul', {className: 'suite', id: 'suite-' + resultNode.result.id}, 207 | createDom('li', {className: 'suite-detail'}, 208 | createDom('a', {href: specHref(resultNode.result)}, resultNode.result.description) 209 | ) 210 | ); 211 | 212 | summaryList(resultNode, suiteListNode); 213 | domParent.appendChild(suiteListNode); 214 | } 215 | if (resultNode.type == 'spec') { 216 | if (domParent.getAttribute('class') != 'specs') { 217 | specListNode = createDom('ul', {className: 'specs'}); 218 | domParent.appendChild(specListNode); 219 | } 220 | var specDescription = resultNode.result.description; 221 | if(noExpectations(resultNode.result)) { 222 | specDescription = 'SPEC HAS NO EXPECTATIONS ' + specDescription; 223 | } 224 | if(resultNode.result.status === 'pending' && resultNode.result.pendingReason !== '') { 225 | specDescription = specDescription + ' PENDING WITH MESSAGE: ' + resultNode.result.pendingReason; 226 | } 227 | specListNode.appendChild( 228 | createDom('li', { 229 | className: resultNode.result.status, 230 | id: 'spec-' + resultNode.result.id 231 | }, 232 | createDom('a', {href: specHref(resultNode.result)}, specDescription) 233 | ) 234 | ); 235 | } 236 | } 237 | } 238 | 239 | if (failures.length) { 240 | alert.appendChild( 241 | createDom('span', {className: 'menu bar spec-list'}, 242 | createDom('span', {}, 'Spec List | '), 243 | createDom('a', {className: 'failures-menu', href: '#'}, 'Failures'))); 244 | alert.appendChild( 245 | createDom('span', {className: 'menu bar failure-list'}, 246 | createDom('a', {className: 'spec-list-menu', href: '#'}, 'Spec List'), 247 | createDom('span', {}, ' | Failures '))); 248 | 249 | find('.failures-menu').onclick = function() { 250 | setMenuModeTo('failure-list'); 251 | }; 252 | find('.spec-list-menu').onclick = function() { 253 | setMenuModeTo('spec-list'); 254 | }; 255 | 256 | setMenuModeTo('failure-list'); 257 | 258 | var failureNode = find('.failures'); 259 | for (var i = 0; i < failures.length; i++) { 260 | failureNode.appendChild(failures[i]); 261 | } 262 | } 263 | }; 264 | 265 | return this; 266 | 267 | function find(selector) { 268 | return getContainer().querySelector('.jasmine_html-reporter ' + selector); 269 | } 270 | 271 | function clearPrior() { 272 | // return the reporter 273 | var oldReporter = find(''); 274 | 275 | if(oldReporter) { 276 | getContainer().removeChild(oldReporter); 277 | } 278 | } 279 | 280 | function createDom(type, attrs, childrenVarArgs) { 281 | var el = createElement(type); 282 | 283 | for (var i = 2; i < arguments.length; i++) { 284 | var child = arguments[i]; 285 | 286 | if (typeof child === 'string') { 287 | el.appendChild(createTextNode(child)); 288 | } else { 289 | if (child) { 290 | el.appendChild(child); 291 | } 292 | } 293 | } 294 | 295 | for (var attr in attrs) { 296 | if (attr == 'className') { 297 | el[attr] = attrs[attr]; 298 | } else { 299 | el.setAttribute(attr, attrs[attr]); 300 | } 301 | } 302 | 303 | return el; 304 | } 305 | 306 | function pluralize(singular, count) { 307 | var word = (count == 1 ? singular : singular + 's'); 308 | 309 | return '' + count + ' ' + word; 310 | } 311 | 312 | function specHref(result) { 313 | return addToExistingQueryString('spec', result.fullName); 314 | } 315 | 316 | function defaultQueryString(key, value) { 317 | return '?' + key + '=' + value; 318 | } 319 | 320 | function setMenuModeTo(mode) { 321 | htmlReporterMain.setAttribute('class', 'jasmine_html-reporter ' + mode); 322 | } 323 | 324 | function noExpectations(result) { 325 | return (result.failedExpectations.length + result.passedExpectations.length) === 0 && 326 | result.status === 'passed'; 327 | } 328 | } 329 | 330 | return HtmlReporter; 331 | }; 332 | 333 | jasmineRequire.HtmlSpecFilter = function() { 334 | function HtmlSpecFilter(options) { 335 | var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); 336 | var filterPattern = new RegExp(filterString); 337 | 338 | this.matches = function(specName) { 339 | return filterPattern.test(specName); 340 | }; 341 | } 342 | 343 | return HtmlSpecFilter; 344 | }; 345 | 346 | jasmineRequire.ResultsNode = function() { 347 | function ResultsNode(result, type, parent) { 348 | this.result = result; 349 | this.type = type; 350 | this.parent = parent; 351 | 352 | this.children = []; 353 | 354 | this.addChild = function(result, type) { 355 | this.children.push(new ResultsNode(result, type, this)); 356 | }; 357 | 358 | this.last = function() { 359 | return this.children[this.children.length - 1]; 360 | }; 361 | } 362 | 363 | return ResultsNode; 364 | }; 365 | 366 | jasmineRequire.QueryString = function() { 367 | function QueryString(options) { 368 | 369 | this.navigateWithNewParam = function(key, value) { 370 | options.getWindowLocation().search = this.fullStringWithNewParam(key, value); 371 | }; 372 | 373 | this.fullStringWithNewParam = function(key, value) { 374 | var paramMap = queryStringToParamMap(); 375 | paramMap[key] = value; 376 | return toQueryString(paramMap); 377 | }; 378 | 379 | this.getParam = function(key) { 380 | return queryStringToParamMap()[key]; 381 | }; 382 | 383 | return this; 384 | 385 | function toQueryString(paramMap) { 386 | var qStrPairs = []; 387 | for (var prop in paramMap) { 388 | qStrPairs.push(encodeURIComponent(prop) + '=' + encodeURIComponent(paramMap[prop])); 389 | } 390 | return '?' + qStrPairs.join('&'); 391 | } 392 | 393 | function queryStringToParamMap() { 394 | var paramStr = options.getWindowLocation().search.substring(1), 395 | params = [], 396 | paramMap = {}; 397 | 398 | if (paramStr.length > 0) { 399 | params = paramStr.split('&'); 400 | for (var i = 0; i < params.length; i++) { 401 | var p = params[i].split('='); 402 | var value = decodeURIComponent(p[1]); 403 | if (value === 'true' || value === 'false') { 404 | value = JSON.parse(value); 405 | } 406 | paramMap[decodeURIComponent(p[0])] = value; 407 | } 408 | } 409 | 410 | return paramMap; 411 | } 412 | 413 | } 414 | 415 | return QueryString; 416 | }; 417 | -------------------------------------------------------------------------------- /vendor/assets/libs/jasmine/jasmine.css: -------------------------------------------------------------------------------- 1 | body { overflow-y: scroll; } 2 | 3 | .jasmine_html-reporter { background-color: #eee; padding: 5px; margin: -8px; font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333; } 4 | .jasmine_html-reporter a { text-decoration: none; } 5 | .jasmine_html-reporter a:hover { text-decoration: underline; } 6 | .jasmine_html-reporter p, .jasmine_html-reporter h1, .jasmine_html-reporter h2, .jasmine_html-reporter h3, .jasmine_html-reporter h4, .jasmine_html-reporter h5, .jasmine_html-reporter h6 { margin: 0; line-height: 14px; } 7 | .jasmine_html-reporter .banner, .jasmine_html-reporter .symbol-summary, .jasmine_html-reporter .summary, .jasmine_html-reporter .result-message, .jasmine_html-reporter .spec .description, .jasmine_html-reporter .spec-detail .description, .jasmine_html-reporter .alert .bar, .jasmine_html-reporter .stack-trace { padding-left: 9px; padding-right: 9px; } 8 | .jasmine_html-reporter .banner { position: relative; } 9 | .jasmine_html-reporter .banner .title { background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAAAZCAMAAACGusnyAAACdlBMVEX/////AP+AgICqVaqAQICZM5mAVYCSSZKAQICOOY6ATYCLRouAQICJO4mSSYCIRIiPQICHPIeOR4CGQ4aMQICGPYaLRoCFQ4WKQICPPYWJRYCOQoSJQICNPoSIRICMQoSHQICHRICKQoOHQICKPoOJO4OJQYOMQICMQ4CIQYKLQICIPoKLQ4CKQICNPoKJQISMQ4KJQoSLQYKJQISLQ4KIQoSKQYKIQICIQISMQoSKQYKLQIOLQoOJQYGLQIOKQIOMQoGKQYOLQYGKQIOLQoGJQYOJQIOKQYGJQIOKQoGKQIGLQIKLQ4KKQoGLQYKJQIGKQYKJQIGKQIKJQoGKQYKLQIGKQYKLQIOJQoKKQoOJQYKKQIOJQoKKQoOKQIOLQoKKQYOLQYKJQIOKQoKKQYKKQoKJQYOKQYKLQIOKQoKLQYOKQYKLQIOJQoGKQYKJQYGJQoGKQYKLQoGLQYGKQoGJQYKKQYGJQIKKQoGJQYKLQIKKQYGLQYKKQYGKQYGKQYKJQYOKQoKJQYOKQYKLQYOLQYOKQYKLQYOKQoKKQYKKQYOKQYOJQYKKQYKLQYKKQIKKQoKKQYKKQYKKQoKJQIKKQYKLQYKKQYKKQIKKQYKKQYKKQYKKQIKKQYKJQYGLQYGKQYKKQYKKQYGKQIKKQYGKQYOJQoKKQYOLQYKKQYOKQoKKQYKKQoKKQYKKQYKJQYKLQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKJQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKLQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKKQYKmIDpEAAAA0XRSTlMAAQIDBAUGBwgJC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9yLWN1cnZhdHVyZT0iMCIKICAgICAgICAgICAgIGlkPSJwYXRoNTYiCiAgICAgICAgICAgICBzdHlsZT0iZmlsbDojOGE0MTgyO2ZpbGwtb3BhY2l0eToxO2ZpbGwtcnVsZTpub256ZXJvO3N0cm9rZTpub25lIiAvPjwvZz48L2c+PC9nPjwvZz48L3N2Zz4=') no-repeat, none; -moz-background-size: 100%; -o-background-size: 100%; -webkit-background-size: 100%; background-size: 100%; display: block; float: left; width: 90px; height: 25px; } 10 | .jasmine_html-reporter .banner .version { margin-left: 14px; position: relative; top: 6px; } 11 | .jasmine_html-reporter .banner .duration { position: absolute; right: 14px; top: 6px; } 12 | .jasmine_html-reporter #jasmine_content { position: fixed; right: 100%; } 13 | .jasmine_html-reporter .version { color: #aaa; } 14 | .jasmine_html-reporter .banner { margin-top: 14px; } 15 | .jasmine_html-reporter .duration { color: #aaa; float: right; } 16 | .jasmine_html-reporter .symbol-summary { overflow: hidden; *zoom: 1; margin: 14px 0; } 17 | .jasmine_html-reporter .symbol-summary li { display: inline-block; height: 8px; width: 14px; font-size: 16px; } 18 | .jasmine_html-reporter .symbol-summary li.passed { font-size: 14px; } 19 | .jasmine_html-reporter .symbol-summary li.passed:before { color: #007069; content: "\02022"; } 20 | .jasmine_html-reporter .symbol-summary li.failed { line-height: 9px; } 21 | .jasmine_html-reporter .symbol-summary li.failed:before { color: #ca3a11; content: "\d7"; font-weight: bold; margin-left: -1px; } 22 | .jasmine_html-reporter .symbol-summary li.disabled { font-size: 14px; } 23 | .jasmine_html-reporter .symbol-summary li.disabled:before { color: #bababa; content: "\02022"; } 24 | .jasmine_html-reporter .symbol-summary li.pending { line-height: 17px; } 25 | .jasmine_html-reporter .symbol-summary li.pending:before { color: #ba9d37; content: "*"; } 26 | .jasmine_html-reporter .symbol-summary li.empty { font-size: 14px; } 27 | .jasmine_html-reporter .symbol-summary li.empty:before { color: #ba9d37; content: "\02022"; } 28 | .jasmine_html-reporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; } 29 | .jasmine_html-reporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; } 30 | .jasmine_html-reporter .bar.failed { background-color: #ca3a11; } 31 | .jasmine_html-reporter .bar.passed { background-color: #007069; } 32 | .jasmine_html-reporter .bar.skipped { background-color: #bababa; } 33 | .jasmine_html-reporter .bar.errored { background-color: #ca3a11; } 34 | .jasmine_html-reporter .bar.menu { background-color: #fff; color: #aaa; } 35 | .jasmine_html-reporter .bar.menu a { color: #333; } 36 | .jasmine_html-reporter .bar a { color: white; } 37 | .jasmine_html-reporter.spec-list .bar.menu.failure-list, .jasmine_html-reporter.spec-list .results .failures { display: none; } 38 | .jasmine_html-reporter.failure-list .bar.menu.spec-list, .jasmine_html-reporter.failure-list .summary { display: none; } 39 | .jasmine_html-reporter .running-alert { background-color: #666; } 40 | .jasmine_html-reporter .results { margin-top: 14px; } 41 | .jasmine_html-reporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; } 42 | .jasmine_html-reporter.showDetails .summaryMenuItem:hover { text-decoration: underline; } 43 | .jasmine_html-reporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; } 44 | .jasmine_html-reporter.showDetails .summary { display: none; } 45 | .jasmine_html-reporter.showDetails #details { display: block; } 46 | .jasmine_html-reporter .summaryMenuItem { font-weight: bold; text-decoration: underline; } 47 | .jasmine_html-reporter .summary { margin-top: 14px; } 48 | .jasmine_html-reporter .summary ul { list-style-type: none; margin-left: 14px; padding-top: 0; padding-left: 0; } 49 | .jasmine_html-reporter .summary ul.suite { margin-top: 7px; margin-bottom: 7px; } 50 | .jasmine_html-reporter .summary li.passed a { color: #007069; } 51 | .jasmine_html-reporter .summary li.failed a { color: #ca3a11; } 52 | .jasmine_html-reporter .summary li.empty a { color: #ba9d37; } 53 | .jasmine_html-reporter .summary li.pending a { color: #ba9d37; } 54 | .jasmine_html-reporter .description + .suite { margin-top: 0; } 55 | .jasmine_html-reporter .suite { margin-top: 14px; } 56 | .jasmine_html-reporter .suite a { color: #333; } 57 | .jasmine_html-reporter .failures .spec-detail { margin-bottom: 28px; } 58 | .jasmine_html-reporter .failures .spec-detail .description { background-color: #ca3a11; } 59 | .jasmine_html-reporter .failures .spec-detail .description a { color: white; } 60 | .jasmine_html-reporter .result-message { padding-top: 14px; color: #333; white-space: pre; } 61 | .jasmine_html-reporter .result-message span.result { display: block; } 62 | .jasmine_html-reporter .stack-trace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666; border: 1px solid #ddd; background: white; white-space: pre; } 63 | -------------------------------------------------------------------------------- /vendor/assets/libs/jasmine/jasmine.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2008-2015 Pivotal Labs 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | */ 23 | var getJasmineRequireObj = (function (jasmineGlobal) { 24 | var jasmineRequire; 25 | 26 | if (typeof module !== 'undefined' && module.exports) { 27 | jasmineGlobal = global; 28 | jasmineRequire = exports; 29 | } else { 30 | if (typeof window !== 'undefined' && typeof window.toString === 'function' && window.toString() === '[object GjsGlobal]') { 31 | jasmineGlobal = window; 32 | } 33 | jasmineRequire = jasmineGlobal.jasmineRequire = jasmineGlobal.jasmineRequire || {}; 34 | } 35 | 36 | function getJasmineRequire() { 37 | return jasmineRequire; 38 | } 39 | 40 | getJasmineRequire().core = function(jRequire) { 41 | var j$ = {}; 42 | 43 | jRequire.base(j$, jasmineGlobal); 44 | j$.util = jRequire.util(); 45 | j$.Any = jRequire.Any(); 46 | j$.Anything = jRequire.Anything(j$); 47 | j$.CallTracker = jRequire.CallTracker(); 48 | j$.MockDate = jRequire.MockDate(); 49 | j$.Clock = jRequire.Clock(); 50 | j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(); 51 | j$.Env = jRequire.Env(j$); 52 | j$.ExceptionFormatter = jRequire.ExceptionFormatter(); 53 | j$.Expectation = jRequire.Expectation(); 54 | j$.buildExpectationResult = jRequire.buildExpectationResult(); 55 | j$.JsApiReporter = jRequire.JsApiReporter(); 56 | j$.matchersUtil = jRequire.matchersUtil(j$); 57 | j$.ObjectContaining = jRequire.ObjectContaining(j$); 58 | j$.ArrayContaining = jRequire.ArrayContaining(j$); 59 | j$.pp = jRequire.pp(j$); 60 | j$.QueueRunner = jRequire.QueueRunner(j$); 61 | j$.ReportDispatcher = jRequire.ReportDispatcher(); 62 | j$.Spec = jRequire.Spec(j$); 63 | j$.SpyRegistry = jRequire.SpyRegistry(j$); 64 | j$.SpyStrategy = jRequire.SpyStrategy(); 65 | j$.StringMatching = jRequire.StringMatching(j$); 66 | j$.Suite = jRequire.Suite(); 67 | j$.Timer = jRequire.Timer(); 68 | j$.version = jRequire.version(); 69 | 70 | j$.matchers = jRequire.requireMatchers(jRequire, j$); 71 | 72 | return j$; 73 | }; 74 | 75 | return getJasmineRequire; 76 | })(this); 77 | 78 | getJasmineRequireObj().requireMatchers = function(jRequire, j$) { 79 | var availableMatchers = [ 80 | 'toBe', 81 | 'toBeCloseTo', 82 | 'toBeDefined', 83 | 'toBeFalsy', 84 | 'toBeGreaterThan', 85 | 'toBeLessThan', 86 | 'toBeNaN', 87 | 'toBeNull', 88 | 'toBeTruthy', 89 | 'toBeUndefined', 90 | 'toContain', 91 | 'toEqual', 92 | 'toHaveBeenCalled', 93 | 'toHaveBeenCalledWith', 94 | 'toMatch', 95 | 'toThrow', 96 | 'toThrowError' 97 | ], 98 | matchers = {}; 99 | 100 | for (var i = 0; i < availableMatchers.length; i++) { 101 | var name = availableMatchers[i]; 102 | matchers[name] = jRequire[name](j$); 103 | } 104 | 105 | return matchers; 106 | }; 107 | 108 | getJasmineRequireObj().base = function(j$, jasmineGlobal) { 109 | j$.unimplementedMethod_ = function() { 110 | throw new Error('unimplemented method'); 111 | }; 112 | 113 | j$.MAX_PRETTY_PRINT_DEPTH = 40; 114 | j$.MAX_PRETTY_PRINT_ARRAY_LENGTH = 100; 115 | j$.DEFAULT_TIMEOUT_INTERVAL = 5000; 116 | 117 | j$.getGlobal = function() { 118 | return jasmineGlobal; 119 | }; 120 | 121 | j$.getEnv = function(options) { 122 | var env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options); 123 | //jasmine. singletons in here (setTimeout blah blah). 124 | return env; 125 | }; 126 | 127 | j$.isArray_ = function(value) { 128 | return j$.isA_('Array', value); 129 | }; 130 | 131 | j$.isString_ = function(value) { 132 | return j$.isA_('String', value); 133 | }; 134 | 135 | j$.isNumber_ = function(value) { 136 | return j$.isA_('Number', value); 137 | }; 138 | 139 | j$.isA_ = function(typeName, value) { 140 | return Object.prototype.toString.apply(value) === '[object ' + typeName + ']'; 141 | }; 142 | 143 | j$.isDomNode = function(obj) { 144 | return obj.nodeType > 0; 145 | }; 146 | 147 | j$.fnNameFor = function(func) { 148 | return func.name || func.toString().match(/^\s*function\s*(\w*)\s*\(/)[1]; 149 | }; 150 | 151 | j$.any = function(clazz) { 152 | return new j$.Any(clazz); 153 | }; 154 | 155 | j$.anything = function() { 156 | return new j$.Anything(); 157 | }; 158 | 159 | j$.objectContaining = function(sample) { 160 | return new j$.ObjectContaining(sample); 161 | }; 162 | 163 | j$.stringMatching = function(expected) { 164 | return new j$.StringMatching(expected); 165 | }; 166 | 167 | j$.arrayContaining = function(sample) { 168 | return new j$.ArrayContaining(sample); 169 | }; 170 | 171 | j$.createSpy = function(name, originalFn) { 172 | 173 | var spyStrategy = new j$.SpyStrategy({ 174 | name: name, 175 | fn: originalFn, 176 | getSpy: function() { return spy; } 177 | }), 178 | callTracker = new j$.CallTracker(), 179 | spy = function() { 180 | var callData = { 181 | object: this, 182 | args: Array.prototype.slice.apply(arguments) 183 | }; 184 | 185 | callTracker.track(callData); 186 | var returnValue = spyStrategy.exec.apply(this, arguments); 187 | callData.returnValue = returnValue; 188 | 189 | return returnValue; 190 | }; 191 | 192 | for (var prop in originalFn) { 193 | if (prop === 'and' || prop === 'calls') { 194 | throw new Error('Jasmine spies would overwrite the \'and\' and \'calls\' properties on the object being spied upon'); 195 | } 196 | 197 | spy[prop] = originalFn[prop]; 198 | } 199 | 200 | spy.and = spyStrategy; 201 | spy.calls = callTracker; 202 | 203 | return spy; 204 | }; 205 | 206 | j$.isSpy = function(putativeSpy) { 207 | if (!putativeSpy) { 208 | return false; 209 | } 210 | return putativeSpy.and instanceof j$.SpyStrategy && 211 | putativeSpy.calls instanceof j$.CallTracker; 212 | }; 213 | 214 | j$.createSpyObj = function(baseName, methodNames) { 215 | if (j$.isArray_(baseName) && j$.util.isUndefined(methodNames)) { 216 | methodNames = baseName; 217 | baseName = 'unknown'; 218 | } 219 | 220 | if (!j$.isArray_(methodNames) || methodNames.length === 0) { 221 | throw 'createSpyObj requires a non-empty array of method names to create spies for'; 222 | } 223 | var obj = {}; 224 | for (var i = 0; i < methodNames.length; i++) { 225 | obj[methodNames[i]] = j$.createSpy(baseName + '.' + methodNames[i]); 226 | } 227 | return obj; 228 | }; 229 | }; 230 | 231 | getJasmineRequireObj().util = function() { 232 | 233 | var util = {}; 234 | 235 | util.inherit = function(childClass, parentClass) { 236 | var Subclass = function() { 237 | }; 238 | Subclass.prototype = parentClass.prototype; 239 | childClass.prototype = new Subclass(); 240 | }; 241 | 242 | util.htmlEscape = function(str) { 243 | if (!str) { 244 | return str; 245 | } 246 | return str.replace(/&/g, '&') 247 | .replace(//g, '>'); 249 | }; 250 | 251 | util.argsToArray = function(args) { 252 | var arrayOfArgs = []; 253 | for (var i = 0; i < args.length; i++) { 254 | arrayOfArgs.push(args[i]); 255 | } 256 | return arrayOfArgs; 257 | }; 258 | 259 | util.isUndefined = function(obj) { 260 | return obj === void 0; 261 | }; 262 | 263 | util.arrayContains = function(array, search) { 264 | var i = array.length; 265 | while (i--) { 266 | if (array[i] === search) { 267 | return true; 268 | } 269 | } 270 | return false; 271 | }; 272 | 273 | util.clone = function(obj) { 274 | if (Object.prototype.toString.apply(obj) === '[object Array]') { 275 | return obj.slice(); 276 | } 277 | 278 | var cloned = {}; 279 | for (var prop in obj) { 280 | if (obj.hasOwnProperty(prop)) { 281 | cloned[prop] = obj[prop]; 282 | } 283 | } 284 | 285 | return cloned; 286 | }; 287 | 288 | return util; 289 | }; 290 | 291 | getJasmineRequireObj().Spec = function(j$) { 292 | function Spec(attrs) { 293 | this.expectationFactory = attrs.expectationFactory; 294 | this.resultCallback = attrs.resultCallback || function() {}; 295 | this.id = attrs.id; 296 | this.description = attrs.description || ''; 297 | this.queueableFn = attrs.queueableFn; 298 | this.beforeAndAfterFns = attrs.beforeAndAfterFns || function() { return {befores: [], afters: []}; }; 299 | this.userContext = attrs.userContext || function() { return {}; }; 300 | this.onStart = attrs.onStart || function() {}; 301 | this.getSpecName = attrs.getSpecName || function() { return ''; }; 302 | this.expectationResultFactory = attrs.expectationResultFactory || function() { }; 303 | this.queueRunnerFactory = attrs.queueRunnerFactory || function() {}; 304 | this.catchingExceptions = attrs.catchingExceptions || function() { return true; }; 305 | 306 | if (!this.queueableFn.fn) { 307 | this.pend(); 308 | } 309 | 310 | this.result = { 311 | id: this.id, 312 | description: this.description, 313 | fullName: this.getFullName(), 314 | failedExpectations: [], 315 | passedExpectations: [], 316 | pendingReason: '' 317 | }; 318 | } 319 | 320 | Spec.prototype.addExpectationResult = function(passed, data) { 321 | var expectationResult = this.expectationResultFactory(data); 322 | if (passed) { 323 | this.result.passedExpectations.push(expectationResult); 324 | } else { 325 | this.result.failedExpectations.push(expectationResult); 326 | } 327 | }; 328 | 329 | Spec.prototype.expect = function(actual) { 330 | return this.expectationFactory(actual, this); 331 | }; 332 | 333 | Spec.prototype.execute = function(onComplete) { 334 | var self = this; 335 | 336 | this.onStart(this); 337 | 338 | if (this.markedPending || this.disabled) { 339 | complete(); 340 | return; 341 | } 342 | 343 | var fns = this.beforeAndAfterFns(); 344 | var allFns = fns.befores.concat(this.queueableFn).concat(fns.afters); 345 | 346 | this.queueRunnerFactory({ 347 | queueableFns: allFns, 348 | onException: function() { self.onException.apply(self, arguments); }, 349 | onComplete: complete, 350 | userContext: this.userContext() 351 | }); 352 | 353 | function complete() { 354 | self.result.status = self.status(); 355 | self.resultCallback(self.result); 356 | 357 | if (onComplete) { 358 | onComplete(); 359 | } 360 | } 361 | }; 362 | 363 | Spec.prototype.onException = function onException(e) { 364 | if (Spec.isPendingSpecException(e)) { 365 | this.pend(extractCustomPendingMessage(e)); 366 | return; 367 | } 368 | 369 | this.addExpectationResult(false, { 370 | matcherName: '', 371 | passed: false, 372 | expected: '', 373 | actual: '', 374 | error: e 375 | }); 376 | }; 377 | 378 | Spec.prototype.disable = function() { 379 | this.disabled = true; 380 | }; 381 | 382 | Spec.prototype.pend = function(message) { 383 | this.markedPending = true; 384 | if (message) { 385 | this.result.pendingReason = message; 386 | } 387 | }; 388 | 389 | Spec.prototype.status = function() { 390 | if (this.disabled) { 391 | return 'disabled'; 392 | } 393 | 394 | if (this.markedPending) { 395 | return 'pending'; 396 | } 397 | 398 | if (this.result.failedExpectations.length > 0) { 399 | return 'failed'; 400 | } else { 401 | return 'passed'; 402 | } 403 | }; 404 | 405 | Spec.prototype.isExecutable = function() { 406 | return !this.disabled && !this.markedPending; 407 | }; 408 | 409 | Spec.prototype.getFullName = function() { 410 | return this.getSpecName(this); 411 | }; 412 | 413 | var extractCustomPendingMessage = function(e) { 414 | var fullMessage = e.toString(), 415 | boilerplateStart = fullMessage.indexOf(Spec.pendingSpecExceptionMessage), 416 | boilerplateEnd = boilerplateStart + Spec.pendingSpecExceptionMessage.length; 417 | 418 | return fullMessage.substr(boilerplateEnd); 419 | }; 420 | 421 | Spec.pendingSpecExceptionMessage = '=> marked Pending'; 422 | 423 | Spec.isPendingSpecException = function(e) { 424 | return !!(e && e.toString && e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1); 425 | }; 426 | 427 | return Spec; 428 | }; 429 | 430 | if (typeof window == void 0 && typeof exports == 'object') { 431 | exports.Spec = jasmineRequire.Spec; 432 | } 433 | 434 | getJasmineRequireObj().Env = function(j$) { 435 | function Env(options) { 436 | options = options || {}; 437 | 438 | var self = this; 439 | var global = options.global || j$.getGlobal(); 440 | 441 | var totalSpecsDefined = 0; 442 | 443 | var catchExceptions = true; 444 | 445 | var realSetTimeout = j$.getGlobal().setTimeout; 446 | var realClearTimeout = j$.getGlobal().clearTimeout; 447 | this.clock = new j$.Clock(global, new j$.DelayedFunctionScheduler(), new j$.MockDate(global)); 448 | 449 | var runnableLookupTable = {}; 450 | var runnableResources = {}; 451 | 452 | var currentSpec = null; 453 | var currentlyExecutingSuites = []; 454 | var currentDeclarationSuite = null; 455 | 456 | var currentSuite = function() { 457 | return currentlyExecutingSuites[currentlyExecutingSuites.length - 1]; 458 | }; 459 | 460 | var currentRunnable = function() { 461 | return currentSpec || currentSuite(); 462 | }; 463 | 464 | var reporter = new j$.ReportDispatcher([ 465 | 'jasmineStarted', 466 | 'jasmineDone', 467 | 'suiteStarted', 468 | 'suiteDone', 469 | 'specStarted', 470 | 'specDone' 471 | ]); 472 | 473 | this.specFilter = function() { 474 | return true; 475 | }; 476 | 477 | this.addCustomEqualityTester = function(tester) { 478 | if(!currentRunnable()) { 479 | throw new Error('Custom Equalities must be added in a before function or a spec'); 480 | } 481 | runnableResources[currentRunnable().id].customEqualityTesters.push(tester); 482 | }; 483 | 484 | this.addMatchers = function(matchersToAdd) { 485 | if(!currentRunnable()) { 486 | throw new Error('Matchers must be added in a before function or a spec'); 487 | } 488 | var customMatchers = runnableResources[currentRunnable().id].customMatchers; 489 | for (var matcherName in matchersToAdd) { 490 | customMatchers[matcherName] = matchersToAdd[matcherName]; 491 | } 492 | }; 493 | 494 | j$.Expectation.addCoreMatchers(j$.matchers); 495 | 496 | var nextSpecId = 0; 497 | var getNextSpecId = function() { 498 | return 'spec' + nextSpecId++; 499 | }; 500 | 501 | var nextSuiteId = 0; 502 | var getNextSuiteId = function() { 503 | return 'suite' + nextSuiteId++; 504 | }; 505 | 506 | var expectationFactory = function(actual, spec) { 507 | return j$.Expectation.Factory({ 508 | util: j$.matchersUtil, 509 | customEqualityTesters: runnableResources[spec.id].customEqualityTesters, 510 | customMatchers: runnableResources[spec.id].customMatchers, 511 | actual: actual, 512 | addExpectationResult: addExpectationResult 513 | }); 514 | 515 | function addExpectationResult(passed, result) { 516 | return spec.addExpectationResult(passed, result); 517 | } 518 | }; 519 | 520 | var defaultResourcesForRunnable = function(id, parentRunnableId) { 521 | var resources = {spies: [], customEqualityTesters: [], customMatchers: {}}; 522 | 523 | if(runnableResources[parentRunnableId]){ 524 | resources.customEqualityTesters = j$.util.clone(runnableResources[parentRunnableId].customEqualityTesters); 525 | resources.customMatchers = j$.util.clone(runnableResources[parentRunnableId].customMatchers); 526 | } 527 | 528 | runnableResources[id] = resources; 529 | }; 530 | 531 | var clearResourcesForRunnable = function(id) { 532 | spyRegistry.clearSpies(); 533 | delete runnableResources[id]; 534 | }; 535 | 536 | var beforeAndAfterFns = function(suite, runnablesExplictlySet) { 537 | return function() { 538 | var befores = [], 539 | afters = [], 540 | beforeAlls = [], 541 | afterAlls = []; 542 | 543 | while(suite) { 544 | befores = befores.concat(suite.beforeFns); 545 | afters = afters.concat(suite.afterFns); 546 | 547 | if (runnablesExplictlySet()) { 548 | beforeAlls = beforeAlls.concat(suite.beforeAllFns); 549 | afterAlls = afterAlls.concat(suite.afterAllFns); 550 | } 551 | 552 | suite = suite.parentSuite; 553 | } 554 | return { 555 | befores: beforeAlls.reverse().concat(befores.reverse()), 556 | afters: afters.concat(afterAlls) 557 | }; 558 | }; 559 | }; 560 | 561 | var getSpecName = function(spec, suite) { 562 | return suite.getFullName() + ' ' + spec.description; 563 | }; 564 | 565 | // TODO: we may just be able to pass in the fn instead of wrapping here 566 | var buildExpectationResult = j$.buildExpectationResult, 567 | exceptionFormatter = new j$.ExceptionFormatter(), 568 | expectationResultFactory = function(attrs) { 569 | attrs.messageFormatter = exceptionFormatter.message; 570 | attrs.stackFormatter = exceptionFormatter.stack; 571 | 572 | return buildExpectationResult(attrs); 573 | }; 574 | 575 | // TODO: fix this naming, and here's where the value comes in 576 | this.catchExceptions = function(value) { 577 | catchExceptions = !!value; 578 | return catchExceptions; 579 | }; 580 | 581 | this.catchingExceptions = function() { 582 | return catchExceptions; 583 | }; 584 | 585 | var maximumSpecCallbackDepth = 20; 586 | var currentSpecCallbackDepth = 0; 587 | 588 | function clearStack(fn) { 589 | currentSpecCallbackDepth++; 590 | if (currentSpecCallbackDepth >= maximumSpecCallbackDepth) { 591 | currentSpecCallbackDepth = 0; 592 | realSetTimeout(fn, 0); 593 | } else { 594 | fn(); 595 | } 596 | } 597 | 598 | var catchException = function(e) { 599 | return j$.Spec.isPendingSpecException(e) || catchExceptions; 600 | }; 601 | 602 | var queueRunnerFactory = function(options) { 603 | options.catchException = catchException; 604 | options.clearStack = options.clearStack || clearStack; 605 | options.timer = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout}; 606 | options.fail = self.fail; 607 | 608 | new j$.QueueRunner(options).execute(); 609 | }; 610 | 611 | var topSuite = new j$.Suite({ 612 | env: this, 613 | id: getNextSuiteId(), 614 | description: 'Jasmine__TopLevel__Suite', 615 | queueRunner: queueRunnerFactory 616 | }); 617 | runnableLookupTable[topSuite.id] = topSuite; 618 | defaultResourcesForRunnable(topSuite.id); 619 | currentDeclarationSuite = topSuite; 620 | 621 | this.topSuite = function() { 622 | return topSuite; 623 | }; 624 | 625 | this.execute = function(runnablesToRun) { 626 | if(runnablesToRun) { 627 | runnablesExplictlySet = true; 628 | } else if (focusedRunnables.length) { 629 | runnablesExplictlySet = true; 630 | runnablesToRun = focusedRunnables; 631 | } else { 632 | runnablesToRun = [topSuite.id]; 633 | } 634 | 635 | var allFns = []; 636 | for(var i = 0; i < runnablesToRun.length; i++) { 637 | var runnable = runnableLookupTable[runnablesToRun[i]]; 638 | allFns.push((function(runnable) { return { fn: function(done) { runnable.execute(done); } }; })(runnable)); 639 | } 640 | 641 | reporter.jasmineStarted({ 642 | totalSpecsDefined: totalSpecsDefined 643 | }); 644 | 645 | queueRunnerFactory({queueableFns: allFns, onComplete: reporter.jasmineDone}); 646 | }; 647 | 648 | this.addReporter = function(reporterToAdd) { 649 | reporter.addReporter(reporterToAdd); 650 | }; 651 | 652 | var spyRegistry = new j$.SpyRegistry({currentSpies: function() { 653 | if(!currentRunnable()) { 654 | throw new Error('Spies must be created in a before function or a spec'); 655 | } 656 | return runnableResources[currentRunnable().id].spies; 657 | }}); 658 | 659 | this.spyOn = function() { 660 | return spyRegistry.spyOn.apply(spyRegistry, arguments); 661 | }; 662 | 663 | var suiteFactory = function(description) { 664 | var suite = new j$.Suite({ 665 | env: self, 666 | id: getNextSuiteId(), 667 | description: description, 668 | parentSuite: currentDeclarationSuite, 669 | queueRunner: queueRunnerFactory, 670 | onStart: suiteStarted, 671 | expectationFactory: expectationFactory, 672 | expectationResultFactory: expectationResultFactory, 673 | runnablesExplictlySetGetter: runnablesExplictlySetGetter, 674 | resultCallback: function(attrs) { 675 | if (!suite.disabled) { 676 | clearResourcesForRunnable(suite.id); 677 | } 678 | currentlyExecutingSuites.pop(); 679 | reporter.suiteDone(attrs); 680 | } 681 | }); 682 | 683 | runnableLookupTable[suite.id] = suite; 684 | return suite; 685 | 686 | function suiteStarted(suite) { 687 | currentlyExecutingSuites.push(suite); 688 | defaultResourcesForRunnable(suite.id, suite.parentSuite.id); 689 | reporter.suiteStarted(suite.result); 690 | } 691 | }; 692 | 693 | this.describe = function(description, specDefinitions) { 694 | var suite = suiteFactory(description); 695 | addSpecsToSuite(suite, specDefinitions); 696 | return suite; 697 | }; 698 | 699 | this.xdescribe = function(description, specDefinitions) { 700 | var suite = this.describe(description, specDefinitions); 701 | suite.disable(); 702 | return suite; 703 | }; 704 | 705 | var focusedRunnables = []; 706 | 707 | this.fdescribe = function(description, specDefinitions) { 708 | var suite = suiteFactory(description); 709 | suite.isFocused = true; 710 | 711 | focusedRunnables.push(suite.id); 712 | unfocusAncestor(); 713 | addSpecsToSuite(suite, specDefinitions); 714 | 715 | return suite; 716 | }; 717 | 718 | function addSpecsToSuite(suite, specDefinitions) { 719 | var parentSuite = currentDeclarationSuite; 720 | parentSuite.addChild(suite); 721 | currentDeclarationSuite = suite; 722 | 723 | var declarationError = null; 724 | try { 725 | specDefinitions.call(suite); 726 | } catch (e) { 727 | declarationError = e; 728 | } 729 | 730 | if (declarationError) { 731 | self.it('encountered a declaration exception', function() { 732 | throw declarationError; 733 | }); 734 | } 735 | 736 | currentDeclarationSuite = parentSuite; 737 | } 738 | 739 | function findFocusedAncestor(suite) { 740 | while (suite) { 741 | if (suite.isFocused) { 742 | return suite.id; 743 | } 744 | suite = suite.parentSuite; 745 | } 746 | 747 | return null; 748 | } 749 | 750 | function unfocusAncestor() { 751 | var focusedAncestor = findFocusedAncestor(currentDeclarationSuite); 752 | if (focusedAncestor) { 753 | for (var i = 0; i < focusedRunnables.length; i++) { 754 | if (focusedRunnables[i] === focusedAncestor) { 755 | focusedRunnables.splice(i, 1); 756 | break; 757 | } 758 | } 759 | } 760 | } 761 | 762 | var runnablesExplictlySet = false; 763 | 764 | var runnablesExplictlySetGetter = function(){ 765 | return runnablesExplictlySet; 766 | }; 767 | 768 | var specFactory = function(description, fn, suite, timeout) { 769 | totalSpecsDefined++; 770 | var spec = new j$.Spec({ 771 | id: getNextSpecId(), 772 | beforeAndAfterFns: beforeAndAfterFns(suite, runnablesExplictlySetGetter), 773 | expectationFactory: expectationFactory, 774 | resultCallback: specResultCallback, 775 | getSpecName: function(spec) { 776 | return getSpecName(spec, suite); 777 | }, 778 | onStart: specStarted, 779 | description: description, 780 | expectationResultFactory: expectationResultFactory, 781 | queueRunnerFactory: queueRunnerFactory, 782 | userContext: function() { return suite.clonedSharedUserContext(); }, 783 | queueableFn: { 784 | fn: fn, 785 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; } 786 | } 787 | }); 788 | 789 | runnableLookupTable[spec.id] = spec; 790 | 791 | if (!self.specFilter(spec)) { 792 | spec.disable(); 793 | } 794 | 795 | return spec; 796 | 797 | function specResultCallback(result) { 798 | clearResourcesForRunnable(spec.id); 799 | currentSpec = null; 800 | reporter.specDone(result); 801 | } 802 | 803 | function specStarted(spec) { 804 | currentSpec = spec; 805 | defaultResourcesForRunnable(spec.id, suite.id); 806 | reporter.specStarted(spec.result); 807 | } 808 | }; 809 | 810 | this.it = function(description, fn, timeout) { 811 | var spec = specFactory(description, fn, currentDeclarationSuite, timeout); 812 | currentDeclarationSuite.addChild(spec); 813 | return spec; 814 | }; 815 | 816 | this.xit = function() { 817 | var spec = this.it.apply(this, arguments); 818 | spec.pend(); 819 | return spec; 820 | }; 821 | 822 | this.fit = function(){ 823 | var spec = this.it.apply(this, arguments); 824 | 825 | focusedRunnables.push(spec.id); 826 | unfocusAncestor(); 827 | return spec; 828 | }; 829 | 830 | this.expect = function(actual) { 831 | if (!currentRunnable()) { 832 | throw new Error('\'expect\' was used when there was no current spec, this could be because an asynchronous test timed out'); 833 | } 834 | 835 | return currentRunnable().expect(actual); 836 | }; 837 | 838 | this.beforeEach = function(beforeEachFunction, timeout) { 839 | currentDeclarationSuite.beforeEach({ 840 | fn: beforeEachFunction, 841 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; } 842 | }); 843 | }; 844 | 845 | this.beforeAll = function(beforeAllFunction, timeout) { 846 | currentDeclarationSuite.beforeAll({ 847 | fn: beforeAllFunction, 848 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; } 849 | }); 850 | }; 851 | 852 | this.afterEach = function(afterEachFunction, timeout) { 853 | currentDeclarationSuite.afterEach({ 854 | fn: afterEachFunction, 855 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; } 856 | }); 857 | }; 858 | 859 | this.afterAll = function(afterAllFunction, timeout) { 860 | currentDeclarationSuite.afterAll({ 861 | fn: afterAllFunction, 862 | timeout: function() { return timeout || j$.DEFAULT_TIMEOUT_INTERVAL; } 863 | }); 864 | }; 865 | 866 | this.pending = function(message) { 867 | var fullMessage = j$.Spec.pendingSpecExceptionMessage; 868 | if(message) { 869 | fullMessage += message; 870 | } 871 | throw fullMessage; 872 | }; 873 | 874 | this.fail = function(error) { 875 | var message = 'Failed'; 876 | if (error) { 877 | message += ': '; 878 | message += error.message || error; 879 | } 880 | 881 | currentRunnable().addExpectationResult(false, { 882 | matcherName: '', 883 | passed: false, 884 | expected: '', 885 | actual: '', 886 | message: message, 887 | error: error && error.message ? error : null 888 | }); 889 | }; 890 | } 891 | 892 | return Env; 893 | }; 894 | 895 | getJasmineRequireObj().JsApiReporter = function() { 896 | 897 | var noopTimer = { 898 | start: function(){}, 899 | elapsed: function(){ return 0; } 900 | }; 901 | 902 | function JsApiReporter(options) { 903 | var timer = options.timer || noopTimer, 904 | status = 'loaded'; 905 | 906 | this.started = false; 907 | this.finished = false; 908 | 909 | this.jasmineStarted = function() { 910 | this.started = true; 911 | status = 'started'; 912 | timer.start(); 913 | }; 914 | 915 | var executionTime; 916 | 917 | this.jasmineDone = function() { 918 | this.finished = true; 919 | executionTime = timer.elapsed(); 920 | status = 'done'; 921 | }; 922 | 923 | this.status = function() { 924 | return status; 925 | }; 926 | 927 | var suites = [], 928 | suites_hash = {}; 929 | 930 | this.suiteStarted = function(result) { 931 | suites_hash[result.id] = result; 932 | }; 933 | 934 | this.suiteDone = function(result) { 935 | storeSuite(result); 936 | }; 937 | 938 | this.suiteResults = function(index, length) { 939 | return suites.slice(index, index + length); 940 | }; 941 | 942 | function storeSuite(result) { 943 | suites.push(result); 944 | suites_hash[result.id] = result; 945 | } 946 | 947 | this.suites = function() { 948 | return suites_hash; 949 | }; 950 | 951 | var specs = []; 952 | 953 | this.specDone = function(result) { 954 | specs.push(result); 955 | }; 956 | 957 | this.specResults = function(index, length) { 958 | return specs.slice(index, index + length); 959 | }; 960 | 961 | this.specs = function() { 962 | return specs; 963 | }; 964 | 965 | this.executionTime = function() { 966 | return executionTime; 967 | }; 968 | 969 | } 970 | 971 | return JsApiReporter; 972 | }; 973 | 974 | getJasmineRequireObj().CallTracker = function() { 975 | 976 | function CallTracker() { 977 | var calls = []; 978 | 979 | this.track = function(context) { 980 | calls.push(context); 981 | }; 982 | 983 | this.any = function() { 984 | return !!calls.length; 985 | }; 986 | 987 | this.count = function() { 988 | return calls.length; 989 | }; 990 | 991 | this.argsFor = function(index) { 992 | var call = calls[index]; 993 | return call ? call.args : []; 994 | }; 995 | 996 | this.all = function() { 997 | return calls; 998 | }; 999 | 1000 | this.allArgs = function() { 1001 | var callArgs = []; 1002 | for(var i = 0; i < calls.length; i++){ 1003 | callArgs.push(calls[i].args); 1004 | } 1005 | 1006 | return callArgs; 1007 | }; 1008 | 1009 | this.first = function() { 1010 | return calls[0]; 1011 | }; 1012 | 1013 | this.mostRecent = function() { 1014 | return calls[calls.length - 1]; 1015 | }; 1016 | 1017 | this.reset = function() { 1018 | calls = []; 1019 | }; 1020 | } 1021 | 1022 | return CallTracker; 1023 | }; 1024 | 1025 | getJasmineRequireObj().Clock = function() { 1026 | function Clock(global, delayedFunctionScheduler, mockDate) { 1027 | var self = this, 1028 | realTimingFunctions = { 1029 | setTimeout: global.setTimeout, 1030 | clearTimeout: global.clearTimeout, 1031 | setInterval: global.setInterval, 1032 | clearInterval: global.clearInterval 1033 | }, 1034 | fakeTimingFunctions = { 1035 | setTimeout: setTimeout, 1036 | clearTimeout: clearTimeout, 1037 | setInterval: setInterval, 1038 | clearInterval: clearInterval 1039 | }, 1040 | installed = false, 1041 | timer; 1042 | 1043 | 1044 | self.install = function() { 1045 | replace(global, fakeTimingFunctions); 1046 | timer = fakeTimingFunctions; 1047 | installed = true; 1048 | 1049 | return self; 1050 | }; 1051 | 1052 | self.uninstall = function() { 1053 | delayedFunctionScheduler.reset(); 1054 | mockDate.uninstall(); 1055 | replace(global, realTimingFunctions); 1056 | 1057 | timer = realTimingFunctions; 1058 | installed = false; 1059 | }; 1060 | 1061 | self.mockDate = function(initialDate) { 1062 | mockDate.install(initialDate); 1063 | }; 1064 | 1065 | self.setTimeout = function(fn, delay, params) { 1066 | if (legacyIE()) { 1067 | if (arguments.length > 2) { 1068 | throw new Error('IE < 9 cannot support extra params to setTimeout without a polyfill'); 1069 | } 1070 | return timer.setTimeout(fn, delay); 1071 | } 1072 | return Function.prototype.apply.apply(timer.setTimeout, [global, arguments]); 1073 | }; 1074 | 1075 | self.setInterval = function(fn, delay, params) { 1076 | if (legacyIE()) { 1077 | if (arguments.length > 2) { 1078 | throw new Error('IE < 9 cannot support extra params to setInterval without a polyfill'); 1079 | } 1080 | return timer.setInterval(fn, delay); 1081 | } 1082 | return Function.prototype.apply.apply(timer.setInterval, [global, arguments]); 1083 | }; 1084 | 1085 | self.clearTimeout = function(id) { 1086 | return Function.prototype.call.apply(timer.clearTimeout, [global, id]); 1087 | }; 1088 | 1089 | self.clearInterval = function(id) { 1090 | return Function.prototype.call.apply(timer.clearInterval, [global, id]); 1091 | }; 1092 | 1093 | self.tick = function(millis) { 1094 | if (installed) { 1095 | mockDate.tick(millis); 1096 | delayedFunctionScheduler.tick(millis); 1097 | } else { 1098 | throw new Error('Mock clock is not installed, use jasmine.clock().install()'); 1099 | } 1100 | }; 1101 | 1102 | return self; 1103 | 1104 | function legacyIE() { 1105 | //if these methods are polyfilled, apply will be present 1106 | return !(realTimingFunctions.setTimeout || realTimingFunctions.setInterval).apply; 1107 | } 1108 | 1109 | function replace(dest, source) { 1110 | for (var prop in source) { 1111 | dest[prop] = source[prop]; 1112 | } 1113 | } 1114 | 1115 | function setTimeout(fn, delay) { 1116 | return delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2)); 1117 | } 1118 | 1119 | function clearTimeout(id) { 1120 | return delayedFunctionScheduler.removeFunctionWithId(id); 1121 | } 1122 | 1123 | function setInterval(fn, interval) { 1124 | return delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true); 1125 | } 1126 | 1127 | function clearInterval(id) { 1128 | return delayedFunctionScheduler.removeFunctionWithId(id); 1129 | } 1130 | 1131 | function argSlice(argsObj, n) { 1132 | return Array.prototype.slice.call(argsObj, n); 1133 | } 1134 | } 1135 | 1136 | return Clock; 1137 | }; 1138 | 1139 | getJasmineRequireObj().DelayedFunctionScheduler = function() { 1140 | function DelayedFunctionScheduler() { 1141 | var self = this; 1142 | var scheduledLookup = []; 1143 | var scheduledFunctions = {}; 1144 | var currentTime = 0; 1145 | var delayedFnCount = 0; 1146 | 1147 | self.tick = function(millis) { 1148 | millis = millis || 0; 1149 | var endTime = currentTime + millis; 1150 | 1151 | runScheduledFunctions(endTime); 1152 | currentTime = endTime; 1153 | }; 1154 | 1155 | self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) { 1156 | var f; 1157 | if (typeof(funcToCall) === 'string') { 1158 | /* jshint evil: true */ 1159 | f = function() { return eval(funcToCall); }; 1160 | /* jshint evil: false */ 1161 | } else { 1162 | f = funcToCall; 1163 | } 1164 | 1165 | millis = millis || 0; 1166 | timeoutKey = timeoutKey || ++delayedFnCount; 1167 | runAtMillis = runAtMillis || (currentTime + millis); 1168 | 1169 | var funcToSchedule = { 1170 | runAtMillis: runAtMillis, 1171 | funcToCall: f, 1172 | recurring: recurring, 1173 | params: params, 1174 | timeoutKey: timeoutKey, 1175 | millis: millis 1176 | }; 1177 | 1178 | if (runAtMillis in scheduledFunctions) { 1179 | scheduledFunctions[runAtMillis].push(funcToSchedule); 1180 | } else { 1181 | scheduledFunctions[runAtMillis] = [funcToSchedule]; 1182 | scheduledLookup.push(runAtMillis); 1183 | scheduledLookup.sort(function (a, b) { 1184 | return a - b; 1185 | }); 1186 | } 1187 | 1188 | return timeoutKey; 1189 | }; 1190 | 1191 | self.removeFunctionWithId = function(timeoutKey) { 1192 | for (var runAtMillis in scheduledFunctions) { 1193 | var funcs = scheduledFunctions[runAtMillis]; 1194 | var i = indexOfFirstToPass(funcs, function (func) { 1195 | return func.timeoutKey === timeoutKey; 1196 | }); 1197 | 1198 | if (i > -1) { 1199 | if (funcs.length === 1) { 1200 | delete scheduledFunctions[runAtMillis]; 1201 | deleteFromLookup(runAtMillis); 1202 | } else { 1203 | funcs.splice(i, 1); 1204 | } 1205 | 1206 | // intervals get rescheduled when executed, so there's never more 1207 | // than a single scheduled function with a given timeoutKey 1208 | break; 1209 | } 1210 | } 1211 | }; 1212 | 1213 | self.reset = function() { 1214 | currentTime = 0; 1215 | scheduledLookup = []; 1216 | scheduledFunctions = {}; 1217 | delayedFnCount = 0; 1218 | }; 1219 | 1220 | return self; 1221 | 1222 | function indexOfFirstToPass(array, testFn) { 1223 | var index = -1; 1224 | 1225 | for (var i = 0; i < array.length; ++i) { 1226 | if (testFn(array[i])) { 1227 | index = i; 1228 | break; 1229 | } 1230 | } 1231 | 1232 | return index; 1233 | } 1234 | 1235 | function deleteFromLookup(key) { 1236 | var value = Number(key); 1237 | var i = indexOfFirstToPass(scheduledLookup, function (millis) { 1238 | return millis === value; 1239 | }); 1240 | 1241 | if (i > -1) { 1242 | scheduledLookup.splice(i, 1); 1243 | } 1244 | } 1245 | 1246 | function reschedule(scheduledFn) { 1247 | self.scheduleFunction(scheduledFn.funcToCall, 1248 | scheduledFn.millis, 1249 | scheduledFn.params, 1250 | true, 1251 | scheduledFn.timeoutKey, 1252 | scheduledFn.runAtMillis + scheduledFn.millis); 1253 | } 1254 | 1255 | function forEachFunction(funcsToRun, callback) { 1256 | for (var i = 0; i < funcsToRun.length; ++i) { 1257 | callback(funcsToRun[i]); 1258 | } 1259 | } 1260 | 1261 | function runScheduledFunctions(endTime) { 1262 | if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) { 1263 | return; 1264 | } 1265 | 1266 | do { 1267 | currentTime = scheduledLookup.shift(); 1268 | 1269 | var funcsToRun = scheduledFunctions[currentTime]; 1270 | delete scheduledFunctions[currentTime]; 1271 | 1272 | forEachFunction(funcsToRun, function(funcToRun) { 1273 | if (funcToRun.recurring) { 1274 | reschedule(funcToRun); 1275 | } 1276 | }); 1277 | 1278 | forEachFunction(funcsToRun, function(funcToRun) { 1279 | funcToRun.funcToCall.apply(null, funcToRun.params || []); 1280 | }); 1281 | } while (scheduledLookup.length > 0 && 1282 | // checking first if we're out of time prevents setTimeout(0) 1283 | // scheduled in a funcToRun from forcing an extra iteration 1284 | currentTime !== endTime && 1285 | scheduledLookup[0] <= endTime); 1286 | } 1287 | } 1288 | 1289 | return DelayedFunctionScheduler; 1290 | }; 1291 | 1292 | getJasmineRequireObj().ExceptionFormatter = function() { 1293 | function ExceptionFormatter() { 1294 | this.message = function(error) { 1295 | var message = ''; 1296 | 1297 | if (error.name && error.message) { 1298 | message += error.name + ': ' + error.message; 1299 | } else { 1300 | message += error.toString() + ' thrown'; 1301 | } 1302 | 1303 | if (error.fileName || error.sourceURL) { 1304 | message += ' in ' + (error.fileName || error.sourceURL); 1305 | } 1306 | 1307 | if (error.line || error.lineNumber) { 1308 | message += ' (line ' + (error.line || error.lineNumber) + ')'; 1309 | } 1310 | 1311 | return message; 1312 | }; 1313 | 1314 | this.stack = function(error) { 1315 | return error ? error.stack : null; 1316 | }; 1317 | } 1318 | 1319 | return ExceptionFormatter; 1320 | }; 1321 | 1322 | getJasmineRequireObj().Expectation = function() { 1323 | 1324 | function Expectation(options) { 1325 | this.util = options.util || { buildFailureMessage: function() {} }; 1326 | this.customEqualityTesters = options.customEqualityTesters || []; 1327 | this.actual = options.actual; 1328 | this.addExpectationResult = options.addExpectationResult || function(){}; 1329 | this.isNot = options.isNot; 1330 | 1331 | var customMatchers = options.customMatchers || {}; 1332 | for (var matcherName in customMatchers) { 1333 | this[matcherName] = Expectation.prototype.wrapCompare(matcherName, customMatchers[matcherName]); 1334 | } 1335 | } 1336 | 1337 | Expectation.prototype.wrapCompare = function(name, matcherFactory) { 1338 | return function() { 1339 | var args = Array.prototype.slice.call(arguments, 0), 1340 | expected = args.slice(0), 1341 | message = ''; 1342 | 1343 | args.unshift(this.actual); 1344 | 1345 | var matcher = matcherFactory(this.util, this.customEqualityTesters), 1346 | matcherCompare = matcher.compare; 1347 | 1348 | function defaultNegativeCompare() { 1349 | var result = matcher.compare.apply(null, args); 1350 | result.pass = !result.pass; 1351 | return result; 1352 | } 1353 | 1354 | if (this.isNot) { 1355 | matcherCompare = matcher.negativeCompare || defaultNegativeCompare; 1356 | } 1357 | 1358 | var result = matcherCompare.apply(null, args); 1359 | 1360 | if (!result.pass) { 1361 | if (!result.message) { 1362 | args.unshift(this.isNot); 1363 | args.unshift(name); 1364 | message = this.util.buildFailureMessage.apply(null, args); 1365 | } else { 1366 | if (Object.prototype.toString.apply(result.message) === '[object Function]') { 1367 | message = result.message(); 1368 | } else { 1369 | message = result.message; 1370 | } 1371 | } 1372 | } 1373 | 1374 | if (expected.length == 1) { 1375 | expected = expected[0]; 1376 | } 1377 | 1378 | // TODO: how many of these params are needed? 1379 | this.addExpectationResult( 1380 | result.pass, 1381 | { 1382 | matcherName: name, 1383 | passed: result.pass, 1384 | message: message, 1385 | actual: this.actual, 1386 | expected: expected // TODO: this may need to be arrayified/sliced 1387 | } 1388 | ); 1389 | }; 1390 | }; 1391 | 1392 | Expectation.addCoreMatchers = function(matchers) { 1393 | var prototype = Expectation.prototype; 1394 | for (var matcherName in matchers) { 1395 | var matcher = matchers[matcherName]; 1396 | prototype[matcherName] = prototype.wrapCompare(matcherName, matcher); 1397 | } 1398 | }; 1399 | 1400 | Expectation.Factory = function(options) { 1401 | options = options || {}; 1402 | 1403 | var expect = new Expectation(options); 1404 | 1405 | // TODO: this would be nice as its own Object - NegativeExpectation 1406 | // TODO: copy instead of mutate options 1407 | options.isNot = true; 1408 | expect.not = new Expectation(options); 1409 | 1410 | return expect; 1411 | }; 1412 | 1413 | return Expectation; 1414 | }; 1415 | 1416 | //TODO: expectation result may make more sense as a presentation of an expectation. 1417 | getJasmineRequireObj().buildExpectationResult = function() { 1418 | function buildExpectationResult(options) { 1419 | var messageFormatter = options.messageFormatter || function() {}, 1420 | stackFormatter = options.stackFormatter || function() {}; 1421 | 1422 | var result = { 1423 | matcherName: options.matcherName, 1424 | message: message(), 1425 | stack: stack(), 1426 | passed: options.passed 1427 | }; 1428 | 1429 | if(!result.passed) { 1430 | result.expected = options.expected; 1431 | result.actual = options.actual; 1432 | } 1433 | 1434 | return result; 1435 | 1436 | function message() { 1437 | if (options.passed) { 1438 | return 'Passed.'; 1439 | } else if (options.message) { 1440 | return options.message; 1441 | } else if (options.error) { 1442 | return messageFormatter(options.error); 1443 | } 1444 | return ''; 1445 | } 1446 | 1447 | function stack() { 1448 | if (options.passed) { 1449 | return ''; 1450 | } 1451 | 1452 | var error = options.error; 1453 | if (!error) { 1454 | try { 1455 | throw new Error(message()); 1456 | } catch (e) { 1457 | error = e; 1458 | } 1459 | } 1460 | return stackFormatter(error); 1461 | } 1462 | } 1463 | 1464 | return buildExpectationResult; 1465 | }; 1466 | 1467 | getJasmineRequireObj().MockDate = function() { 1468 | function MockDate(global) { 1469 | var self = this; 1470 | var currentTime = 0; 1471 | 1472 | if (!global || !global.Date) { 1473 | self.install = function() {}; 1474 | self.tick = function() {}; 1475 | self.uninstall = function() {}; 1476 | return self; 1477 | } 1478 | 1479 | var GlobalDate = global.Date; 1480 | 1481 | self.install = function(mockDate) { 1482 | if (mockDate instanceof GlobalDate) { 1483 | currentTime = mockDate.getTime(); 1484 | } else { 1485 | currentTime = new GlobalDate().getTime(); 1486 | } 1487 | 1488 | global.Date = FakeDate; 1489 | }; 1490 | 1491 | self.tick = function(millis) { 1492 | millis = millis || 0; 1493 | currentTime = currentTime + millis; 1494 | }; 1495 | 1496 | self.uninstall = function() { 1497 | currentTime = 0; 1498 | global.Date = GlobalDate; 1499 | }; 1500 | 1501 | createDateProperties(); 1502 | 1503 | return self; 1504 | 1505 | function FakeDate() { 1506 | switch(arguments.length) { 1507 | case 0: 1508 | return new GlobalDate(currentTime); 1509 | case 1: 1510 | return new GlobalDate(arguments[0]); 1511 | case 2: 1512 | return new GlobalDate(arguments[0], arguments[1]); 1513 | case 3: 1514 | return new GlobalDate(arguments[0], arguments[1], arguments[2]); 1515 | case 4: 1516 | return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3]); 1517 | case 5: 1518 | return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3], 1519 | arguments[4]); 1520 | case 6: 1521 | return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3], 1522 | arguments[4], arguments[5]); 1523 | default: 1524 | return new GlobalDate(arguments[0], arguments[1], arguments[2], arguments[3], 1525 | arguments[4], arguments[5], arguments[6]); 1526 | } 1527 | } 1528 | 1529 | function createDateProperties() { 1530 | FakeDate.prototype = GlobalDate.prototype; 1531 | 1532 | FakeDate.now = function() { 1533 | if (GlobalDate.now) { 1534 | return currentTime; 1535 | } else { 1536 | throw new Error('Browser does not support Date.now()'); 1537 | } 1538 | }; 1539 | 1540 | FakeDate.toSource = GlobalDate.toSource; 1541 | FakeDate.toString = GlobalDate.toString; 1542 | FakeDate.parse = GlobalDate.parse; 1543 | FakeDate.UTC = GlobalDate.UTC; 1544 | } 1545 | } 1546 | 1547 | return MockDate; 1548 | }; 1549 | 1550 | getJasmineRequireObj().pp = function(j$) { 1551 | 1552 | function PrettyPrinter() { 1553 | this.ppNestLevel_ = 0; 1554 | this.seen = []; 1555 | } 1556 | 1557 | PrettyPrinter.prototype.format = function(value) { 1558 | this.ppNestLevel_++; 1559 | try { 1560 | if (j$.util.isUndefined(value)) { 1561 | this.emitScalar('undefined'); 1562 | } else if (value === null) { 1563 | this.emitScalar('null'); 1564 | } else if (value === 0 && 1/value === -Infinity) { 1565 | this.emitScalar('-0'); 1566 | } else if (value === j$.getGlobal()) { 1567 | this.emitScalar(''); 1568 | } else if (value.jasmineToString) { 1569 | this.emitScalar(value.jasmineToString()); 1570 | } else if (typeof value === 'string') { 1571 | this.emitString(value); 1572 | } else if (j$.isSpy(value)) { 1573 | this.emitScalar('spy on ' + value.and.identity()); 1574 | } else if (value instanceof RegExp) { 1575 | this.emitScalar(value.toString()); 1576 | } else if (typeof value === 'function') { 1577 | this.emitScalar('Function'); 1578 | } else if (typeof value.nodeType === 'number') { 1579 | this.emitScalar('HTMLNode'); 1580 | } else if (value instanceof Date) { 1581 | this.emitScalar('Date(' + value + ')'); 1582 | } else if (j$.util.arrayContains(this.seen, value)) { 1583 | this.emitScalar(''); 1584 | } else if (j$.isArray_(value) || j$.isA_('Object', value)) { 1585 | this.seen.push(value); 1586 | if (j$.isArray_(value)) { 1587 | this.emitArray(value); 1588 | } else { 1589 | this.emitObject(value); 1590 | } 1591 | this.seen.pop(); 1592 | } else { 1593 | this.emitScalar(value.toString()); 1594 | } 1595 | } finally { 1596 | this.ppNestLevel_--; 1597 | } 1598 | }; 1599 | 1600 | PrettyPrinter.prototype.iterateObject = function(obj, fn) { 1601 | for (var property in obj) { 1602 | if (!Object.prototype.hasOwnProperty.call(obj, property)) { continue; } 1603 | fn(property, obj.__lookupGetter__ ? (!j$.util.isUndefined(obj.__lookupGetter__(property)) && 1604 | obj.__lookupGetter__(property) !== null) : false); 1605 | } 1606 | }; 1607 | 1608 | PrettyPrinter.prototype.emitArray = j$.unimplementedMethod_; 1609 | PrettyPrinter.prototype.emitObject = j$.unimplementedMethod_; 1610 | PrettyPrinter.prototype.emitScalar = j$.unimplementedMethod_; 1611 | PrettyPrinter.prototype.emitString = j$.unimplementedMethod_; 1612 | 1613 | function StringPrettyPrinter() { 1614 | PrettyPrinter.call(this); 1615 | 1616 | this.string = ''; 1617 | } 1618 | 1619 | j$.util.inherit(StringPrettyPrinter, PrettyPrinter); 1620 | 1621 | StringPrettyPrinter.prototype.emitScalar = function(value) { 1622 | this.append(value); 1623 | }; 1624 | 1625 | StringPrettyPrinter.prototype.emitString = function(value) { 1626 | this.append('\'' + value + '\''); 1627 | }; 1628 | 1629 | StringPrettyPrinter.prototype.emitArray = function(array) { 1630 | if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) { 1631 | this.append('Array'); 1632 | return; 1633 | } 1634 | var length = Math.min(array.length, j$.MAX_PRETTY_PRINT_ARRAY_LENGTH); 1635 | this.append('[ '); 1636 | for (var i = 0; i < length; i++) { 1637 | if (i > 0) { 1638 | this.append(', '); 1639 | } 1640 | this.format(array[i]); 1641 | } 1642 | if(array.length > length){ 1643 | this.append(', ...'); 1644 | } 1645 | this.append(' ]'); 1646 | }; 1647 | 1648 | StringPrettyPrinter.prototype.emitObject = function(obj) { 1649 | var constructorName = obj.constructor ? j$.fnNameFor(obj.constructor) : 'null'; 1650 | this.append(constructorName); 1651 | 1652 | if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) { 1653 | return; 1654 | } 1655 | 1656 | var self = this; 1657 | this.append('({ '); 1658 | var first = true; 1659 | 1660 | this.iterateObject(obj, function(property, isGetter) { 1661 | if (first) { 1662 | first = false; 1663 | } else { 1664 | self.append(', '); 1665 | } 1666 | 1667 | self.append(property); 1668 | self.append(': '); 1669 | if (isGetter) { 1670 | self.append(''); 1671 | } else { 1672 | self.format(obj[property]); 1673 | } 1674 | }); 1675 | 1676 | this.append(' })'); 1677 | }; 1678 | 1679 | StringPrettyPrinter.prototype.append = function(value) { 1680 | this.string += value; 1681 | }; 1682 | 1683 | return function(value) { 1684 | var stringPrettyPrinter = new StringPrettyPrinter(); 1685 | stringPrettyPrinter.format(value); 1686 | return stringPrettyPrinter.string; 1687 | }; 1688 | }; 1689 | 1690 | getJasmineRequireObj().QueueRunner = function(j$) { 1691 | 1692 | function once(fn) { 1693 | var called = false; 1694 | return function() { 1695 | if (!called) { 1696 | called = true; 1697 | fn(); 1698 | } 1699 | }; 1700 | } 1701 | 1702 | function QueueRunner(attrs) { 1703 | this.queueableFns = attrs.queueableFns || []; 1704 | this.onComplete = attrs.onComplete || function() {}; 1705 | this.clearStack = attrs.clearStack || function(fn) {fn();}; 1706 | this.onException = attrs.onException || function() {}; 1707 | this.catchException = attrs.catchException || function() { return true; }; 1708 | this.userContext = attrs.userContext || {}; 1709 | this.timer = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout}; 1710 | this.fail = attrs.fail || function() {}; 1711 | } 1712 | 1713 | QueueRunner.prototype.execute = function() { 1714 | this.run(this.queueableFns, 0); 1715 | }; 1716 | 1717 | QueueRunner.prototype.run = function(queueableFns, recursiveIndex) { 1718 | var length = queueableFns.length, 1719 | self = this, 1720 | iterativeIndex; 1721 | 1722 | 1723 | for(iterativeIndex = recursiveIndex; iterativeIndex < length; iterativeIndex++) { 1724 | var queueableFn = queueableFns[iterativeIndex]; 1725 | if (queueableFn.fn.length > 0) { 1726 | attemptAsync(queueableFn); 1727 | return; 1728 | } else { 1729 | attemptSync(queueableFn); 1730 | } 1731 | } 1732 | 1733 | var runnerDone = iterativeIndex >= length; 1734 | 1735 | if (runnerDone) { 1736 | this.clearStack(this.onComplete); 1737 | } 1738 | 1739 | function attemptSync(queueableFn) { 1740 | try { 1741 | queueableFn.fn.call(self.userContext); 1742 | } catch (e) { 1743 | handleException(e, queueableFn); 1744 | } 1745 | } 1746 | 1747 | function attemptAsync(queueableFn) { 1748 | var clearTimeout = function () { 1749 | Function.prototype.apply.apply(self.timer.clearTimeout, [j$.getGlobal(), [timeoutId]]); 1750 | }, 1751 | next = once(function () { 1752 | clearTimeout(timeoutId); 1753 | self.run(queueableFns, iterativeIndex + 1); 1754 | }), 1755 | timeoutId; 1756 | 1757 | next.fail = function() { 1758 | self.fail.apply(null, arguments); 1759 | next(); 1760 | }; 1761 | 1762 | if (queueableFn.timeout) { 1763 | timeoutId = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() { 1764 | var error = new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.'); 1765 | onException(error, queueableFn); 1766 | next(); 1767 | }, queueableFn.timeout()]]); 1768 | } 1769 | 1770 | try { 1771 | queueableFn.fn.call(self.userContext, next); 1772 | } catch (e) { 1773 | handleException(e, queueableFn); 1774 | next(); 1775 | } 1776 | } 1777 | 1778 | function onException(e, queueableFn) { 1779 | self.onException(e); 1780 | } 1781 | 1782 | function handleException(e, queueableFn) { 1783 | onException(e, queueableFn); 1784 | if (!self.catchException(e)) { 1785 | //TODO: set a var when we catch an exception and 1786 | //use a finally block to close the loop in a nice way.. 1787 | throw e; 1788 | } 1789 | } 1790 | }; 1791 | 1792 | return QueueRunner; 1793 | }; 1794 | 1795 | getJasmineRequireObj().ReportDispatcher = function() { 1796 | function ReportDispatcher(methods) { 1797 | 1798 | var dispatchedMethods = methods || []; 1799 | 1800 | for (var i = 0; i < dispatchedMethods.length; i++) { 1801 | var method = dispatchedMethods[i]; 1802 | this[method] = (function(m) { 1803 | return function() { 1804 | dispatch(m, arguments); 1805 | }; 1806 | }(method)); 1807 | } 1808 | 1809 | var reporters = []; 1810 | 1811 | this.addReporter = function(reporter) { 1812 | reporters.push(reporter); 1813 | }; 1814 | 1815 | return this; 1816 | 1817 | function dispatch(method, args) { 1818 | for (var i = 0; i < reporters.length; i++) { 1819 | var reporter = reporters[i]; 1820 | if (reporter[method]) { 1821 | reporter[method].apply(reporter, args); 1822 | } 1823 | } 1824 | } 1825 | } 1826 | 1827 | return ReportDispatcher; 1828 | }; 1829 | 1830 | 1831 | getJasmineRequireObj().SpyRegistry = function(j$) { 1832 | 1833 | function SpyRegistry(options) { 1834 | options = options || {}; 1835 | var currentSpies = options.currentSpies || function() { return []; }; 1836 | 1837 | this.spyOn = function(obj, methodName) { 1838 | if (j$.util.isUndefined(obj)) { 1839 | throw new Error('spyOn could not find an object to spy upon for ' + methodName + '()'); 1840 | } 1841 | 1842 | if (j$.util.isUndefined(methodName)) { 1843 | throw new Error('No method name supplied'); 1844 | } 1845 | 1846 | if (j$.util.isUndefined(obj[methodName])) { 1847 | throw new Error(methodName + '() method does not exist'); 1848 | } 1849 | 1850 | if (obj[methodName] && j$.isSpy(obj[methodName])) { 1851 | //TODO?: should this return the current spy? Downside: may cause user confusion about spy state 1852 | throw new Error(methodName + ' has already been spied upon'); 1853 | } 1854 | 1855 | var spy = j$.createSpy(methodName, obj[methodName]); 1856 | 1857 | currentSpies().push({ 1858 | spy: spy, 1859 | baseObj: obj, 1860 | methodName: methodName, 1861 | originalValue: obj[methodName] 1862 | }); 1863 | 1864 | obj[methodName] = spy; 1865 | 1866 | return spy; 1867 | }; 1868 | 1869 | this.clearSpies = function() { 1870 | var spies = currentSpies(); 1871 | for (var i = 0; i < spies.length; i++) { 1872 | var spyEntry = spies[i]; 1873 | spyEntry.baseObj[spyEntry.methodName] = spyEntry.originalValue; 1874 | } 1875 | }; 1876 | } 1877 | 1878 | return SpyRegistry; 1879 | }; 1880 | 1881 | getJasmineRequireObj().SpyStrategy = function() { 1882 | 1883 | function SpyStrategy(options) { 1884 | options = options || {}; 1885 | 1886 | var identity = options.name || 'unknown', 1887 | originalFn = options.fn || function() {}, 1888 | getSpy = options.getSpy || function() {}, 1889 | plan = function() {}; 1890 | 1891 | this.identity = function() { 1892 | return identity; 1893 | }; 1894 | 1895 | this.exec = function() { 1896 | return plan.apply(this, arguments); 1897 | }; 1898 | 1899 | this.callThrough = function() { 1900 | plan = originalFn; 1901 | return getSpy(); 1902 | }; 1903 | 1904 | this.returnValue = function(value) { 1905 | plan = function() { 1906 | return value; 1907 | }; 1908 | return getSpy(); 1909 | }; 1910 | 1911 | this.returnValues = function() { 1912 | var values = Array.prototype.slice.call(arguments); 1913 | plan = function () { 1914 | return values.shift(); 1915 | }; 1916 | return getSpy(); 1917 | }; 1918 | 1919 | this.throwError = function(something) { 1920 | var error = (something instanceof Error) ? something : new Error(something); 1921 | plan = function() { 1922 | throw error; 1923 | }; 1924 | return getSpy(); 1925 | }; 1926 | 1927 | this.callFake = function(fn) { 1928 | plan = fn; 1929 | return getSpy(); 1930 | }; 1931 | 1932 | this.stub = function(fn) { 1933 | plan = function() {}; 1934 | return getSpy(); 1935 | }; 1936 | } 1937 | 1938 | return SpyStrategy; 1939 | }; 1940 | 1941 | getJasmineRequireObj().Suite = function() { 1942 | function Suite(attrs) { 1943 | this.env = attrs.env; 1944 | this.id = attrs.id; 1945 | this.parentSuite = attrs.parentSuite; 1946 | this.description = attrs.description; 1947 | this.onStart = attrs.onStart || function() {}; 1948 | this.resultCallback = attrs.resultCallback || function() {}; 1949 | this.clearStack = attrs.clearStack || function(fn) {fn();}; 1950 | this.expectationFactory = attrs.expectationFactory; 1951 | this.expectationResultFactory = attrs.expectationResultFactory; 1952 | this.runnablesExplictlySetGetter = attrs.runnablesExplictlySetGetter || function() {}; 1953 | 1954 | this.beforeFns = []; 1955 | this.afterFns = []; 1956 | this.beforeAllFns = []; 1957 | this.afterAllFns = []; 1958 | this.queueRunner = attrs.queueRunner || function() {}; 1959 | this.disabled = false; 1960 | 1961 | this.children = []; 1962 | 1963 | this.result = { 1964 | id: this.id, 1965 | description: this.description, 1966 | fullName: this.getFullName(), 1967 | failedExpectations: [] 1968 | }; 1969 | } 1970 | 1971 | Suite.prototype.expect = function(actual) { 1972 | return this.expectationFactory(actual, this); 1973 | }; 1974 | 1975 | Suite.prototype.getFullName = function() { 1976 | var fullName = this.description; 1977 | for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { 1978 | if (parentSuite.parentSuite) { 1979 | fullName = parentSuite.description + ' ' + fullName; 1980 | } 1981 | } 1982 | return fullName; 1983 | }; 1984 | 1985 | Suite.prototype.disable = function() { 1986 | this.disabled = true; 1987 | }; 1988 | 1989 | Suite.prototype.beforeEach = function(fn) { 1990 | this.beforeFns.unshift(fn); 1991 | }; 1992 | 1993 | Suite.prototype.beforeAll = function(fn) { 1994 | this.beforeAllFns.push(fn); 1995 | }; 1996 | 1997 | Suite.prototype.afterEach = function(fn) { 1998 | this.afterFns.unshift(fn); 1999 | }; 2000 | 2001 | Suite.prototype.afterAll = function(fn) { 2002 | this.afterAllFns.push(fn); 2003 | }; 2004 | 2005 | Suite.prototype.addChild = function(child) { 2006 | this.children.push(child); 2007 | }; 2008 | 2009 | Suite.prototype.status = function() { 2010 | if (this.disabled) { 2011 | return 'disabled'; 2012 | } 2013 | 2014 | if (this.result.failedExpectations.length > 0) { 2015 | return 'failed'; 2016 | } else { 2017 | return 'finished'; 2018 | } 2019 | }; 2020 | 2021 | Suite.prototype.execute = function(onComplete) { 2022 | var self = this; 2023 | 2024 | this.onStart(this); 2025 | 2026 | if (this.disabled) { 2027 | complete(); 2028 | return; 2029 | } 2030 | 2031 | var allFns = []; 2032 | 2033 | for (var i = 0; i < this.children.length; i++) { 2034 | allFns.push(wrapChildAsAsync(this.children[i])); 2035 | } 2036 | 2037 | if (this.isExecutable()) { 2038 | allFns = this.beforeAllFns.concat(allFns); 2039 | allFns = allFns.concat(this.afterAllFns); 2040 | } 2041 | 2042 | this.queueRunner({ 2043 | queueableFns: allFns, 2044 | onComplete: complete, 2045 | userContext: this.sharedUserContext(), 2046 | onException: function() { self.onException.apply(self, arguments); } 2047 | }); 2048 | 2049 | function complete() { 2050 | self.result.status = self.status(); 2051 | self.resultCallback(self.result); 2052 | 2053 | if (onComplete) { 2054 | onComplete(); 2055 | } 2056 | } 2057 | 2058 | function wrapChildAsAsync(child) { 2059 | return { fn: function(done) { child.execute(done); } }; 2060 | } 2061 | }; 2062 | 2063 | Suite.prototype.isExecutable = function() { 2064 | var runnablesExplicitlySet = this.runnablesExplictlySetGetter(); 2065 | return !runnablesExplicitlySet && hasExecutableChild(this.children); 2066 | }; 2067 | 2068 | Suite.prototype.sharedUserContext = function() { 2069 | if (!this.sharedContext) { 2070 | this.sharedContext = this.parentSuite ? clone(this.parentSuite.sharedUserContext()) : {}; 2071 | } 2072 | 2073 | return this.sharedContext; 2074 | }; 2075 | 2076 | Suite.prototype.clonedSharedUserContext = function() { 2077 | return clone(this.sharedUserContext()); 2078 | }; 2079 | 2080 | Suite.prototype.onException = function() { 2081 | if(isAfterAll(this.children)) { 2082 | var data = { 2083 | matcherName: '', 2084 | passed: false, 2085 | expected: '', 2086 | actual: '', 2087 | error: arguments[0] 2088 | }; 2089 | this.result.failedExpectations.push(this.expectationResultFactory(data)); 2090 | } else { 2091 | for (var i = 0; i < this.children.length; i++) { 2092 | var child = this.children[i]; 2093 | child.onException.apply(child, arguments); 2094 | } 2095 | } 2096 | }; 2097 | 2098 | Suite.prototype.addExpectationResult = function () { 2099 | if(isAfterAll(this.children) && isFailure(arguments)){ 2100 | var data = arguments[1]; 2101 | this.result.failedExpectations.push(this.expectationResultFactory(data)); 2102 | } else { 2103 | for (var i = 0; i < this.children.length; i++) { 2104 | var child = this.children[i]; 2105 | child.addExpectationResult.apply(child, arguments); 2106 | } 2107 | } 2108 | }; 2109 | 2110 | function isAfterAll(children) { 2111 | return children && children[0].result.status; 2112 | } 2113 | 2114 | function isFailure(args) { 2115 | return !args[0]; 2116 | } 2117 | 2118 | function hasExecutableChild(children) { 2119 | var foundActive = false; 2120 | for (var i = 0; i < children.length; i++) { 2121 | if (children[i].isExecutable()) { 2122 | foundActive = true; 2123 | break; 2124 | } 2125 | } 2126 | return foundActive; 2127 | } 2128 | 2129 | function clone(obj) { 2130 | var clonedObj = {}; 2131 | for (var prop in obj) { 2132 | if (obj.hasOwnProperty(prop)) { 2133 | clonedObj[prop] = obj[prop]; 2134 | } 2135 | } 2136 | 2137 | return clonedObj; 2138 | } 2139 | 2140 | return Suite; 2141 | }; 2142 | 2143 | if (typeof window == void 0 && typeof exports == 'object') { 2144 | exports.Suite = jasmineRequire.Suite; 2145 | } 2146 | 2147 | getJasmineRequireObj().Timer = function() { 2148 | var defaultNow = (function(Date) { 2149 | return function() { return new Date().getTime(); }; 2150 | })(Date); 2151 | 2152 | function Timer(options) { 2153 | options = options || {}; 2154 | 2155 | var now = options.now || defaultNow, 2156 | startTime; 2157 | 2158 | this.start = function() { 2159 | startTime = now(); 2160 | }; 2161 | 2162 | this.elapsed = function() { 2163 | return now() - startTime; 2164 | }; 2165 | } 2166 | 2167 | return Timer; 2168 | }; 2169 | 2170 | getJasmineRequireObj().Any = function() { 2171 | 2172 | function Any(expectedObject) { 2173 | this.expectedObject = expectedObject; 2174 | } 2175 | 2176 | Any.prototype.asymmetricMatch = function(other) { 2177 | if (this.expectedObject == String) { 2178 | return typeof other == 'string' || other instanceof String; 2179 | } 2180 | 2181 | if (this.expectedObject == Number) { 2182 | return typeof other == 'number' || other instanceof Number; 2183 | } 2184 | 2185 | if (this.expectedObject == Function) { 2186 | return typeof other == 'function' || other instanceof Function; 2187 | } 2188 | 2189 | if (this.expectedObject == Object) { 2190 | return typeof other == 'object'; 2191 | } 2192 | 2193 | if (this.expectedObject == Boolean) { 2194 | return typeof other == 'boolean'; 2195 | } 2196 | 2197 | return other instanceof this.expectedObject; 2198 | }; 2199 | 2200 | Any.prototype.jasmineToString = function() { 2201 | return ''; 2202 | }; 2203 | 2204 | return Any; 2205 | }; 2206 | 2207 | getJasmineRequireObj().Anything = function(j$) { 2208 | 2209 | function Anything() {} 2210 | 2211 | Anything.prototype.asymmetricMatch = function(other) { 2212 | return !j$.util.isUndefined(other) && other !== null; 2213 | }; 2214 | 2215 | Anything.prototype.jasmineToString = function() { 2216 | return ''; 2217 | }; 2218 | 2219 | return Anything; 2220 | }; 2221 | 2222 | getJasmineRequireObj().ArrayContaining = function(j$) { 2223 | function ArrayContaining(sample) { 2224 | this.sample = sample; 2225 | } 2226 | 2227 | ArrayContaining.prototype.asymmetricMatch = function(other) { 2228 | var className = Object.prototype.toString.call(this.sample); 2229 | if (className !== '[object Array]') { throw new Error('You must provide an array to arrayContaining, not \'' + this.sample + '\'.'); } 2230 | 2231 | for (var i = 0; i < this.sample.length; i++) { 2232 | var item = this.sample[i]; 2233 | if (!j$.matchersUtil.contains(other, item)) { 2234 | return false; 2235 | } 2236 | } 2237 | 2238 | return true; 2239 | }; 2240 | 2241 | ArrayContaining.prototype.jasmineToString = function () { 2242 | return ''; 2243 | }; 2244 | 2245 | return ArrayContaining; 2246 | }; 2247 | 2248 | getJasmineRequireObj().ObjectContaining = function(j$) { 2249 | 2250 | function ObjectContaining(sample) { 2251 | this.sample = sample; 2252 | } 2253 | 2254 | ObjectContaining.prototype.asymmetricMatch = function(other) { 2255 | if (typeof(this.sample) !== 'object') { throw new Error('You must provide an object to objectContaining, not \''+this.sample+'\'.'); } 2256 | 2257 | for (var property in this.sample) { 2258 | if (!Object.prototype.hasOwnProperty.call(other, property) || 2259 | !j$.matchersUtil.equals(this.sample[property], other[property])) { 2260 | return false; 2261 | } 2262 | } 2263 | 2264 | return true; 2265 | }; 2266 | 2267 | ObjectContaining.prototype.jasmineToString = function() { 2268 | return ''; 2269 | }; 2270 | 2271 | return ObjectContaining; 2272 | }; 2273 | 2274 | getJasmineRequireObj().StringMatching = function(j$) { 2275 | 2276 | function StringMatching(expected) { 2277 | if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) { 2278 | throw new Error('Expected is not a String or a RegExp'); 2279 | } 2280 | 2281 | this.regexp = new RegExp(expected); 2282 | } 2283 | 2284 | StringMatching.prototype.asymmetricMatch = function(other) { 2285 | return this.regexp.test(other); 2286 | }; 2287 | 2288 | StringMatching.prototype.jasmineToString = function() { 2289 | return ''; 2290 | }; 2291 | 2292 | return StringMatching; 2293 | }; 2294 | 2295 | getJasmineRequireObj().matchersUtil = function(j$) { 2296 | // TODO: what to do about jasmine.pp not being inject? move to JSON.stringify? gut PrettyPrinter? 2297 | 2298 | return { 2299 | equals: function(a, b, customTesters) { 2300 | customTesters = customTesters || []; 2301 | 2302 | return eq(a, b, [], [], customTesters); 2303 | }, 2304 | 2305 | contains: function(haystack, needle, customTesters) { 2306 | customTesters = customTesters || []; 2307 | 2308 | if ((Object.prototype.toString.apply(haystack) === '[object Array]') || 2309 | (!!haystack && !haystack.indexOf)) 2310 | { 2311 | for (var i = 0; i < haystack.length; i++) { 2312 | if (eq(haystack[i], needle, [], [], customTesters)) { 2313 | return true; 2314 | } 2315 | } 2316 | return false; 2317 | } 2318 | 2319 | return !!haystack && haystack.indexOf(needle) >= 0; 2320 | }, 2321 | 2322 | buildFailureMessage: function() { 2323 | var args = Array.prototype.slice.call(arguments, 0), 2324 | matcherName = args[0], 2325 | isNot = args[1], 2326 | actual = args[2], 2327 | expected = args.slice(3), 2328 | englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); }); 2329 | 2330 | var message = 'Expected ' + 2331 | j$.pp(actual) + 2332 | (isNot ? ' not ' : ' ') + 2333 | englishyPredicate; 2334 | 2335 | if (expected.length > 0) { 2336 | for (var i = 0; i < expected.length; i++) { 2337 | if (i > 0) { 2338 | message += ','; 2339 | } 2340 | message += ' ' + j$.pp(expected[i]); 2341 | } 2342 | } 2343 | 2344 | return message + '.'; 2345 | } 2346 | }; 2347 | 2348 | function isAsymmetric(obj) { 2349 | return obj && j$.isA_('Function', obj.asymmetricMatch); 2350 | } 2351 | 2352 | function asymmetricMatch(a, b) { 2353 | var asymmetricA = isAsymmetric(a), 2354 | asymmetricB = isAsymmetric(b); 2355 | 2356 | if (asymmetricA && asymmetricB) { 2357 | return undefined; 2358 | } 2359 | 2360 | if (asymmetricA) { 2361 | return a.asymmetricMatch(b); 2362 | } 2363 | 2364 | if (asymmetricB) { 2365 | return b.asymmetricMatch(a); 2366 | } 2367 | } 2368 | 2369 | // Equality function lovingly adapted from isEqual in 2370 | // [Underscore](http://underscorejs.org) 2371 | function eq(a, b, aStack, bStack, customTesters) { 2372 | var result = true; 2373 | 2374 | var asymmetricResult = asymmetricMatch(a, b); 2375 | if (!j$.util.isUndefined(asymmetricResult)) { 2376 | return asymmetricResult; 2377 | } 2378 | 2379 | for (var i = 0; i < customTesters.length; i++) { 2380 | var customTesterResult = customTesters[i](a, b); 2381 | if (!j$.util.isUndefined(customTesterResult)) { 2382 | return customTesterResult; 2383 | } 2384 | } 2385 | 2386 | if (a instanceof Error && b instanceof Error) { 2387 | return a.message == b.message; 2388 | } 2389 | 2390 | // Identical objects are equal. `0 === -0`, but they aren't identical. 2391 | // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). 2392 | if (a === b) { return a !== 0 || 1 / a == 1 / b; } 2393 | // A strict comparison is necessary because `null == undefined`. 2394 | if (a === null || b === null) { return a === b; } 2395 | var className = Object.prototype.toString.call(a); 2396 | if (className != Object.prototype.toString.call(b)) { return false; } 2397 | switch (className) { 2398 | // Strings, numbers, dates, and booleans are compared by value. 2399 | case '[object String]': 2400 | // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is 2401 | // equivalent to `new String("5")`. 2402 | return a == String(b); 2403 | case '[object Number]': 2404 | // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for 2405 | // other numeric values. 2406 | return a != +a ? b != +b : (a === 0 ? 1 / a == 1 / b : a == +b); 2407 | case '[object Date]': 2408 | case '[object Boolean]': 2409 | // Coerce dates and booleans to numeric primitive values. Dates are compared by their 2410 | // millisecond representations. Note that invalid dates with millisecond representations 2411 | // of `NaN` are not equivalent. 2412 | return +a == +b; 2413 | // RegExps are compared by their source patterns and flags. 2414 | case '[object RegExp]': 2415 | return a.source == b.source && 2416 | a.global == b.global && 2417 | a.multiline == b.multiline && 2418 | a.ignoreCase == b.ignoreCase; 2419 | } 2420 | if (typeof a != 'object' || typeof b != 'object') { return false; } 2421 | 2422 | var aIsDomNode = j$.isDomNode(a); 2423 | var bIsDomNode = j$.isDomNode(b); 2424 | if (aIsDomNode && bIsDomNode) { 2425 | // At first try to use DOM3 method isEqualNode 2426 | if (a.isEqualNode) { 2427 | return a.isEqualNode(b); 2428 | } 2429 | // IE8 doesn't support isEqualNode, try to use outerHTML && innerText 2430 | var aIsElement = a instanceof Element; 2431 | var bIsElement = b instanceof Element; 2432 | if (aIsElement && bIsElement) { 2433 | return a.outerHTML == b.outerHTML; 2434 | } 2435 | if (aIsElement || bIsElement) { 2436 | return false; 2437 | } 2438 | return a.innerText == b.innerText && a.textContent == b.textContent; 2439 | } 2440 | if (aIsDomNode || bIsDomNode) { 2441 | return false; 2442 | } 2443 | 2444 | // Assume equality for cyclic structures. The algorithm for detecting cyclic 2445 | // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. 2446 | var length = aStack.length; 2447 | while (length--) { 2448 | // Linear search. Performance is inversely proportional to the number of 2449 | // unique nested structures. 2450 | if (aStack[length] == a) { return bStack[length] == b; } 2451 | } 2452 | // Add the first object to the stack of traversed objects. 2453 | aStack.push(a); 2454 | bStack.push(b); 2455 | var size = 0; 2456 | // Recursively compare objects and arrays. 2457 | // Compare array lengths to determine if a deep comparison is necessary. 2458 | if (className == '[object Array]' && a.length !== b.length) { 2459 | result = false; 2460 | } 2461 | 2462 | if (result) { 2463 | // Objects with different constructors are not equivalent, but `Object`s 2464 | // from different frames are. 2465 | var aCtor = a.constructor, bCtor = b.constructor; 2466 | if (aCtor !== bCtor && !(isFunction(aCtor) && (aCtor instanceof aCtor) && 2467 | isFunction(bCtor) && (bCtor instanceof bCtor))) { 2468 | return false; 2469 | } 2470 | // Deep compare objects. 2471 | for (var key in a) { 2472 | if (has(a, key)) { 2473 | // Count the expected number of properties. 2474 | size++; 2475 | // Deep compare each member. 2476 | if (!(result = has(b, key) && eq(a[key], b[key], aStack, bStack, customTesters))) { break; } 2477 | } 2478 | } 2479 | // Ensure that both objects contain the same number of properties. 2480 | if (result) { 2481 | for (key in b) { 2482 | if (has(b, key) && !(size--)) { break; } 2483 | } 2484 | result = !size; 2485 | } 2486 | } 2487 | // Remove the first object from the stack of traversed objects. 2488 | aStack.pop(); 2489 | bStack.pop(); 2490 | 2491 | return result; 2492 | 2493 | function has(obj, key) { 2494 | return Object.prototype.hasOwnProperty.call(obj, key); 2495 | } 2496 | 2497 | function isFunction(obj) { 2498 | return typeof obj === 'function'; 2499 | } 2500 | } 2501 | }; 2502 | 2503 | getJasmineRequireObj().toBe = function() { 2504 | function toBe() { 2505 | return { 2506 | compare: function(actual, expected) { 2507 | return { 2508 | pass: actual === expected 2509 | }; 2510 | } 2511 | }; 2512 | } 2513 | 2514 | return toBe; 2515 | }; 2516 | 2517 | getJasmineRequireObj().toBeCloseTo = function() { 2518 | 2519 | function toBeCloseTo() { 2520 | return { 2521 | compare: function(actual, expected, precision) { 2522 | if (precision !== 0) { 2523 | precision = precision || 2; 2524 | } 2525 | 2526 | return { 2527 | pass: Math.abs(expected - actual) < (Math.pow(10, -precision) / 2) 2528 | }; 2529 | } 2530 | }; 2531 | } 2532 | 2533 | return toBeCloseTo; 2534 | }; 2535 | 2536 | getJasmineRequireObj().toBeDefined = function() { 2537 | function toBeDefined() { 2538 | return { 2539 | compare: function(actual) { 2540 | return { 2541 | pass: (void 0 !== actual) 2542 | }; 2543 | } 2544 | }; 2545 | } 2546 | 2547 | return toBeDefined; 2548 | }; 2549 | 2550 | getJasmineRequireObj().toBeFalsy = function() { 2551 | function toBeFalsy() { 2552 | return { 2553 | compare: function(actual) { 2554 | return { 2555 | pass: !!!actual 2556 | }; 2557 | } 2558 | }; 2559 | } 2560 | 2561 | return toBeFalsy; 2562 | }; 2563 | 2564 | getJasmineRequireObj().toBeGreaterThan = function() { 2565 | 2566 | function toBeGreaterThan() { 2567 | return { 2568 | compare: function(actual, expected) { 2569 | return { 2570 | pass: actual > expected 2571 | }; 2572 | } 2573 | }; 2574 | } 2575 | 2576 | return toBeGreaterThan; 2577 | }; 2578 | 2579 | 2580 | getJasmineRequireObj().toBeLessThan = function() { 2581 | function toBeLessThan() { 2582 | return { 2583 | 2584 | compare: function(actual, expected) { 2585 | return { 2586 | pass: actual < expected 2587 | }; 2588 | } 2589 | }; 2590 | } 2591 | 2592 | return toBeLessThan; 2593 | }; 2594 | getJasmineRequireObj().toBeNaN = function(j$) { 2595 | 2596 | function toBeNaN() { 2597 | return { 2598 | compare: function(actual) { 2599 | var result = { 2600 | pass: (actual !== actual) 2601 | }; 2602 | 2603 | if (result.pass) { 2604 | result.message = 'Expected actual not to be NaN.'; 2605 | } else { 2606 | result.message = function() { return 'Expected ' + j$.pp(actual) + ' to be NaN.'; }; 2607 | } 2608 | 2609 | return result; 2610 | } 2611 | }; 2612 | } 2613 | 2614 | return toBeNaN; 2615 | }; 2616 | 2617 | getJasmineRequireObj().toBeNull = function() { 2618 | 2619 | function toBeNull() { 2620 | return { 2621 | compare: function(actual) { 2622 | return { 2623 | pass: actual === null 2624 | }; 2625 | } 2626 | }; 2627 | } 2628 | 2629 | return toBeNull; 2630 | }; 2631 | 2632 | getJasmineRequireObj().toBeTruthy = function() { 2633 | 2634 | function toBeTruthy() { 2635 | return { 2636 | compare: function(actual) { 2637 | return { 2638 | pass: !!actual 2639 | }; 2640 | } 2641 | }; 2642 | } 2643 | 2644 | return toBeTruthy; 2645 | }; 2646 | 2647 | getJasmineRequireObj().toBeUndefined = function() { 2648 | 2649 | function toBeUndefined() { 2650 | return { 2651 | compare: function(actual) { 2652 | return { 2653 | pass: void 0 === actual 2654 | }; 2655 | } 2656 | }; 2657 | } 2658 | 2659 | return toBeUndefined; 2660 | }; 2661 | 2662 | getJasmineRequireObj().toContain = function() { 2663 | function toContain(util, customEqualityTesters) { 2664 | customEqualityTesters = customEqualityTesters || []; 2665 | 2666 | return { 2667 | compare: function(actual, expected) { 2668 | 2669 | return { 2670 | pass: util.contains(actual, expected, customEqualityTesters) 2671 | }; 2672 | } 2673 | }; 2674 | } 2675 | 2676 | return toContain; 2677 | }; 2678 | 2679 | getJasmineRequireObj().toEqual = function() { 2680 | 2681 | function toEqual(util, customEqualityTesters) { 2682 | customEqualityTesters = customEqualityTesters || []; 2683 | 2684 | return { 2685 | compare: function(actual, expected) { 2686 | var result = { 2687 | pass: false 2688 | }; 2689 | 2690 | result.pass = util.equals(actual, expected, customEqualityTesters); 2691 | 2692 | return result; 2693 | } 2694 | }; 2695 | } 2696 | 2697 | return toEqual; 2698 | }; 2699 | 2700 | getJasmineRequireObj().toHaveBeenCalled = function(j$) { 2701 | 2702 | function toHaveBeenCalled() { 2703 | return { 2704 | compare: function(actual) { 2705 | var result = {}; 2706 | 2707 | if (!j$.isSpy(actual)) { 2708 | throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.'); 2709 | } 2710 | 2711 | if (arguments.length > 1) { 2712 | throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith'); 2713 | } 2714 | 2715 | result.pass = actual.calls.any(); 2716 | 2717 | result.message = result.pass ? 2718 | 'Expected spy ' + actual.and.identity() + ' not to have been called.' : 2719 | 'Expected spy ' + actual.and.identity() + ' to have been called.'; 2720 | 2721 | return result; 2722 | } 2723 | }; 2724 | } 2725 | 2726 | return toHaveBeenCalled; 2727 | }; 2728 | 2729 | getJasmineRequireObj().toHaveBeenCalledWith = function(j$) { 2730 | 2731 | function toHaveBeenCalledWith(util, customEqualityTesters) { 2732 | return { 2733 | compare: function() { 2734 | var args = Array.prototype.slice.call(arguments, 0), 2735 | actual = args[0], 2736 | expectedArgs = args.slice(1), 2737 | result = { pass: false }; 2738 | 2739 | if (!j$.isSpy(actual)) { 2740 | throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.'); 2741 | } 2742 | 2743 | if (!actual.calls.any()) { 2744 | result.message = function() { return 'Expected spy ' + actual.and.identity() + ' to have been called with ' + j$.pp(expectedArgs) + ' but it was never called.'; }; 2745 | return result; 2746 | } 2747 | 2748 | if (util.contains(actual.calls.allArgs(), expectedArgs, customEqualityTesters)) { 2749 | result.pass = true; 2750 | result.message = function() { return 'Expected spy ' + actual.and.identity() + ' not to have been called with ' + j$.pp(expectedArgs) + ' but it was.'; }; 2751 | } else { 2752 | result.message = function() { return 'Expected spy ' + actual.and.identity() + ' to have been called with ' + j$.pp(expectedArgs) + ' but actual calls were ' + j$.pp(actual.calls.allArgs()).replace(/^\[ | \]$/g, '') + '.'; }; 2753 | } 2754 | 2755 | return result; 2756 | } 2757 | }; 2758 | } 2759 | 2760 | return toHaveBeenCalledWith; 2761 | }; 2762 | 2763 | getJasmineRequireObj().toMatch = function(j$) { 2764 | 2765 | function toMatch() { 2766 | return { 2767 | compare: function(actual, expected) { 2768 | if (!j$.isString_(expected) && !j$.isA_('RegExp', expected)) { 2769 | throw new Error('Expected is not a String or a RegExp'); 2770 | } 2771 | 2772 | var regexp = new RegExp(expected); 2773 | 2774 | return { 2775 | pass: regexp.test(actual) 2776 | }; 2777 | } 2778 | }; 2779 | } 2780 | 2781 | return toMatch; 2782 | }; 2783 | 2784 | getJasmineRequireObj().toThrow = function(j$) { 2785 | 2786 | function toThrow(util) { 2787 | return { 2788 | compare: function(actual, expected) { 2789 | var result = { pass: false }, 2790 | threw = false, 2791 | thrown; 2792 | 2793 | if (typeof actual != 'function') { 2794 | throw new Error('Actual is not a Function'); 2795 | } 2796 | 2797 | try { 2798 | actual(); 2799 | } catch (e) { 2800 | threw = true; 2801 | thrown = e; 2802 | } 2803 | 2804 | if (!threw) { 2805 | result.message = 'Expected function to throw an exception.'; 2806 | return result; 2807 | } 2808 | 2809 | if (arguments.length == 1) { 2810 | result.pass = true; 2811 | result.message = function() { return 'Expected function not to throw, but it threw ' + j$.pp(thrown) + '.'; }; 2812 | 2813 | return result; 2814 | } 2815 | 2816 | if (util.equals(thrown, expected)) { 2817 | result.pass = true; 2818 | result.message = function() { return 'Expected function not to throw ' + j$.pp(expected) + '.'; }; 2819 | } else { 2820 | result.message = function() { return 'Expected function to throw ' + j$.pp(expected) + ', but it threw ' + j$.pp(thrown) + '.'; }; 2821 | } 2822 | 2823 | return result; 2824 | } 2825 | }; 2826 | } 2827 | 2828 | return toThrow; 2829 | }; 2830 | 2831 | getJasmineRequireObj().toThrowError = function(j$) { 2832 | function toThrowError (util) { 2833 | return { 2834 | compare: function(actual) { 2835 | var threw = false, 2836 | pass = {pass: true}, 2837 | fail = {pass: false}, 2838 | thrown; 2839 | 2840 | if (typeof actual != 'function') { 2841 | throw new Error('Actual is not a Function'); 2842 | } 2843 | 2844 | var errorMatcher = getMatcher.apply(null, arguments); 2845 | 2846 | try { 2847 | actual(); 2848 | } catch (e) { 2849 | threw = true; 2850 | thrown = e; 2851 | } 2852 | 2853 | if (!threw) { 2854 | fail.message = 'Expected function to throw an Error.'; 2855 | return fail; 2856 | } 2857 | 2858 | if (!(thrown instanceof Error)) { 2859 | fail.message = function() { return 'Expected function to throw an Error, but it threw ' + j$.pp(thrown) + '.'; }; 2860 | return fail; 2861 | } 2862 | 2863 | if (errorMatcher.hasNoSpecifics()) { 2864 | pass.message = 'Expected function not to throw an Error, but it threw ' + j$.fnNameFor(thrown) + '.'; 2865 | return pass; 2866 | } 2867 | 2868 | if (errorMatcher.matches(thrown)) { 2869 | pass.message = function() { 2870 | return 'Expected function not to throw ' + errorMatcher.errorTypeDescription + errorMatcher.messageDescription() + '.'; 2871 | }; 2872 | return pass; 2873 | } else { 2874 | fail.message = function() { 2875 | return 'Expected function to throw ' + errorMatcher.errorTypeDescription + errorMatcher.messageDescription() + 2876 | ', but it threw ' + errorMatcher.thrownDescription(thrown) + '.'; 2877 | }; 2878 | return fail; 2879 | } 2880 | } 2881 | }; 2882 | 2883 | function getMatcher() { 2884 | var expected = null, 2885 | errorType = null; 2886 | 2887 | if (arguments.length == 2) { 2888 | expected = arguments[1]; 2889 | if (isAnErrorType(expected)) { 2890 | errorType = expected; 2891 | expected = null; 2892 | } 2893 | } else if (arguments.length > 2) { 2894 | errorType = arguments[1]; 2895 | expected = arguments[2]; 2896 | if (!isAnErrorType(errorType)) { 2897 | throw new Error('Expected error type is not an Error.'); 2898 | } 2899 | } 2900 | 2901 | if (expected && !isStringOrRegExp(expected)) { 2902 | if (errorType) { 2903 | throw new Error('Expected error message is not a string or RegExp.'); 2904 | } else { 2905 | throw new Error('Expected is not an Error, string, or RegExp.'); 2906 | } 2907 | } 2908 | 2909 | function messageMatch(message) { 2910 | if (typeof expected == 'string') { 2911 | return expected == message; 2912 | } else { 2913 | return expected.test(message); 2914 | } 2915 | } 2916 | 2917 | return { 2918 | errorTypeDescription: errorType ? j$.fnNameFor(errorType) : 'an exception', 2919 | thrownDescription: function(thrown) { 2920 | var thrownName = errorType ? j$.fnNameFor(thrown.constructor) : 'an exception', 2921 | thrownMessage = ''; 2922 | 2923 | if (expected) { 2924 | thrownMessage = ' with message ' + j$.pp(thrown.message); 2925 | } 2926 | 2927 | return thrownName + thrownMessage; 2928 | }, 2929 | messageDescription: function() { 2930 | if (expected === null) { 2931 | return ''; 2932 | } else if (expected instanceof RegExp) { 2933 | return ' with a message matching ' + j$.pp(expected); 2934 | } else { 2935 | return ' with message ' + j$.pp(expected); 2936 | } 2937 | }, 2938 | hasNoSpecifics: function() { 2939 | return expected === null && errorType === null; 2940 | }, 2941 | matches: function(error) { 2942 | return (errorType === null || error.constructor === errorType) && 2943 | (expected === null || messageMatch(error.message)); 2944 | } 2945 | }; 2946 | } 2947 | 2948 | function isStringOrRegExp(potential) { 2949 | return potential instanceof RegExp || (typeof potential == 'string'); 2950 | } 2951 | 2952 | function isAnErrorType(type) { 2953 | if (typeof type !== 'function') { 2954 | return false; 2955 | } 2956 | 2957 | var Surrogate = function() {}; 2958 | Surrogate.prototype = type.prototype; 2959 | return (new Surrogate()) instanceof Error; 2960 | } 2961 | } 2962 | 2963 | return toThrowError; 2964 | }; 2965 | 2966 | getJasmineRequireObj().interface = function(jasmine, env) { 2967 | var jasmineInterface = { 2968 | describe: function(description, specDefinitions) { 2969 | return env.describe(description, specDefinitions); 2970 | }, 2971 | 2972 | xdescribe: function(description, specDefinitions) { 2973 | return env.xdescribe(description, specDefinitions); 2974 | }, 2975 | 2976 | fdescribe: function(description, specDefinitions) { 2977 | return env.fdescribe(description, specDefinitions); 2978 | }, 2979 | 2980 | it: function() { 2981 | return env.it.apply(env, arguments); 2982 | }, 2983 | 2984 | xit: function() { 2985 | return env.xit.apply(env, arguments); 2986 | }, 2987 | 2988 | fit: function() { 2989 | return env.fit.apply(env, arguments); 2990 | }, 2991 | 2992 | beforeEach: function() { 2993 | return env.beforeEach.apply(env, arguments); 2994 | }, 2995 | 2996 | afterEach: function() { 2997 | return env.afterEach.apply(env, arguments); 2998 | }, 2999 | 3000 | beforeAll: function() { 3001 | return env.beforeAll.apply(env, arguments); 3002 | }, 3003 | 3004 | afterAll: function() { 3005 | return env.afterAll.apply(env, arguments); 3006 | }, 3007 | 3008 | expect: function(actual) { 3009 | return env.expect(actual); 3010 | }, 3011 | 3012 | pending: function() { 3013 | return env.pending.apply(env, arguments); 3014 | }, 3015 | 3016 | fail: function() { 3017 | return env.fail.apply(env, arguments); 3018 | }, 3019 | 3020 | spyOn: function(obj, methodName) { 3021 | return env.spyOn(obj, methodName); 3022 | }, 3023 | 3024 | jsApiReporter: new jasmine.JsApiReporter({ 3025 | timer: new jasmine.Timer() 3026 | }), 3027 | 3028 | jasmine: jasmine 3029 | }; 3030 | 3031 | jasmine.addCustomEqualityTester = function(tester) { 3032 | env.addCustomEqualityTester(tester); 3033 | }; 3034 | 3035 | jasmine.addMatchers = function(matchers) { 3036 | return env.addMatchers(matchers); 3037 | }; 3038 | 3039 | jasmine.clock = function() { 3040 | return env.clock; 3041 | }; 3042 | 3043 | return jasmineInterface; 3044 | }; 3045 | 3046 | getJasmineRequireObj().version = function() { 3047 | return '2.2.0'; 3048 | }; 3049 | -------------------------------------------------------------------------------- /vendor/assets/libs/jasmine/jasmine_favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fnando/test_squad/69c4f88e401e9a0e3077a86ef45b632676ff7f85/vendor/assets/libs/jasmine/jasmine_favicon.png --------------------------------------------------------------------------------