Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
JavaScript BDD Rails Plugin (using Screw.Unit and env.js)
JavaScript Ruby
tree: c8d048af94

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
generators
lib
tasks
LICENSE
LICENSE-Screw.Unit
LICENSE-Smoke
README
TODO.taskpaper

README

JavaScript Testing
==================

This collection of files is useful for getting a Rails app up and running with headless Screw.Unit tests for your JavaScript files.  

More information at: http://blog.thinkrelevance.com/2008/7/31/fully-headless-jsspec

To install:

  rails_project> ./script/plugin install git://github.com/relevance/javascript_testing.git
  rails_project> ./script/generate javascript_testing
  
  
... example of creating just one spec ...  

Example
=======

We don’t actually encourage you to write specs and tests for standard libraries like Prototype, JQuery, etc. It just makes for an easy demo.

In test/javascript/fixtures/selector.html

  <html>
  <body>
    <div class="select_me"/>
    <span class="select_me"/>
    <div class="dont_select_me"/>
  </body>
  </html>
  
In test/javascript/selector_spec.js

  require("spec_helper.js");
  require("../../public/javascripts/prototype.js");

  Screw.Unit(function() {
    describe("Prototype's $$ selector", function() {
      it("should find only elements with the provided class selector", function() {  
         expect($$('.select_me').length).to(equal, 2);
      });

      it("should find only elements with the provided tag", function() {
        expect($$('div').length).to(equal,2);
      });
    });
  });

  
Now run the individual spec:

  rake test:javascripts TEST=selector_spec.js
  
Or run all of the specs:

  rake test:javascripts
  
  
... API: require, etc ...  

Copyright (c) 2008-9 Relevance, Inc., released under the MIT license
  env.js - Copyright 2007-9 John Resig, under the MIT License
  Screw.Unit - Copyright 2008 Nick Kallen, license attached
  Rhino - Copyright 2009 Mozilla Foundation, GPL 2.0
  Smoke - Copyright 2008 Andy Kent, license attached

Contributors
===================
* Justin Gehtland
* Geof Dagley
* Larry Karnowski
* Raimonds Simanovskis
* Jason Rudolph
* Chris Thatcher (for numerous env.js bug fixes!)
Something went wrong with that request. Please try again.