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.
Specifying the required behaviour consists of 2 parts:
- running the web application using your favourite staging environment
- driving the web application using jRuby, cucumber, celerity, rspec, and friends
Quickstart: read feature files and step definitions in features/
Celerity requires jRuby. Celerity, cucumber, rspec, and other gems used for specifying the required behaviour are installed in the jRuby environment.
- 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
- ruby start.rb
- browse to localhost:7000
You should see “Welcome” and a list of example web pages.
Verify jRuby, cucumber, rspec are installed correctly by
- 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
Links to Celerity documentation
Documentation on Github
Documentation on rubyforge
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
Automatically executing the AJAX response
A jQuery AJAX request like
is now automatically executed with celerity 0.0.6.
Using Celerity from jirb
You can explore celerity by using jirb as follows
> require ‘rubygems’
> require ‘celerity’
> browser = Celerity::Browser.new
Yutaka HARA – Updated the examples to use Ramaze (2009.07)