rjs is testable using ActionController:TestCase

Create a simple test application; run the provided functional tests.

ruby -rubygems /home/rubys/git/rails/bin/rails new testapp
      create  
      create  README
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/controllers/application_controller.rb
      create  app/views/layouts/application.html.erb
      create  app/helpers/application_helper.rb
      create  app/models
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/environments
      create  config/environments/test.rb
      create  config/environments/production.rb
      create  config/environments/development.rb
      create  config/initializers
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/secret_token.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/inflections.rb
      create  config/initializers/session_store.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  doc
      create  doc/README_FOR_APP
      create  lib
      create  lib/tasks
      create  lib/tasks/.gitkeep
      create  log
      create  log/server.log
      create  log/production.log
      create  log/development.log
      create  log/test.log
      create  public
      create  public/422.html
      create  public/404.html
      create  public/robots.txt
      create  public/500.html
      create  public/index.html
      create  public/favicon.ico
      create  public/images
      create  public/images/rails.png
      create  public/stylesheets
      create  public/stylesheets/.gitkeep
      create  public/javascripts
      create  public/javascripts/controls.js
      create  public/javascripts/rails.js
      create  public/javascripts/application.js
      create  public/javascripts/prototype.js
      create  public/javascripts/effects.js
      create  public/javascripts/dragdrop.js
      create  script
      create  script/rails
      create  test
      create  test/performance/browsing_test.rb
      create  test/test_helper.rb
      create  test/unit
      create  test/fixtures
      create  test/functional
      create  test/integration
      create  tmp
      create  tmp/sessions
      create  tmp/sockets
      create  tmp/cache
      create  tmp/pids
      create  vendor/plugins
      create  vendor/plugins/.gitkeep
bundle install
Resolving dependencies
Installing rake (0.8.7) from system gems 
Installing rails (3.0.0.beta3) from source code at /home/rubys/git/rails 
Installing activeresource (3.0.0.beta3) from source code at /home/rubys/git/rails 
Installing activesupport (3.0.0.beta3) from source code at /home/rubys/git/rails 
Installing railties (3.0.0.beta3) from source code at /home/rubys/git/rails 
Installing activemodel (3.0.0.beta3) from source code at /home/rubys/git/rails 
Installing activerecord (3.0.0.beta3) from source code at /home/rubys/git/rails 
Installing actionpack (3.0.0.beta3) from source code at /home/rubys/git/rails 
Installing actionmailer (3.0.0.beta3) from source code at /home/rubys/git/rails 
Installing erubis (2.6.5) from system gems 
Installing bundler (0.9.24) from .gem files at /home/rubys/.rvm/gems/ruby-1.9.2-r26869/cache 
Installing sqlite3-ruby (1.2.5) from system gems 
Installing builder (2.1.2) from system gems 
Installing rack (1.1.0) from system gems 
Installing rack-mount (0.6.3) from .gem files at /home/rubys/.rvm/gems/ruby-1.9.2-r26869/cache 
Installing arel (0.3.3) from .gem files at /home/rubys/.rvm/gems/ruby-1.9.2-r26869/cache 
Installing i18n (0.4.1) from .gem files at /home/rubys/.rvm/gems/ruby-1.9.2-r26869/cache 
Installing rack-test (0.5.4) from .gem files at /home/rubys/.rvm/gems/ruby-1.9.2-r26869/cache 
Installing thor (0.13.6) from .gem files at /home/rubys/.rvm/gems/ruby-1.9.2-r26869/cache 
Installing abstract (1.0.0) from system gems 
Installing mail (2.2.1) from .gem files at /home/rubys/.rvm/gems/ruby-1.9.2-r26869/cache 
Installing mime-types (1.16) from system gems 
Installing treetop (1.4.8) from .gem files at /home/rubys/.rvm/gems/ruby-1.9.2-r26869/cache 
Installing polyglot (0.3.1) from .gem files at /home/rubys/.rvm/gems/ruby-1.9.2-r26869/cache 
Installing tzinfo (0.3.22) from .gem files at /home/rubys/.rvm/gems/ruby-1.9.2-r26869/cache 
Your bundle is complete!
rails generate scaffold product title:string
      invoke  active_record
      create    db/migrate/20100606174312_create_products.rb
      create    app/models/product.rb
      invoke    test_unit
      create      test/unit/product_test.rb
      create      test/fixtures/products.yml
       route  resources :products
      invoke  scaffold_controller
      create    app/controllers/products_controller.rb
      invoke    erb
      create      app/views/products
      create      app/views/products/index.html.erb
      create      app/views/products/edit.html.erb
      create      app/views/products/show.html.erb
      create      app/views/products/new.html.erb
      create      app/views/products/_form.html.erb
      invoke    test_unit
      create      test/functional/products_controller_test.rb
      invoke    helper
      create      app/helpers/products_helper.rb
      invoke      test_unit
      create        test/unit/helpers/products_helper_test.rb
      invoke  stylesheets
      create    public/stylesheets/scaffold.css
rake db:migrate
mv 20100606174312_create_products.rb 20100301000001_create_products.rb
(in /home/rubys/tmp/work/testapp)
==  CreateProducts: migrating =================================================
-- create_table(:products)
   -> 0.0025s
==  CreateProducts: migrated (0.0027s) ========================================
 
rake test:functionals
(in /home/rubys/tmp/work/testapp)
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.2-r26869@global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.......
Finished in 0.368446 seconds.
 
7 tests, 10 assertions, 0 failures, 0 errors, 0 skips

