website/index.html in newjs-1.1.0 vs website/index.html in newjs-1.2.0
- old
+ new
@@ -29,11 +29,11 @@
<div id="main">
<h1>JavaScript Project Generator</h1>
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/newjs"; return false'>
<p>Get Version</p>
- <a href="http://rubyforge.org/projects/newjs" class="numbers">1.0.4</a>
+ <a href="http://rubyforge.org/projects/newjs" class="numbers">1.2.0</a>
</div>
<h1>→ ‘newjs’</h1>
<h2>What</h2>
@@ -79,36 +79,38 @@
<p>To kick-off your new project/library, run the command-line app <code>newjs</code>:</p>
-<pre>$ newjs mylib
- 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 config/javascript_test_autotest.yml.sample
- create lib/protodoc.rb
- create README.txt
- create Rakefile
- 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>$ 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>Look at all that!</p>
@@ -118,36 +120,42 @@
<p>Your raw, unconcatenated library/source files go in <code>src/</code></p>
- <p>Your unit test <span class="caps">HTML</span> files, go in <code>test/</code> (see test generator below).</p>
+ <p>Your unit test <span class="caps">HTML</span> files, go in <code>test/unit/</code> (see test generator below).</p>
+ <p>Your functional test <span class="caps">HTML</span> files, go in <code>test/functional/</code> (see test generator below).</p>
+
+
When you’ve got a new version to release, edit <code>Rakefile</code> and modify the
<code>APP_VERSION</code> string (see Distribution section below).
<p>To merge your <code>src/</code> files into a distribution file, see below.</p>
- <h2>Generating test <span class="caps">HTML</span> files</h2>
+ <h2>Unit testing</h2>
<p>If you are going to have a <code>src/some_lib.js</code> file, then you’ll want a unit
test file(s). By default you’d call it <code>test/some_lib_test.html</code>.</p>
+ <h3>Generating test <span class="caps">HTML</span> files</h3>
+
+
<p>And then what? Personally, I can never remember what basic <span class="caps">HTML</span> + JavaScript
goes in the test <span class="caps">HTML</span> files. I quite like the <a href="http://drnicwilliams.com/2008/01/04/autotesting-javascript-in-rails/">javascript_test plugin</a> for <a href="http://www.rubyonrails.org/">Ruby
on Rails</a>, which allows you to generate a
test <span class="caps">HTML</span> stub. So I’ve included a version of it
here. That is, your JavaScript project comes with a generator to create new
test <span class="caps">HTML</span> files, ready to rock and roll.</p>
<pre>$ script/generate unit_test some_lib
- exists test
+ create test/unit
create test/unit/some_lib_test.html</pre>
<p>Now edit <code>test/unit/some_lib_test.html</code> and follow the comments
that tell you what to do to write your unit tests.</p>
@@ -155,14 +163,14 @@
<p>Want to name your test file something different? Specify the target
library as an additional parameter.</p>
<pre>$ script/generate unit_test my_library_tests some_lib
- exists test
+ exists test/unit
create test/unit/my_library_tests_test.html</pre>
- <h2>Running unit tests</h2>
+ <h3>Running unit tests</h3>
<p>Each test <span class="caps">HTML</span> file should be self-executable: just open it in a target
browser. That is, to run the <code>test/some_lib_test.html</code> tests
in Firefox, open the file in Firefox.</p>
@@ -172,10 +180,41 @@
<p><img src="images/example-unittest-log.jpg" width="647" height="427" alt="Example Unittest Log"></p>
+ <h2>Functional tests</h2>
+
+
+ <p>End-to-end functional tests will test the final distribution file(s), rather than
+the <code>src/</code> files.</p>
+
+
+ <p>As shown below, your <code>src/</code> files will be merged into (commonly) one
+distribution file – a merging of your source files.</p>
+
+
+ <h3>Generating test <span class="caps">HTML</span> files</h3>
+
+
+ <p>To create functional tests, there is another generator:</p>
+
+
+<pre>$ script/generate functional_test basic_usage
+ create test/functional
+ create test/functional/basic_usage_test.html</pre>
+
+ <h3>Running functional tests</h3>
+
+
+<pre>rake test_functionals</pre>
+
+ <p>The generated <span class="caps">HTML</span> file uses the <code>dist/mylib.js</code> file. So, if
+you are running these tests it is best to use the <code>rake test_functionals</code>
+as it pre-builds the distribution files first.</p>
+
+
<h2>Distribution of library</h2>
<p>Your project comes with the ability to concatenate all your <code>src/*.js</code>
files into a single file for distribution, as <code>dist/project_name.js</code>.</p>
@@ -379,9 +418,16 @@
<a href="drnicwilliams@gmail.com">Dr Nic Williams</a>, 17th February 2008<br>
Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
</p>
</div>
-<!-- insert site tracking codes here, like Google Urchin -->
-
+<script type="text/javascript">
+var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+</script>
+<script type="text/javascript">
+var pageTracker = _gat._getTracker("UA-567811-8");
+pageTracker._initData();
+pageTracker._trackPageview();
+</script>
</body>
</html>