<?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; newjs</title>
	<atom:link href="http://drnicwilliams.com/category/newjs/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>Mon, 21 May 2012 03:31:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>One-stop JavaScript Unit Testing for Rails 2.0</title>
		<link>http://drnicwilliams.com/2008/02/19/one-stop-javascript-unit-testing-for-rails2/</link>
		<comments>http://drnicwilliams.com/2008/02/19/one-stop-javascript-unit-testing-for-rails2/#comments</comments>
		<pubDate>Tue, 19 Feb 2008 04:08:30 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[newjs]]></category>
		<category><![CDATA[RubiGen]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2008/02/19/one-stop-javascript-unit-testing-for-rails2/</guid>
		<description><![CDATA[Previously, I mentioned a multi-step/multi-project solution to doing JavaScript Unit Testing for Rails, including an autotest script to make TDD life easier for the autotest-addicted. It was too many steps, too many different projects, and too much dependence on prototypejs. So let&#8217;s fix this via the spanky new newjs (introduced here): Instead of several steps, [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2012/04/10/instant-new-rails-applications-with-the-app-scrolls/' rel='bookmark' title='Permanent Link: Instant new Rails applications with the App Scrolls'>Instant new Rails applications with the App Scrolls</a> <small>When I start a new project I want to start...</small></li><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/2009/11/03/first-look-at-rails-3-0-pre/' rel='bookmark' title='Permanent Link: First look at rails 3.0.pre'>First look at rails 3.0.pre</a> <small> This article is out of date in some aspects....</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://drnicwilliams.com/2008/01/04/autotesting-javascript-in-rails/">Previously</a>, I mentioned a multi-step/multi-project solution to doing JavaScript Unit Testing for Rails, including an autotest script to make TDD life easier for the autotest-addicted.</p>
<p>It was too many steps, too many different projects, and too much dependence on <a href="http://prototypejs.org">prototypejs</a>. So let&#8217;s fix this via the spanky new <a href="http://newjs.rubyforge.org">newjs</a> (<a href="http://drnicwilliams.com/2008/02/17/newjs-javascript-project-generator/">introduced here</a>):</p>
<p>Instead of several steps, there is now two steps:</p>
<pre>
cd myrailsapp                # rails 2.0 app
sudo gem install newjs       # v1.3.1+
script/generate javascript_test application
    create  vendor/plugins/javascript_unittest/lib
    create  vendor/plugins/javascript_unittest/tasks
    create  test/javascript/assets/jsunittest.js
    create  test/javascript/assets/unittest.css
    create  config/javascript_test_autotest.yml.sample
    create  vendor/plugins/javascript_unittest/lib/jstest.rb
    create  vendor/plugins/javascript_unittest/tasks/runner.rake
    create  vendor/plugins/javascript_unittest/tasks/autotest.rake
    create  vendor/plugins/javascript_unittest/README
    create  test/javascript/application_test.html
    create  script/rstakeout
    create  script/js_autotest
</pre>
<p>It installs all assets, gives you a <code>rake test:javascripts</code> task, gives you <code>script/js_autotest</code>, and finally (and most importantly), creates the <code>application_test.html</code> test stub.</p>
<p>As always, you can also run a single test file by loading it into a browser.</p>
<h3 id="prototype_independence">Prototype independence</h3>
<p>Previously, the test suite &#8211; unittest.js &#8211; had a dependency on <a href="http://prototypejs.org">prototypejs</a>. This was wonderful if you&#8217;re developing in prototypejs, but could cause some grief if you weren&#8217;t.</p>
<p><a href="http://newjs.rubyforge.org">newjs</a> now comes packed with an identical test suite &#8211; <a href="http://jsunittest.rubyforge.org">jsunittest</a> &#8211; but it is built without a dependency on prototypejs.</p>
<h3 id="merb_et_al_support">Merb et al support</h3>
<p>I wrote a rails generator because I used Rails. If a merb/other framework (Ruby or non-Ruby) wants a similar generator, just ask. Its pretty simple &#8211; I copy over the <code>rails_generators</code> folder into a <code>merb_generators</code> folder in <code>newjs</code> and change some things based on your frameworks&#8217; structure.</p>
<h3 id="alternate_test_suite_support">Alternate test suite support</h3>
<p>If you like another test suite, and want it included in the generators, this might require some additional effort on your part. It probably has different mechanisms for launching runners etc; whereas I was able to steal the rake tests + support libraries from prototypejs. But, it can be done.</p>
<h3 id="peepcode">Peepcode</h3>
<p>These tools will be discussed in animated detail in the forth coming Peepcode &#8220;JavaScript Unit Testing&#8221;.</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2012/04/10/instant-new-rails-applications-with-the-app-scrolls/' rel='bookmark' title='Permanent Link: Instant new Rails applications with the App Scrolls'>Instant new Rails applications with the App Scrolls</a> <small>When I start a new project I want to start...</small></li><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/2009/11/03/first-look-at-rails-3-0-pre/' rel='bookmark' title='Permanent Link: First look at rails 3.0.pre'>First look at rails 3.0.pre</a> <small> This article is out of date in some aspects....</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2008/02/19/one-stop-javascript-unit-testing-for-rails2/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

