Plugins - JavaScript Fu

StarAdd to favorites

JavaScript Fu Rails Plugin

This plugin adds helpers, rake tasks, and rspec matchers for JavaScript development.

Installation

  git clone git://github.com/osteele/javascript_fu.git vendor/plugins/javascript_fu --depth 1

Extended Rake Tasks

The existing notes and statistics tasks are extended to compass the public/javascript directory:

  rake statistics
  rake notes

New View Helper

The new onload generator method generates code that executes the content of the block upon the completion of page load.

  page.onload do
    page.call alert', 'page loaded!'
  end

generates

  Event.observe("window", "load", function() { alert("page loaded!"); });

or

  $(document).ready(function() { alert("page loaded!"); });

New RSpec Matcher

Use these in your specs to verify that a view is calling a JavaScript function:

  response.should call_js('fn')
  response.should call_js('fn(true)')
  response.should call_js('gApp.setup')

If there is a body, the arguments to the call are parsed (as JSON) and passed to it:

  # response includes <script>...fn('string', 2)...</script>
  response.should call_js(fn') do |args|
    args.should == ['string', 2]
  end

License

Copyright 2008 by Oliver Steele. All rights reserved. Released under the MIT License.

Oliver Steele

http://osteele.com/archives/2008/04/javascript-fu-rails-plugin

git://github.com/osteele/javascript_fu.git

Rails' (MIT)

  • Currently 0.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

View Extensions

Tags

Comments

Add a comment

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?