Create a test using XHR

edit test/functional/products_controller_test.rb
require 'test_helper'
 
class ProductsControllerTest < ActionController::TestCase
  setup do
    @product = products(:one)
  end
 
  test "should get index" do
    get :index
    assert_response :success
    assert_not_nil assigns(:products)
  end
 
  test "should get new" do
    get :new
    assert_response :success
  end
 
  test "should create product" do
    assert_difference('Product.count') do
      post :create, :product => @product.attributes
    end
 
    assert_redirected_to product_path(assigns(:product))
  end
 
  test "should show product" do
    get :show, :id => @product.to_param
    assert_response :success
  end
 
  test "should get edit" do
    get :edit, :id => @product.to_param
    assert_response :success
  end
 
  test "should update product" do
    put :update, :id => @product.to_param, :product => @product.attributes
    assert_redirected_to product_path(assigns(:product))
  end
 
  test "should destroy product" do
    assert_difference('Product.count', -1) do
      delete :destroy, :id => @product.to_param
    end
 
    assert_redirected_to products_path
  end
 
  test "should create line_item via XHR" do
    assert_difference('Product.count', +1) do
      xhr :post, :create, :product_title => 'Lorem Ipsum'
    end
  end
end

Rerun the tests

rake test:functionals
(in /home/rubys/tmp/work/testapp)
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.2-r26869@global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
........
Finished in 0.497975 seconds.
 
8 tests, 11 assertions, 0 failures, 0 errors, 0 skips

Add js to the response formats for create

edit app/controllers/products_controller.rb
class ProductsController < ApplicationController
  # GET /products
  # GET /products.xml
  def index
    @products = Product.all
 
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @products }
    end
  end
 
  # GET /products/1
  # GET /products/1.xml
  def show
    @product = Product.find(params[:id])
 
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @product }
    end
  end
 
  # GET /products/new
  # GET /products/new.xml
  def new
    @product = Product.new
 
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @product }
    end
  end
 
  # GET /products/1/edit
  def edit
    @product = Product.find(params[:id])
  end
 
  # POST /products
  # POST /products.xml
  def create
    @product = Product.new(params[:product])
 
    respond_to do |format|
      if @product.save
        format.html { redirect_to(@product, :notice => 'Product was successfully created.') }
        format.js
        format.xml  { render :xml => @product, :status => :created, :location => @product }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @product.errors, :status => :unprocessable_entity }
      end
    end
  end
 
  # PUT /products/1
  # PUT /products/1.xml
  def update
    @product = Product.find(params[:id])
 
    respond_to do |format|
      if @product.update_attributes(params[:product])
        format.html { redirect_to(@product, :notice => 'Product was successfully updated.') }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @product.errors, :status => :unprocessable_entity }
      end
    end
  end
 
  # DELETE /products/1
  # DELETE /products/1.xml
  def destroy
    @product = Product.find(params[:id])
    @product.destroy
 
    respond_to do |format|
      format.html { redirect_to(products_url) }
      format.xml  { head :ok }
    end
  end
end

Create an empty rjs file

edit app/views/products/create.js.rjs
# this space intentionally left blank

Rerun functional tests

rake test:functionals
(in /home/rubys/tmp/work/testapp)
Loaded suite /home/rubys/.rvm/gems/ruby-1.9.2-r26869@global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
........
Finished in 0.601208 seconds.
 
8 tests, 11 assertions, 0 failures, 0 errors, 0 skips

Environment

Sun, 06 Jun 2010 17:44:04 GMT
/home/rubys/.rvm/rubies/ruby-1.9.2-r26869/bin/ruby -v
ruby 1.9.2dev (2010-03-11 trunk 26869) [x86_64-linux]
gem -v
1.3.6
bundle show
Gems included by the bundle:
  * abstract (1.0.0)
  * actionmailer (3.0.0.beta3)
  * actionpack (3.0.0.beta3)
  * activemodel (3.0.0.beta3)
  * activerecord (3.0.0.beta3)
  * activeresource (3.0.0.beta3)
  * activesupport (3.0.0.beta3)
  * arel (0.3.3)
  * builder (2.1.2)
  * bundler (0.9.24)
  * erubis (2.6.5)
  * i18n (0.4.1)
  * mail (2.2.1)
  * mime-types (1.16)
  * polyglot (0.3.1)
  * rack (1.1.0)
  * rack-mount (0.6.3)
  * rack-test (0.5.4)
  * rails (3.0.0.beta3 509f3d)
  * railties (3.0.0.beta3)
  * rake (0.8.7)
  * sqlite3-ruby (1.2.5)
  * thor (0.13.6)
  * treetop (1.4.8)
  * tzinfo (0.3.22)
rake about
(in /home/rubys/tmp/work/testapp)
About your application's environment
Ruby version              1.9.2 (x86_64-linux)
RubyGems version          1.3.6
Rack version              1.1
Rails version             3.0.0.beta3
Active Record version     3.0.0.beta3
Action Pack version       3.0.0.beta3
Active Resource version   3.0.0.beta3
Action Mailer version     3.0.0.beta3
Active Support version    3.0.0.beta3
Application root          /home/rubys/tmp/work/testapp
Environment               development
git log -1
commit 509f3d7d2f346b83dfd22aec681feffbd2d25803
Author: Jeremy Kemper <jeremy@bitsweat.net>
Date:   Sat Jun 5 20:34:30 2010 -0700

    Simplify middleware stack lazy compares using named const references