Mailinglist Archive: opensuse-ruby (2 mails)

< Previous Next >
Re: [opensuse-ruby] active_resource_test_helper
  • From: Josef Reidinger <jreidinger@xxxxxxx>
  • Date: Wed, 19 May 2010 08:11:59 +0200
  • Message-id: <201005190811.59862.jreidinger@xxxxxxx>
Flavio Castelli write:
Sometimes ago I tried to figure out how to tests ActiveResouce. Unfortunately
there are two possible choices around: use mocha or use the
ActiveResource::HttpMock.responds_to method.

Stubbing ActiveResource objects/calls with mocha is really annoying and
produces ugly and unmaintainable code (especially when you have big/complex

Using ActiveResource::HttpMock is slightly better, but unfortunately you have
to write manually all the request/response pairs that are going to be used by
your test. You have also to write all the objects that are going to be
transformed into ActiveResource instances by HttpMock. This really annoying
and there's no way to avoid that (you cannot for example use fixtures).

Hi, we use "fixtures" in webyast for httpmock. We just save example xml
response from server and use it as input for http mock. Also we have own
extension of httpmock which mock authentification header (quite annoying),
introspection on our backend and permission setup on backend. Maybe you find
something useful in our testsuite (especially how we test that request is
really sent correct) -
example test:
our extension:


Hence I decided to create the active_resource_test_helper. Below you can find
an explanation about how it works and how it can be used.

You can find the code on github:

You can install the gem from gemcutter or using the package from
devel:languages:ruby:extensions (it's called rubygem-
active_resource_test_helper and I've just submitted it).

Feedback is really appreciated.

Happy hacking

Josef Reidinger
YaST team
maintainer of perl-Bootloader, YaST2-Repair, parts of webyast
To unsubscribe, e-mail: opensuse-ruby+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-ruby+help@xxxxxxxxxxxx

< Previous Next >
List Navigation