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

alvinschur / celerity-examples

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 49
    • 1
  • Source
  • Commits
  • Network (1)
  • Issues (0)
  • Downloads (0)
  • Wiki (2)
  • 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.

Examples using celerity, cucumber, and rspec to verify web application behaviour, including javascript and AJAX. — Read more

  cancel

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

This URL has Read+Write access

Updated an example that automatically executes AJAX scripts 
Alvin Schur (author)
Sat Aug 08 14:51:48 -0700 2009
commit  5b1b98c296998d63b9c0f2a62f022875f63f05d1
tree    fc1a313b225b76e0952aab290da5672434d36eb4
parent  3139e2c3af1024cbd77f0fd9804526ca276ba69e
celerity-examples /
name age
history
message
file README.textile Sat Aug 08 14:53:06 -0700 2009 Updated an example that automatically executes ... [Alvin Schur]
file Rakefile Sun Nov 16 15:19:11 -0800 2008 feature to verify cucumber and celerity are ins... [alvinschur]
directory controller/ Fri Jul 31 00:33:51 -0700 2009 Moved page.xhtml to layout/ [yhara]
directory features/ Sat Aug 08 14:53:06 -0700 2009 Updated an example that automatically executes ... [Alvin Schur]
directory layout/ Fri Jul 31 00:33:51 -0700 2009 Moved page.xhtml to layout/ [yhara]
directory public/ Sun Nov 16 15:12:39 -0800 2008 Initial import [alvinschur]
directory spec/ Sun Nov 16 15:12:39 -0800 2008 Initial import [alvinschur]
file start.rb Fri Jul 31 00:30:14 -0700 2009 Ramaze's String#/ is deprecated [yhara]
directory view/ Fri Jul 31 00:33:51 -0700 2009 Moved page.xhtml to layout/ [yhara]
README.textile

Introduction

This project provides examples of testing web applications that use javascript and AJAX. The main tools are Cucumber to describe the required behaviour and Celerity for simulating a web browser and executing the javascript.

Thanks to Ashley Moran for the introduction to using cucumber, celerity, and rspec at: geekup-sheffield

The examples were developed with Celerity version 0.0.6.

Note:

  • Webrat is another excellent tool that can be used with Cucumber.
  • jQuery is used in the javascript

Specifying the required behaviour consists of 2 parts:

  1. running the web application using your favourite staging environment
  2. driving the web application using jRuby, cucumber, celerity, rspec, and friends

Quickstart: read feature files and step definitions in features/

Getting started

Celerity requires jRuby. Celerity, cucumber, rspec, and other gems used for specifying the required behaviour are installed in the jRuby environment.

Install

  • Ramaze (2009.07) Easy web app framework
  • jRuby (1.3.1)
  • Celerity (0.0.6)
  • Cucumber (0.3.94)
  • Rspec (1.2.8)
  • hpricot (0.6.164) jRuby instructions

Verify the web application is installed correctly by

  1. ruby start.rb
  2. browse to localhost:7000
    You should see “Welcome” and a list of example web pages.

Verify jRuby, cucumber, rspec are installed correctly by

  1. jrake cucumber

You should see output similar to

  Feature: Verify Cucumber, celerity, rspec are installed  # features/verify_cucumber_installation.feature
    In order verify web application behaviour
    the development team should be able to 
    run cucumber and celerity
    Scenario: visit the web application home page  # features/verify_cucumber_installation.feature:6
      When I visit the home page                   # features/step_definitions/first_steps.rb:19
      Then I should see "Welcome"                  # features/step_definitions/first_steps.rb:35


  2 steps passed

Tips

Links to Celerity documentation

Documentation on Github

  • Ajax docs
  • FAQ

Documentation on rubyforge

  • How to select elements
  • FAQ
  • Tutorial
  • API docs

Wait for AJAX to finish

AJAX calls are executed asynchronously, which means we have to tell celerity to wait for the AJAX call to finish before trying to verify the results.

One option is to create a browser instance that automatically waits for AJAX calls to finish.

	@browser = Celerity::Browser.new(:resynchronize => true)

Or you can explicitly wait for AJAX calls.

	When "I wait for the AJAX call to finish" do
 		@browser.wait
	end

Which came from the Celerity Ajax docs
and HtmlUnit FAQ

Automatically executing the AJAX response

A jQuery AJAX request like

	$.get('http://localhost:7000/ajax_responses/returning_javascript', null, null, 'script');

is now automatically executed with celerity 0.0.6.

Using Celerity from jirb

You can explore celerity by using jirb as follows


> jirb
> require ‘rubygems’
> require ‘celerity’
> browser = Celerity::Browser.new
> browser.goto(‘http://localhost:7000/on_page_load’)
> browser.html

Credits

Yutaka HARA – Updated the examples to use Ramaze (2009.07)

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