3

I'm wondering if this is possible. I use the VCR gem (http://rubygems.org/gems/vcr) for recording API calls within my models for my unit tests. This works fine. For more higher level testing I'm using Cucumber. In my app I also test stuff with google maps markers, geocoder etc. So I'm wondering if there is a solution for providing something like VCR for the client side.

Maybe someone got some ideas,

thx, tux

[EDIT] I forgot to mention that I use Selenium for javascript tests inside cucumber. So JavaScript calls should also be mocked.

23tux
  • 14,104
  • 15
  • 88
  • 187
  • What do you mean by "I'm wondering if there is a solution for providing something like VCR for the client side"? – Myron Marston May 25 '11 at 06:11
  • VCR records network traffic from your tests, and playback this records each time you run the tests. So, an API call is performed one time (at the first run of a test) and VCR playbacks this call to your tests the other times. But this only works for unit tests, when the network call comes from the testing framework itself. But if you are using Selenium with firefox, a network call like google maps comes from firefox, and not from the testing framework. Do you get me? ;) (I know, little bit complicated) – 23tux Aug 23 '11 at 14:26
  • I'm currently working on this problem with a VCR proxy, if anyone interested, any help is appreciated (see http://stackoverflow.com/questions/13039251/record-phantomjs-ajax-calls-with-vcr-inside-capybara) – 23tux Nov 21 '12 at 10:15

1 Answers1

0

Can't you set a different configuration for your tests? Something like: var gmaps_url = test ? "http://localhost:1234" : "http://maps.google.com";

Another idea could be using backbone-js (http://documentcloud.github.com/backbone/) on your javascript code. It makes it easier to unit test your javascript code.

Guilherme Garnier
  • 2,208
  • 23
  • 22