Forum: Ruby on Rails [ANN] Blue Ridge 1.0: JavaScript Unit Testing for Rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jason Rudolph (Guest)
on 2009-05-13 18:09
(Received via mailing list)
Blue Ridge 1.0 has been released!

#### Blue Ridge
  by Relevance, http://thinkrelevance.com

Blue Ridge is a JavaScript testing plugin for Rails.  It provides
support for both command-line and in-browser JavaScript unit tests,
and it brings the goodness of test-driven and behavior-driven
development to your unobtrusive JavaScript code in a Rails-friendly
manner.

http://github.com/relevance/blue-ridge

#### DESCRIPTION

You wouldn’t consider developing a Rails application without having a
solid test suite for your Ruby code, but you’ve somehow convinced
yourself to cross your fingers and look the other way when it comes to
JavaScript. It doesn’t have to be that way.

Historically, when selecting a JavaScript testing solution, you were
forced to choose whether you wanted a framework that could run your
tests in the browser or one that could only run your tests in a
headless fashion.  By providing a friendly convention-over-
configuration wrapper around a collection of great open source tools,
Blue Ridge gives us the best of both worlds: fast, automation-
friendly, and headless testing plus the ability to run your tests in
whichever browser is acting up on any given day.

#### FEATURES

* BDD-style specs for your JavaScript code
* jQuery and Prototype support
* Headless execution of JavaScript specs for easy command-line
execution and integration with your Continuous Integration build
* In-browser execution of JavaScript specs for testing and debugging
browser-specific quirks
* Mocking support via Smoke
* TextMate integration for running specs from inside TextMate
* irb-like JavaScript shell for experimentation and debugging

#### QUICK START

Install Blue Ridge into your Rails app:

    ./script/plugin install git://github.com/relevance/blue-ridge.git
    ./script/generate blue_ridge

Blue Ridge creates a small example spec to get you started.  Run your
JavaScript specs to make sure that all is well.

    rake test:javascripts

Hint: You can also use the "spec:javascripts" or
"examples:javascripts" aliases.  Blue Ridge is compatible with your
testing framework of choice, be it test/unit, RSpec, Micronaut,
Shoulda, test-spec, etc.

#### EXAMPLE SPEC

Installing the plugin creates an example spec ("application_spec.js"),
demonstrating some basic tests to help you get a feel for the
structure of the tests.

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

    Screw.Unit(function() {
      describe("Your application javascript", function() {
        it("provides cliché example", function() {
          expect("hello").to(equal, "hello");
        });

        it("accesses the DOM from fixtures/application.html", function
() {
          expect($('.select_me').length).to(equal, 2);
        });
      });
    });

This particular spec uses jQuery, but you can optionally configure
your spec to use Prototype.

And, no, we don’t actually encourage you to write tests for standard
libraries like jQuery and Prototype; it just happens to make for an
easy demo.

#### ADDITIONAL RESOURCES

Check out the README [1] for detailed information on each of the
features described above and for tips and tricks for getting the most
out of Blue Ridge.

Explore the sample app [2] to see more specs and testing techniques in
action.

Use the project’s GitHub issue tracker [3] to let us know about any
issues or ideas for possible improvements. Even better, fork the repo
[1] and start hacking!  If you have patches, send us pull requests.

--

[1] Detailed README - http://github.com/relevance/blue-ridge
[2] Sample Application -
http://github.com/relevance/blue-ridge-sample-app
[3] Issues - http://github.com/relevance/blue-ridge/issues

--

Cheers,
Jason

--

Jason Rudolph
http://thinkrelevance.com
http://jasonrudolph.com
This topic is locked and can not be replied to.