# \[ANN\] Blue Ridge 1.0: JavaScript Unit Testing for Rails

**URL:** <https://www.ruby-forum.com/t/ann-blue-ridge-1-0-javascript-unit-testing-for-rails/167880>\
**Category:** Rails\
**Created:** [May 13, 2009, 4:09pm UTC](https://www.ruby-forum.com/t/ann-blue-ridge-1-0-javascript-unit-testing-for-rails/167880 "2009-05-13T16:09:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Rudolph](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/fbc32d/32.png) [@Jason\_Rudolph](https://www.ruby-forum.com/u/Jason_Rudolph)\
**Post date:** [May 13, 2009, 4:09pm UTC](https://www.ruby-forum.com/t/ann-blue-ridge-1-0-javascript-unit-testing-for-rails/167880/1 "2009-05-13T16:09:53Z")

</div>

Blue Ridge 1.0 has been released!

#### Blue Ridge

by Relevance, [http://thinkrelevance.com](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.

> **[GitHub - relevance/blue-ridge: Framework for JavaScript Testing (currently a...](https://github.com/relevance/blue-ridge)**
>
> Framework for JavaScript Testing (currently a Rails Plugin) - GitHub - relevance/blue-ridge: Framework for JavaScript Testing (currently a Rails Plugin)

#### 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 - [GitHub - relevance/blue-ridge: Framework for JavaScript Testing (currently a Rails Plugin)](http://github.com/relevance/blue-ridge)  
[2] Sample Application -  
[GitHub - relevance/blue-ridge-sample-app: Sample Rails project demonstrating JavaScript testing with Blue-Ridge](http://github.com/relevance/blue-ridge-sample-app)  
[3] Issues - [Issues · relevance/blue-ridge · GitHub](http://github.com/relevance/blue-ridge/issues)

–

Cheers,  
Jason

–

Jason Rudolph

> **[Cognitect, a Nu Holdings, Ltd. Company](https://cognitect.com/)**

> **[jasonrudolph.com](https://jasonrudolph.com/)**
>
> Jason Rudolph - Programmer, consultant, speaker, and author specializing in Ruby and Rails
