abu

Jasmine test skeleton builder for Tetra.js

Abu - a little helper for Tetra.js projects

abu helps you setup Tetra.js projects and its Jasmine test specs.

But remember - you should write your tests before you write your code!

  1. Install the latest version of Node
  2. Run npm install -g abu
  3. Once install has finished, run abu --help

Run npm update -g abu (or npm update -g to update all global libraries)

By default, abu will expect a Maven-configured project, with Tetra.js resources residing in the following folders

  • Application code at src\main\webapp\javascript\coremvc\apps
  • Global tetra models at src\main\webapp\javascript\coremvc\model
  • Test spec code at src\test\javascript\coremvc

You can override these defaults by creating a file named abu.json in the project root. Consult the file abu.sample.json to see how this file should be formatted.

abu can build empty model, view and controller skeletons for new projects, along with test skeletons and empty fixtures.

  1. Open a command prompt and go to your project root directory (e.g. C:\projects\myProject)
  2. Run abu make myApp, where myApp is the name of the application you want to create

abu will create

  • empty model, view and controller skeletons in the coremvc\apps\myApp directory
  • empty test skeletons in the src\test\javascript\coremvc\myApp location
  • an empty fixture at src\test\javascript\fixtures\myApp
  • --model [model] Make only this named model
  • --controller [controller] Make only this named controller
  • --view [view] Make only this named view
  • --scope [scope] Name of the scope to use (defaults to the name of the application)
  • --overwrite Overwrite any existing source files or test specs

abu can generate partially completed Jasmine test specs for an existing project.

  1. Open a command prompt and go to the project root directory (e.g. C:\projects\myProject)
  2. Run abu test myApp, where myApp is the name of the application you want to test

abu will run a check on the code, and then create

  • partially complete model, view and test specs in the src\test\javascript\coremvc\myApp location, for all models, views and controllers found in the project
  • an empty fixture at src\test\javascript\fixtures\myApp
  • --controller [controller] Make specs only for this named controller
  • --view [view] Make specs only for this named view
  • --overwrite Overwrite any existing test specs

abu can run some basic validations on existing Tetra.js code.

  1. Open a command prompt and go to the project root directory (e.g. C:\projects\myProject)
  2. Run abu validate myApp, where myApp is the name of the application you want to check

If abu finds a jshint.json configuration file in the root directory, then JSHINT errors will be included in the output. Consult the file jshint.sample.json for an example.

If abu finds an abu.json configuration file with the options cyclomaticComplexityCeiling or maintainabilityFloor, it will also output complexity statistics for files and functions with a cyclomatic complexity greater than the cyclomaticComplexityCeiling value, or files with a Halstead maintainability index less than the maintainabilityFloor value.

  • --model [model] Only validate this named model
  • --controller [controller] Only validate this named controller
  • --view [view] Only validate this named view

Here's a few example commands and the files they create. Remember - abu make will create empty test and MVC skeletons for a new project. abu test will create partially-completed test skeletons generated from an existing project.

  • [tetra-app-dir]/foo/model/foo.class.js
  • [tetra-app-dir]/foo/controller/foo.ctrl.js
  • [tetra-app-dir]/coremvc/foo/view/foo.ui.js
  • [test-dir]/coremvc/foo/foo.ctrl.spec.js
  • [test-dir]/coremvc/foo/foo.ui.spec.js
  • [test-dir]/fixtures/foo/foo.html
  • [tetra-app-dir]/foo/model/bar.class.js
  • [tetra-app-dir]/foo/controller/bar.ctrl.js
  • [test-dir]/coremvc/foo/bar.ctrl.spec.js
  • [tetra-app-dir]/foo/controller/bar.ctrl.js
  • [test-dir]/coremvc/foo/bar.ctrl.spec.js

With scope set to the value 'baz'

  • [tetra-app-dir]/coremvc/foo/view/bar.ui.js
  • [test-dir]/coremvc/foo/bar.ui.spec.js
  • [test-dir]/fixtures/foo/bar.html
  • [test-dir]/coremvc/lightReco/lightReco.ctrl.spec.js
  • [test-dir]/coremvc/lightReco/lightReco.ui.spec.js
  • [test-dir]/fixtures/lightReco/lightReco.html
  • Nothing is generated, as we don't test models directly
  • [test-dir]/coremvc/lightReco/lightReco.ctrl.spec.js
  • [test-dir]/coremvc/lightReco/lightReco.ui.spec.js
  • [test-dir]/fixtures/lightReco/lightReco.html

Nothing will be created as, in this case, all the test spec files already exist

  • [test-dir]/coremvc/miniprofile/miniprofile.ctrl.spec.js
  • [test-dir]/coremvc/miniprofile/miniprofile.ui.spec.js
  • [test-dir]/fixtures/miniprofile/miniprofile.html
  • Validates all models, views and controllers

Pass --model [model], --controller [controller] or --view [view], to limit the validation to a single file.

  • Validates all models, views and controllers and passes the output to the file report.txt.

abu is the kleptomaniac monkey from Disney's Aladdin. Say abu hello and he'll say hi.