Mailinglist Archive: opensuse-ruby (2 mails)

< Previous Next >
[opensuse-ruby] active_resource_test_helper
  • From: Flavio Castelli <fcastelli@xxxxxxxxxx>
  • Date: Tue, 18 May 2010 18:43:03 +0200
  • Message-id: <201005181843.03570.fcastelli@xxxxxxxxxx>
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
objects).

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).

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:
http://github.com/flavio/active_resource_test_helper

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
Flavio
--
To unsubscribe, e-mail: opensuse-ruby+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-ruby+help@xxxxxxxxxxxx

< Previous Next >
List Navigation
Follow Ups