You know you should do TDD but wouldn’t know how to get started, what support libraries you need and where to get them from?
You need tools to deploy your library, your website etc?
You’d like a consistent structure to your project so that IDEs could provide support (toggle btw src/person.js and test/unit/person_test.html) [I haven’t done this bit yet, I’m sure I’ll add it to the JavaScipt Unit testing textmate bundle one day soon].
I couldn’t find anything helpful like this, so I created
But first, an brief history of everything…
I fell instantly in love with Rails for a couple reasons:
script/generatecommands – they teach you what files you need
and where they should go
- Ajax support – the marketing phrase “its as easy to use Ajax as not to” took me
away from ASP.NET where the new Ajax.NET library was non-trivial to use; RJS
- TextMate – though I didn’t get to use it for 18 mths til I bought a Mac
Later I fell in love with Ruby, for its meta-programming, syntactical possibilities
and free TDD support within Rails.
became “write-once, modify-never” affairs. Not just because I had no tests,
but each project had a different structure, different deployment processes, etc.
- In-built testing support, with
- Tasks for deploying distribution files (via version numbers)
- Tasks for managing the project website
I don’t think there is one already, thus my hand was forced: newjs.
Installation & Getting Started
The command-line application
newjs is installed as below, for any operating system (except the ‘sudo’ part – use as necessary):
sudo gem install newjs
You’ll note it uses RubiGen because I like to cheat when it comes to generating things.
To kick-off your new project/library, run the command-line app
And you thought you wanted to create all that by hand…
Two actually: one for unit tests and one for functional tests.
$ script/generate unit_test some_lib create test/unit create test/unit/some_lib_test.html
For functional tests, use
functional_test generator. See the newjs site for more details.
src/ and then when you run
they can compressed into
To make this work, add new
src/ files into
<%= include "file_name.js" %>.
This is the build mechanism used by prototypejs and I stole it. Actually, I stole nearly everything from the prototypejs source structure.
Like newgem you can create a simple website (via textile files):
BONUS: instead of the crap purple default theme for
newjs websites have a nice yellow theme – see example.
Source for newjs
Get it via git: master branch
Actually, I stole nearly everything from the prototypejs source structure. They are much cleverer than I am.
- Using CoffeeScript in Rails and even on Heroku I’m pretty excited about CoffeeScript as a clean-syntax replacement for...
- newgem 1.0.0 all thanks to Cucumber The New Gem Generator (newgem) was exciting, moderately revolutionary, and...
- NewGem Generator – now with script/generate The New Gem Generator (0.13.0)’s newgem command now behaves like...