From c6aef7ea1299273038a033ed96adc6dd8237d329 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Sun, 3 Jun 2012 22:37:56 -0700 Subject: [PATCH] Update testing instructions --- README.md | 41 ++++++++++++++++++++++++------------ TESTING.md | 62 ------------------------------------------------------ 2 files changed, 28 insertions(+), 75 deletions(-) delete mode 100644 TESTING.md diff --git a/README.md b/README.md index a04f66722..20e2f77da 100644 --- a/README.md +++ b/README.md @@ -357,21 +357,9 @@ text and are awkward to use for markup." Custom delimiters may not contain whitespace or the equals sign. -## Streaming - -To stream template results out of mustache.js, you can pass an optional callback -to the call to `Mustache.render`: - - Mustache.render(template, view, partials, function (chunk) { - print(chunk); - }); - -When the template is finished rendering, the callback will be called with `null` -after which it won't be called anymore for that rendering. - ## Plugins for JavaScript Libraries -By default mustache.js may be used in a browser or any [CommonJS](http://www.commonjs.org/) +By default mustache.js may be used in any browser or [CommonJS](http://www.commonjs.org/) environment, including [node](http://nodejs.org/). Additionally, mustache.js may be built specifically for several different client libraries and platforms, including the following: @@ -393,6 +381,33 @@ following commands: $ rake requirejs $ rake qooxdoo +## Testing + +The mustache.js test suite uses the [vows](http://vowsjs.org/) testing +framework. In order to run the tests you'll need to install [node](http://nodejs.org/) +first. Once it's installed, you can install vows using [npm](http://npmjs.org/). + + $ npm install -g vows + +Then, run the tests. + + $ vows test/*_test.js + +The test suite consists of both unit and integration tests. If a template isn't +rendering correctly for you, you can make a test for it by doing the following: + + 1. Create a template file named `mytest.mustache` in the `test/_files` + directory. Replace `mytest` with the name of your test. + 2. Create a corresponding view file named `mytest.js` in the same directory. + This file should contain a JavaScript object literal enclosed in + parentheses. See any of the other view files for an example. + 3. Create a file with the expected output in `mytest.txt` in the same + directory. + +Then, you can run the test with: + + $ TEST=mytest vows test/render_test.js + ## Thanks Mustache.js wouldn't kick ass if it weren't for these fine souls: diff --git a/TESTING.md b/TESTING.md deleted file mode 100644 index 47d15e42d..000000000 --- a/TESTING.md +++ /dev/null @@ -1,62 +0,0 @@ -## Running the mustache.js test suite - -The mustache.js test suite uses the [RSpec](http://rspec.info/) testing -framework. In order to run the tests you'll need to install [Ruby](http://ruby-lang.org/) -as well as the `rake`, `rspec` (>=2), and `json` [RubyGems](http://rubygems.org/). - -### How to install Ruby and the required gems from source - -Make sure you have the required tools to compile it: - - $ apt-get install build-essential libssl-dev libreadline5-dev zlib1g-dev - -Download and extract the Ruby source, and install it: - - $ wget ftp://ftp.ruby-lang.org/pub/ruby/stable-snapshot.tar.gz - $ tar xvzf stable-snapshot.tar.gz - $ cd ruby - $ ./configure && make && make install - -Download and extract RubyGems, and install it: - - $ wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.12.tgz - $ tar xzvf rubygems-1.8.12.tgz - $ cd rubygems-1.8.12 - $ ruby setup.rb - -If you want to update RubyGems: - - $ gem update --system - -Install the required gems: - - $ gem install rake rspec json - -That's it! - -### How to run the tests - -The mustache.js test suite currently uses 4 different JavaScript runtime engines -to maximize portability across platforms and browsers. They are: - - * node - * SpiderMonkey (Mozilla, Firefox) - * JavaScriptCore (WebKit, Safari) - * Rhino (Mozilla, Java) - -When the test suite runs it will automatically determine which platforms are -available on your machine and run on all of them. The suite must run on at least -one platform in order to succeed. - -Once you have at least one JavaScript platform installed, you can run the test -suite with the following command: - - $ rake - -### How to create a test - -All test files live in the spec/_files directory. To create a new test: - - * Create a template file called `somename.mustache` - * Create a JavaScript file containing the view called `somename.js` - * Create a text file with the expected result called `somename.txt`