[rspec-users] Mocking/Faking requests for js/ajax-based tests

Marcelo de Moraes Serpa celoserpa at gmail.com
Fri Jun 18 12:46:50 EDT 2010

Hello all,

I have an acceptance test that aims to bdd a Google Apps OpenID
authentication feature. This login screen also uses some JS (in order to
switch between the regular / Google OpenID forms). Now, I know this is not
something that would prevent me from using the :rack driver for Capybara,
but it made me think of the following problem: What to do when you have a
JS/Ajax-oriented page that makes web service calls and you need to write an
integration/acceptance test for it?

The fact that a scenario uses Javascript (Culerity/Selenium/Whatever) means
it will need to spawn a different process (Not sure about EnvJS, but I guess
it also needs a rails server running? ) for the rails app server. This
essentially prevents any mocking/stubbing/faking of requests. I wouldn't
want a bunch of acceptance tests that actually make requests to web
services, certainly a testing no-no.

What do you guys think could be done in these cases? I remember seeing
something a long time ago (a lib) that actually tried to solve the problem
of mocking while having the two processes open. Or maybe it's too much
troube to write integration tests for these kind of features?

FYI, I'm using rSpec, Steak and Capybara+Culerity.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100618/0954732c/attachment-0001.html>

More information about the rspec-users mailing list