github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

osteele / javascript_fu

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 10
    • 0
  • Source
  • Commits
  • Network (0)
  • Issues (0)
  • Downloads (0)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

A Rails plugin to add more support for javascript files. — Read more

  cancel

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

README -> README.rdoc 
osteele (author)
Sun Mar 22 19:46:40 -0700 2009
commit  e7e19b19cf24e1abd5b0f45cd7c6fbd7b59b952c
tree    463bc8cbc43e1f5565f433887b0fc49893f2a2e9
parent  0c05de37efcd5b07328554a756863e25ad4e6117
javascript_fu /
name age
history
message
file .gitignore Loading commit data...
file MIT-LICENSE
file README.rdoc
file Rakefile
file TODO
file init.rb
directory lib/
directory spec/
directory tasks/
README.rdoc

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

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

If the "JCON" gem is installed, you can use this to test arguments values against ECMAScript 4.0 types:

  '<script>fn("id", {x:1, y:2}, true)</script>'.should call_js('fn') do |args|
    args[0].should conform_to_js('string')
    args[1].should conform_to_js('{x:int, y:int}')
    args[2].should conform_to_js('boolean')
    # or:
    args.should conform_to_js('[string, {x:int, y:int}, boolean]')
  end

License

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

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server