github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

alexyoung / riotjs

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 36
    • 2
  • Source
  • Commits
  • Network (2)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (2)
    • gh-pages
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

JavaScript unit tests. — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Added "other engine" detection so I can get an exit code from v8 
Alex Young (author)
Fri Nov 13 07:37:46 -0800 2009
commit  efe43ed3001867f101ea4dae74e716be55f2720f
tree    e0cad212dafdd85351fa3bb0fe7c61f9201249c3
parent  4a98b0ca053e89f1038a1513e182fe917086c38d
riotjs /
name age
history
message
file .gitignore Sat Oct 17 08:20:12 -0700 2009 first commit [Alex Young]
file README.textile Thu Oct 22 13:10:55 -0700 2009 added xpcc note to the README [Alex Young]
file riot.js Fri Nov 13 07:37:46 -0800 2009 Added "other engine" detection so I can get an ... [Alex Young]
file riotjs.html Sat Oct 17 17:27:38 -0700 2009 Added assert... raises [Alex Young]
file test.js Sat Oct 24 06:23:18 -0700 2009 added isFalse [Alex Young]
README.textile

This is a JavaScript implementation of Riot.

It will run in a browser or in Rhino.

Example

Tests look like this:

Riot.run(function() {
  context('basic riot functionality', function() {
    given('some simple equality tests', function() {
      asserts('a simple truth test should return true', true).isTrue();
      asserts('isNull is null', null).isNull();
    });

    given('another context', function() {
      asserts('equals should compare strings as expected', 'test string').equals('test string');
    });

    given('a context concerned with functions', function() {
      asserts('asserts() should allow functions to be compared', function() {
        return 'test string';
      }).equals('test string');
    });
  });

  given('yet another context', function() {
    asserts('equals should compare strings as expected', 'test string').equals('test string');
  });
});

There are a few aliases to make tests (and output) read more naturally:

  • context: given — Given will add “Given…” to the title in the test output
  • asserts: should

Assertions

  • equals – for example, asserts('description').equals('value')
  • matches – matches a regex
  • typeOf – aliased to isTypeOf, kindOf
  • isNull
  • isTrue
  • raises

Riot.run

Riot.run(function() { // your tests }); just adds your tests to window.onload. If there’s already an onload handler it’ll prepend it. If there’s no window it will just run the tests.

It can also be called with no parameters to run tests defined with Riot.context. This can be used to create a set of files with tests inside a Riot.context for each file

Packaging

Packaged as a RubyGem usable via XPCOMCore-RubyGems — riotjs-xpcc.

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server