Capybara is the latest testing library that is more robust than webrat. Capybara helps you test your web applications like how a real user would interact with your system.
With capybara we can turn the :js => true option on the test case like:
[ruby] it “should see payment error if payment amount is smaller than product price�?, :js = true do
fill_in “payment_card_number�?, :with => “1234567891234567�?
fill_in “payment_card_name�?, :with => “validname�?
page.should have_content(“There was a problem saving your order�?)
Here a user logs in then clicks on a product (let’s say in an ordering application). He/she fills in the payment details and we have an ajax call which returns a partial. This can be well tested with the option above.