<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dr Nic &#187; Testing</title>
	<atom:link href="http://drnicwilliams.com/category/testing/feed/" rel="self" type="application/rss+xml" />
	<link>http://drnicwilliams.com</link>
	<description>Ruby makes Rails, Javascript makes Ajax, Dr Nic makes Magic</description>
	<lastBuildDate>Tue, 03 Aug 2010 23:44:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Future proofing your Ruby code. Ruby 1.9.1 is coming.</title>
		<link>http://drnicwilliams.com/2008/12/11/future-proofing-your-ruby-code/</link>
		<comments>http://drnicwilliams.com/2008/12/11/future-proofing-your-ruby-code/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 04:37:49 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Cucumber]]></category>
		<category><![CDATA[Gems]]></category>
		<category><![CDATA[Link]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/?p=368</guid>
		<description><![CDATA[Bugger. I&#8217;m a Ruby monogamist. I use the Ruby that comes with Leopard (ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]). Oh sure I&#8217;ve cheated on my Ruby a couple of times. It was just sex, I didn&#8217;t fall in love, I promise. My machine has had various versions of jRuby, Rubinius and MacRuby installed at various [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/' rel='bookmark' title='Permanent Link: Validate and Save your Ruby in TextMate &#8211; with secret Rubinus superpowers'>Validate and Save your Ruby in TextMate &#8211; with secret Rubinus superpowers</a> <small>In some TextMate bundles, if you save a file it...</small></li><li><a href='http://drnicwilliams.com/2009/11/04/hacking-someones-gem-with-github-and-gemcutter/' rel='bookmark' title='Permanent Link: Hacking someone&#8217;s gem with github and gemcutter'>Hacking someone&#8217;s gem with github and gemcutter</a> <small> Ever used a rubygem, found a bug, and just...</small></li><li><a href='http://drnicwilliams.com/2009/10/07/hash-bang-cucumber/' rel='bookmark' title='Permanent Link: hash bang cucumber'>hash bang cucumber</a> <small>I don&#8217;t know if this is a good idea or...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p><img src="http://img.skitch.com/20081210-qu1ekkhmbtyfjwbchbmwe89gru.png" width="550" height="133"></p>
<p>Bugger.</p>
<p>I&#8217;m a Ruby monogamist. I use the Ruby that comes with Leopard (<code>ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]</code>). Oh sure I&#8217;ve cheated on my Ruby a couple of times. It was just sex, I didn&#8217;t fall in love, I promise. </p>
<p>My machine has had various versions of jRuby, Rubinius and MacRuby installed at various times, but I don&#8217;t think it&#8217;s ever had two working copies of Ruby MRI (Matz Ruby Implementation) at a time.</p>
<p>Ok, that&#8217;s a lie. On Christmas Day 2007, Matz released Ruby 1.9. Yes I was a deviant. I installed it. But I didn&#8217;t inhale. <code>ruby19</code> sat on my filesystem outside the $PATH. It was a trophy not a tool.</p>
<p>My Ruby monogamy was working out perfectly for me, whilst I collected futurist and novelty Ruby implementations as a passive hobby, until yesterday when I saw the above tweet.</p>
<p>That&#8217;s a bit of a bugger. I mean, why was he playing with Ruby 1.9.1 anyway?</p>
<p>Or perhaps having multiple version of Ruby on one computer isn&#8217;t some illicit activity. <em>Everyone else is doing it, Your Honour.</em></p>
<p>I still didn&#8217;t care for having multiple ruby versions lying around in my path; but I had to fix <a href="http://rubigen.rubyforge.org">rubigen</a>. I just wanted a way to fix bugs against ruby 1.9+ and move on with my life. I didn&#8217;t want to have to do any manual work in order to set this up. Surely someone else has solved this problem already?</p>
<p><span id="more-368"></span></p>
<h3 id="multiruby">MultiRuby</h3>
<p>Yes. Ryan Davis did <a href="http://blog.zenspider.com/2007/12/testing-for-ruby-18-and-19-usi.html">solve this problem already</a>. You can follow his instructions and get most of the answers I needed. Except as of today, multiruby wasn&#8217;t pulling down my nemesis ruby 1.9.1 prerelease versions, just the latest 1.9.0 version. (update: <a href="http://www.rubyinside.com/ruby-191-released-first-production-release-of-the-fastest-ruby-ever-1480.html">1.9.1 is out</a>; installation instructions below are updated)</p>
<p>Also, I couldn&#8217;t figure out how to setup rubygems and I couldn&#8217;t figure out how install all the fun gems that my code needed. Ryan fixed me up with this answer too.</p>
<p>MultiRuby is really nice in that it installs all the version of ruby into a safe place (<code>~/.multiruby/</code>) and has nice ways to add and remove versions of ruby that you want to test against. To run the tests for rubigen I ran the following code. It takes about 30 minutes from scratch.</p>
<pre>sudo gem install ZenTest
multiruby -e "p 1+1"
multiruby_setup mri:svn:tag:v1_8_6_114
multiruby_setup mri:svn:tag:v1_9_1_0

multiruby_setup update:rubygems
multiruby -S gem install --no-ri --no-rdoc --development test-unit rspec mocha rails
</pre>
<p>To get the full list of available ruby tagged releases, ask the SVN repo:</p>
<pre>svn list http://svn.ruby-lang.org/repos/ruby/tags
</pre>
<p>Sometimes I got time out errors on the gem installs</p>
<pre>ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    timed out (http://gems.rubyforge.org/gems/rails-2.2.2.gem)
</pre>
<p>The next section helps fix this if it occurs for you.</p>
<h3 id="sake_tasks_to_help_with_multiruby">Sake tasks to help with multiruby</h3>
<p>Whilst <code>multiruby_setup</code> comes with some useful helpers, and hoe generates a helpful &#8216;rake multi&#8217; runner for test/unit tests of hoe gems, I wanted more helpers. These have been compiled as sake tasks in <a href="http://github.com/drnic/sake-tasks">http://github.com/drnic/sake-tasks</a>.</p>
<p>To install them from scratch (<a href="http://drnicwilliams.com/2008/08/19/my-attempt-at-sake-task-management/">initial blog post</a>):</p>
<pre>sudo gem install sake
cd /tmp
git clone git://github.com/drnic/sake-tasks.git
cd sake-tasks
rake install:all
</pre>
<p>You can toss away the repo after installing the sake tasks.</p>
<h3 id="installing_gems_into_multiruby">Installing gems into multiruby</h3>
<p>Each version of ruby has its own rubygems cache. To install a gem into each ruby version:</p>
<pre>sake multiruby:gems:install GEM=gemname
sake multiruby:gems:install GEMS=gem1,gem2
</pre>
<p>Want to see what gems were installed for each version of ruby?</p>
<pre>multiruby -S gem list
</pre>
<h3 id="running_tests">Running tests</h3>
<p>If you use hoe, and your tests are traditional <code>test/unit</code> tests, then hoe comes with a very helpful <code>rake multi</code> task.</p>
<p>For everyone else, use the following sake tasks:</p>
<pre>sake multiruby       # Runs any tests or specs in current project against multiruby
sake multiruby:spec  # Runs specs in current project against multiruby
sake multiruby:test  # Runs tests in current project against multiruby
</pre>
<h3 id="miscellaneous_multiruby_management">Miscellaneous MultiRuby management</h3>
<p>When I was fixing rubigen, I had some failing tests against 1.9.0-5 but not against 1.9.1, so I decided I hated 1.9.0 and stopped running tests against it. You can stop supporting a version of ruby with:</p>
<pre>multiruby_setup rm:1.9.0-5
</pre>
<p>Not sure what versions of ruby you&#8217;re supporting?</p>
<pre>multiruby_setup list
</pre>
<h3 id="cucumber">Cucumber</h3>
<p>Theoretically you could try something like (after installing cucumber gem into multiruby):</p>
<pre>multiruby -S cucumber features
multiruby -S cucumber --format progress features
</pre>
<p>My scenarios are failing at the moment. All of them. And the log/stdout files are overwriting each other in the tmp folder. To isolate it down to one scenario you&#8217;d try something like:</p>
<pre>multiruby -S cucumber features/executable_generator.feature:7
</pre>
<p>You can now easily isolate and run a specific cucumber scenario against a specific ruby version by copy+pasting from the output of the above line. For example:</p>
<pre>~/.multiruby/install/v1_8_6_114/bin/ruby -S cucumber features/executable_generator.feature:7
</pre>
<p>Perhaps this is too much information. I&#8217;m still getting cucumber + multiruby working together, so I&#8217;ll add new ideas to the bottom of this post as I figure them out.</p>
<h3>Running rake tasks</h3>
<p>I&#8217;ve been poking around a bunch of other people&#8217;s gems seeing how many gems current pass against ruby 1.9.1 (answer: not many). When I came across nokogiri, I found that I needed to trigger the build steps of the C code first before running the tests. The simplest way to do this was via its own rake tasks.</p>
<pre>multiruby -S rake clean test</pre>
<p>Here we are calling the &#8216;clean&#8217; task first, so that the C code is rebuilt from scratch for each new ruby version. BTW, there are 6 failing tests for v1_9_1_preview2.</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2010/06/01/validate-and-save-your-ruby-in-textmate-with-secret-rubinus-superpowers/' rel='bookmark' title='Permanent Link: Validate and Save your Ruby in TextMate &#8211; with secret Rubinus superpowers'>Validate and Save your Ruby in TextMate &#8211; with secret Rubinus superpowers</a> <small>In some TextMate bundles, if you save a file it...</small></li><li><a href='http://drnicwilliams.com/2009/11/04/hacking-someones-gem-with-github-and-gemcutter/' rel='bookmark' title='Permanent Link: Hacking someone&#8217;s gem with github and gemcutter'>Hacking someone&#8217;s gem with github and gemcutter</a> <small> Ever used a rubygem, found a bug, and just...</small></li><li><a href='http://drnicwilliams.com/2009/10/07/hash-bang-cucumber/' rel='bookmark' title='Permanent Link: hash bang cucumber'>hash bang cucumber</a> <small>I don&#8217;t know if this is a good idea or...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2008/12/11/future-proofing-your-ruby-code/feed/</wfw:commentRss>
		<slash:comments>36</slash:comments>
		</item>
		<item>
		<title>My RubyGems development tools and workflow</title>
		<link>http://drnicwilliams.com/2008/12/05/my-rubygems-development-tools-and-workflow/</link>
		<comments>http://drnicwilliams.com/2008/12/05/my-rubygems-development-tools-and-workflow/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 08:05:20 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Gems]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/?p=357</guid>
		<description><![CDATA[The Open Source Developers Conference (osdc) is a nifty conference &#8211; people from different language communities, who all do open source, come together in harmony. They simultaneously snigger at each other and then proceed to steal each others ideas when they aren&#8217;t looking. Miscellaneous idea possibly worth stealing from Perl: when you install Perl modules [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2009/11/04/hacking-someones-gem-with-github-and-gemcutter/' rel='bookmark' title='Permanent Link: Hacking someone&#8217;s gem with github and gemcutter'>Hacking someone&#8217;s gem with github and gemcutter</a> <small> Ever used a rubygem, found a bug, and just...</small></li><li><a href='http://drnicwilliams.com/2008/12/11/future-proofing-your-ruby-code/' rel='bookmark' title='Permanent Link: Future proofing your Ruby code. Ruby 1.9.1 is coming.'>Future proofing your Ruby code. Ruby 1.9.1 is coming.</a> <small> Bugger. I&#8217;m a Ruby monogamist. I use the Ruby...</small></li><li><a href='http://drnicwilliams.com/2006/10/18/create-and-deploy-command-line-apps-with-rubygems/' rel='bookmark' title='Permanent Link: Create and deploy command line apps with RubyGems'>Create and deploy command line apps with RubyGems</a> <small>RubyGems have many things going for them: they are a...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p><img alt="" src="http://img.skitch.com/20081204-x2rcu7ajds1wah41b943m8cd7a.png" title="Create lots of gems" class="alignright" width="246" height="387" /></p>
<p>The Open Source Developers Conference (<a href="http://www.osdc.com.au">osdc</a>) is a nifty conference &#8211; people from different language communities, who all do open source, come together in harmony. They simultaneously snigger at each other and then proceed to steal each others ideas when they aren&#8217;t looking.</p>
<p>Miscellaneous idea possibly worth stealing from Perl: when you install Perl modules from CPAN it runs the module&#8217;s tests locally to confirm everything is oaky-dokey. You can manually do this via <code>gem install --test rails</code>, but its not the default. Nor have I ever used the <code>--test</code> flag. I just looked it up via <code>gem help install</code>. I like it.</p>
<p>Another CPAN thing to steal: For any RubyGem or perhaps Rails project on rubyforge/github/whatever, show the aggregate status of tests. Here&#8217;s a <a href="http://deps.cpantesters.org/?module=App::Asciio;perl=latest">sample from CPAN</a>. Lots of green lines but the aggregate change of this project working? 11%. I like the chart, and perhaps <a href="http://runcoderun.com">runcoderun</a> or some other hosted CI service to generate a sexy graph of test outputs for dependencies.</p>
<p>Anyway, Ruby. I did a talk. I have <a href="http://drnicwilliams.com/wp-content/uploads/2008/12/rubygem-dev-and-workflow-osdc2008-20081204.pdf">slides</a>.</p>
<div style="width:425px;text-align:left" id="__ss_819679"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/drnic/rubygem-dev-and-workflow-presentation?type=powerpoint" title="Rubygem Dev And Workflow">Rubygem Dev And Workflow</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=rubygem-dev-and-workflow-1228434585968621-8&#038;stripped_title=rubygem-dev-and-workflow-presentation" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slideshare.net/swf/ssplayer2.swf?doc=rubygem-dev-and-workflow-1228434585968621-8&#038;stripped_title=rubygem-dev-and-workflow-presentation" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></div>
<p>Over time I&#8217;ve written a few RubyGems and am pretty happy with my basic tools and workflow for getting new gems out the door or maintaining existing projects. I use newgem + a patched version of hoe, I use git + github, and recently I started using runcoderun for hosted continuous integration. </p>
<p>If you&#8217;re new to creating your own RubyGems, perhaps my workflow and tools are a useful starting point to follow.</p>
<p>If you want an account with <a href="http://runcoderun.com/">runcoderun</a>, and I reckon you do, then hassle <a href="http://blog.thinkrelevance.com/2008/10/14/runcoderun-now-open-to-the-anonymous-public-2">Rob Sanheim</a> (<a href="http://twitter.com/rsanheim">twitter</a>). For what its worth, tell him I said it was urgent.</p>
<p>There is now a <a href="http://thinkrelevance.rubyforge.org/runcoderun_badge/">sexy blog badge</a> to show off the current pass/fail state of each of your projects, by <a href="http://blog.thinkrelevance.com/2008/10/17/runcoderun-badges">Glenn Vanderburg</a>. Badges are fun. It seems to clash with having github-badge in the same page, and there are other bugs with these badges. Probably my fault. I should investigate that soon.</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2009/11/04/hacking-someones-gem-with-github-and-gemcutter/' rel='bookmark' title='Permanent Link: Hacking someone&#8217;s gem with github and gemcutter'>Hacking someone&#8217;s gem with github and gemcutter</a> <small> Ever used a rubygem, found a bug, and just...</small></li><li><a href='http://drnicwilliams.com/2008/12/11/future-proofing-your-ruby-code/' rel='bookmark' title='Permanent Link: Future proofing your Ruby code. Ruby 1.9.1 is coming.'>Future proofing your Ruby code. Ruby 1.9.1 is coming.</a> <small> Bugger. I&#8217;m a Ruby monogamist. I use the Ruby...</small></li><li><a href='http://drnicwilliams.com/2006/10/18/create-and-deploy-command-line-apps-with-rubygems/' rel='bookmark' title='Permanent Link: Create and deploy command line apps with RubyGems'>Create and deploy command line apps with RubyGems</a> <small>RubyGems have many things going for them: they are a...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2008/12/05/my-rubygems-development-tools-and-workflow/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>newjs = newgem for JavaScript projects; free TDD suite</title>
		<link>http://drnicwilliams.com/2008/02/17/newjs-javascript-project-generator/</link>
		<comments>http://drnicwilliams.com/2008/02/17/newjs-javascript-project-generator/#comments</comments>
		<pubDate>Sun, 17 Feb 2008 05:06:13 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[RubiGen]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2008/02/17/newjs-javascript-project-generator/</guid>
		<description><![CDATA[Want to start a new JavaScript project for a library or widget/badge for your website? You know you should do TDD but wouldn&#8217;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&#8217;d like a consistent structure to [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2010/03/15/using-coffeescript-in-rails-and-even-on-heroku/' rel='bookmark' title='Permanent Link: Using CoffeeScript in Rails and even on Heroku'>Using CoffeeScript in Rails and even on Heroku</a> <small>I&#8217;m pretty excited about CoffeeScript as a clean-syntax replacement for...</small></li><li><a href='http://drnicwilliams.com/2008/10/31/newgem-100-all-thanks-to-cucumber/' rel='bookmark' title='Permanent Link: newgem 1.0.0 all thanks to Cucumber'>newgem 1.0.0 all thanks to Cucumber</a> <small>The New Gem Generator (newgem) was exciting, moderately revolutionary, and...</small></li><li><a href='http://drnicwilliams.com/2008/02/19/one-stop-javascript-unit-testing-for-rails2/' rel='bookmark' title='Permanent Link: One-stop JavaScript Unit Testing for Rails 2.0'>One-stop JavaScript Unit Testing for Rails 2.0</a> <small>Previously, I mentioned a multi-step/multi-project solution to doing JavaScript Unit...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Want to start a new JavaScript project for a library or widget/badge for your website?</p>
<p>You know you should do TDD but wouldn&#8217;t know how to get started, what support libraries you need and where to get them from? </p>
<p>You need tools to deploy your library, your website etc?</p>
<p>You&#8217;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&#8217;t done this bit yet, I&#8217;m sure I&#8217;ll add it to the <a href="http://github.com/drnic/javascript-unittest-tmbundle/tree/master">JavaScipt Unit testing</a> textmate bundle one day soon].</p>
<p>I couldn&#8217;t find anything helpful like this, so I created <code>newjs</code> &#8211; the <a href="http://newjs.rubyforge.org">JavaScript Project Generator</a>.</p>
<h3 id="why">Why?</h3>
<p>But first, an brief history of everything&#8230;</p>
<p>I fell instantly in love with Rails for a couple reasons:</p>
<ul>
<li><code>rails</code> &amp; <code>script/generate</code> commands &#8211; they teach you what files you need<br />
and where they should go</li>
<li>Ajax support &#8211; the marketing phrase &#8220;its as easy to use Ajax as not to&#8221; took me<br />
away from ASP.NET where the new Ajax.NET library was non-trivial to use; RJS<br />
didn&#8217;t exist at this stage, but Rails&#8217; JavaScript support was still awesome</li>
<li>TextMate &#8211; though I didn&#8217;t get to use it for 18 mths til I bought a Mac</li>
</ul>
<p>Later I fell in love with Ruby, for its meta-programming, syntactical possibilities<br />
and free TDD support within Rails.</p>
<p>Then I fell out of love with JavaScript. Partly because Rails started generating JavaScript for me, and ultimately because I didn&#8217;t have test support. Whether you use Rails JavaScript helpers, or write your own unobtrusive JavaScript libraries you&#8217;re still living in an unhappy world without tests; let alone without TDD.</p>
<p>I still wrote JavaScript because it still needed writing. But a lot of my JavaScript<br />
became &#8220;write-once, modify-never&#8221; affairs. Not just because I had no tests,<br />
but each project had a different structure, different deployment processes, etc.</p>
<p>Finally, this year I figured out &#8220;TDD for JavaScript&#8221;. For every 1000 blog articles about Rails or Ruby, there is 0-1 article on unit testing JavaScript. Or perhaps I just don&#8217;t know how to use Google. Soon, the &#8220;JavaScript Unit Testing&#8221; <a href="http://peepcode.com">PeepCode</a> will be finished, so hopefully it will add to this lacking body of knowledge.</p>
<p>What I needed now was one-line starter-kit for new JavaScript projects that included:</p>
<ul>
<li>A standard structure for JavaScript libraries/projects</li>
<li>In-built testing support, with <code>rake</code> tasks and <code>script/generate unit_test</code><br />
generators</li>
<li>Tasks for deploying distribution files (via version numbers)</li>
<li>Tasks for managing the project website</li>
</ul>
<p>I don&#8217;t think there is one already, thus my hand was forced: <a href="http://newjs.rubyforge.org">newjs</a>.</p>
<h3 id="installation_getting_started">Installation &amp; Getting Started</h3>
<p>Installation and maintenance of generated JavaScript projects requires the installation of <a href="http://www.ruby-lang.org/">Ruby</a> and <a href="http://rubygems.org/">RubyGems</a>.</p>
<p>The command-line application <code>newjs</code> is installed as below, for any operating system (except the &#8216;sudo&#8217; part &#8211; use as necessary):</p>
<pre>sudo gem install newjs</pre>
<p>You&#8217;ll note it uses <a href="http://rubigen.rubyforge.org">RubiGen</a> because I like to cheat when it comes to generating things.</p>
<p>To kick-off your new project/library, run the command-line app <code>newjs</code>:</p>
<pre>$ newjs mylib -a "Dr Nic" -e "drnicwilliams@gmail.com" -u "http://mylib.rubyforge.org"
      create  config
      create  lib
      create  src
      create  script
      create  tasks
      create  test/assets
      create  test/assets/unittest.css
      create  test/assets/unittest.js
      create  test/assets/prototype.js
      create  tasks/javascript_test_autotest_tasks.rake
      create  tasks/environment.rake
      create  tasks/deploy.rake
      create  config/javascript_test_autotest.yml.sample
      create  lib/protodoc.rb
      create  lib/jstest.rb
      create  Rakefile
      create  README.txt
      create  History.txt
      create  License.txt
      create  src/HEADER
      create  src/mylib.js
      create  script/rstakeout
      create  script/js_autotest
  dependency  install_rubigen_scripts
      exists    script
      create    script/generate
      create    script/destroy
</pre>
<p>And you thought you wanted to create all that by hand&#8230;</p>
<h3 id="tdd_for_javascript">TDD for JavaScript</h3>
<p>Personally, I can never remember what basic HTML + JavaScript goes in the test HTML files. I quite like the <a href="http://drnicwilliams.com/2008/01/04/autotesting-javascript-in-rails/">javascript_test plugin</a> for Rails, which allows you to generate a test HTML stub. So I&#8217;ve included a version of it<br />
here.</p>
<p>Two actually: one for unit tests and one for functional tests.</p>
<pre>$ script/generate unit_test some_lib
  create  test/unit
  create  test/unit/some_lib_test.html
</pre>
<p>For functional tests, use <code>functional_test</code> generator. See the <a href="http://newjs.rubyforge.org">newjs site</a> for more details.</p>
<h3 id="lifecycle_of_javascript_files">Lifecycle of JavaScript files</h3>
<p>You create JavaScript files in <code>src/</code> and then when you run <code>rake dist</code><br />
they can compressed into <code>dist/project_name.js</code>. </p>
<p>To make this work, add new <code>src/</code> files into <code>src/project_name.js</code> via<br />
<code>&lt;%= include "file_name.js" %&gt;</code>.</p>
<p>This is the build mechanism used by <a href="http://prototypejs.org" alt="PrototypeJS">prototypejs</a> and I stole it. Actually, I stole nearly everything from the prototypejs source structure.</p>
<h3 id="other_stuff">Other stuff</h3>
<p>Like <a href="http://newgem.rubyforge.org">newgem</a> you can create a simple website (via textile files):</p>
<pre>script/generate install_website
</pre>
<p>BONUS: instead of the crap purple default theme for <code>newgem</code>, <code>newjs</code> websites have a nice yellow theme &#8211; <a href="http://drnicutilities.rubyforge.org/drnic_js_test_helpers/" alt=" Dr Nic’s JavaScript Test Helpers">see example</a>.</p>
<h3 id="source">Source for newjs</h3>
<p>Get it via git: <a href="http://github.com/drnic/newjs/tree/master">master branch</a></p>
<h3 id="credits">Credits</h3>
<p>The generated structure, the unittest.js test suite, and its included help files mostly come from <a href="http://prototypejs.org PrototypeJS">prototypejs</a> and <a href="http://newgem.rubyforge.org">newgem</a>.</p>
<p>The generator mechanism is from <a href="http://rubigen.rubyforge.org">RubiGem</a> which comes from the Rails Generator created by Jeremy &#8220;<a href="http://www.oreillynet.com/ruby/blog/2007/09/7_reasons_i_switched_back_to_p_1.html">I made someone leave Rails for PHP</a>&#8221; Kemper.</p>
<p>Actually, I stole nearly everything from the prototypejs source structure. They are much cleverer than I am.</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2010/03/15/using-coffeescript-in-rails-and-even-on-heroku/' rel='bookmark' title='Permanent Link: Using CoffeeScript in Rails and even on Heroku'>Using CoffeeScript in Rails and even on Heroku</a> <small>I&#8217;m pretty excited about CoffeeScript as a clean-syntax replacement for...</small></li><li><a href='http://drnicwilliams.com/2008/10/31/newgem-100-all-thanks-to-cucumber/' rel='bookmark' title='Permanent Link: newgem 1.0.0 all thanks to Cucumber'>newgem 1.0.0 all thanks to Cucumber</a> <small>The New Gem Generator (newgem) was exciting, moderately revolutionary, and...</small></li><li><a href='http://drnicwilliams.com/2008/02/19/one-stop-javascript-unit-testing-for-rails2/' rel='bookmark' title='Permanent Link: One-stop JavaScript Unit Testing for Rails 2.0'>One-stop JavaScript Unit Testing for Rails 2.0</a> <small>Previously, I mentioned a multi-step/multi-project solution to doing JavaScript Unit...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2008/02/17/newjs-javascript-project-generator/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Functional Testing using a Matrix to cover all edge cases [video]</title>
		<link>http://drnicwilliams.com/2007/05/22/functional-testing-using-a-matrix-to-cover-all-edge-cases-video/</link>
		<comments>http://drnicwilliams.com/2007/05/22/functional-testing-using-a-matrix-to-cover-all-edge-cases-video/#comments</comments>
		<pubDate>Tue, 22 May 2007 07:12:46 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Link]]></category>
		<category><![CDATA[Presentation]]></category>
		<category><![CDATA[RejectConf]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2007/05/22/functional-testing-using-a-matrix-to-cover-all-edge-cases-video/</guid>
		<description><![CDATA[I&#8217;ve been a fan of Ryan Davis&#8216; (zenspider) and Eric Hodel&#8216; ZenTest library (including its autotest CI tool for rails and gems), and their Hoe gem, the Rubyforge gem, etc ever since I figured out what they did. (Side note: how to setup rubyforge gem) Over the last month, Ryan mentioned &#8220;functional testing by a [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2009/03/26/testing-outbound-emails-with-cucumber/' rel='bookmark' title='Permanent Link: Testing outbound emails with Cucumber'>Testing outbound emails with Cucumber</a> <small> My testimonial for Cucumber still stands even in 2009....</small></li><li><a href='http://drnicwilliams.com/2008/12/05/my-rubygems-development-tools-and-workflow/' rel='bookmark' title='Permanent Link: My RubyGems development tools and workflow'>My RubyGems development tools and workflow</a> <small> The Open Source Developers Conference (osdc) is a nifty...</small></li><li><a href='http://drnicwilliams.com/2008/07/04/unit-testing-iphone-apps-with-ruby-rbiphonetest/' rel='bookmark' title='Permanent Link: Unit Testing iPhone apps with Ruby: rbiphonetest'>Unit Testing iPhone apps with Ruby: rbiphonetest</a> <small> Everything to love about Ruby: the concise, powerful language;...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been a fan of <a href="http://blog.zenspider.com">Ryan Davis</a>&#8216; (zenspider) and <a href="http://blog.segment7.net">Eric Hodel</a>&#8216; ZenTest library (including its autotest CI tool for rails and gems), and their <a href="http://seattlerb.rubyforge.org/hoe/">Hoe</a> gem, the Rubyforge gem, etc ever since I figured out what they did. (Side note: how to <a href="http://newgem.rubyforge.org/rubyforge.html">setup rubyforge gem</a>)</p>
<p>Over the last month, Ryan mentioned &#8220;functional testing by a matrix&#8221; in <a href="http://blog.zenspider.com/archives/2007/04/functional_test_matrix.html">four</a> <a href="http://blog.zenspider.com/archives/2007/04/functional_test_matrix_cont_sorta.html">great</a> <a href="http://blog.zenspider.com/archives/2007/04/functional_test_matrix_a_visualization.html">blog</a> <a href="http://blog.zenspider.com/archives/2007/05/functional_test_matrix_gets_a_nice_little_boost.html">articles</a>.</p>
<p>Ryan shows this off at RejectConf; its 16 minutes but definitely worth your time to investigate, as I think this will be awesome for ensuring basic edge cases are thoroughly tested. Can a guest create something? Can a member delete something?</p>
<p>It is hard to see the code on the screen, but look at the blog posts linked above to get the gist of what is being shown.</p>
<p>People were really interested this as you can tell by the huge number of questions, despite this being the last of many many presentations.</p>
<p><embed style="width:500px; height:376px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=-2381939140760426511&#038;hl=en" flashvars=""> </embed></p>
<p>This stuff looks primed for a sweet generator to create the test file.</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2009/03/26/testing-outbound-emails-with-cucumber/' rel='bookmark' title='Permanent Link: Testing outbound emails with Cucumber'>Testing outbound emails with Cucumber</a> <small> My testimonial for Cucumber still stands even in 2009....</small></li><li><a href='http://drnicwilliams.com/2008/12/05/my-rubygems-development-tools-and-workflow/' rel='bookmark' title='Permanent Link: My RubyGems development tools and workflow'>My RubyGems development tools and workflow</a> <small> The Open Source Developers Conference (osdc) is a nifty...</small></li><li><a href='http://drnicwilliams.com/2008/07/04/unit-testing-iphone-apps-with-ruby-rbiphonetest/' rel='bookmark' title='Permanent Link: Unit Testing iPhone apps with Ruby: rbiphonetest'>Unit Testing iPhone apps with Ruby: rbiphonetest</a> <small> Everything to love about Ruby: the concise, powerful language;...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2007/05/22/functional-testing-using-a-matrix-to-cover-all-edge-cases-video/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
