Rails 2.x testing (needs authentication and coordination with other server)

Hello, all!

I’ve been a subscriber for a bit, but now I have a question for those
knowledgeable than I.

I’ve inherited a Rails 2.3.x app, and have had some issues
the right versions of rspec / rubygems / etc. to find compatible
but I pretty much have discovered that I may need a modified approach to
testing other than the straightforward tutorials. The app came with no
working tests (although there are stubs for fixtures-based tests
from ActionController::TestCase). I’ve been playing with Rails
but this is my first “big” project. We’ll be doing significant mods
but I don’t want to do too much until we have a good testing strategy.
replaced a manual deploy with capistrano, etc. so we’re pretty ok for
mods but wholesale changes scare me without any tests.

The application doesn’t manage its own login – the accounts /
are stored on an external system. There is a fairly intimate
of data between the external system and the rails app: authentication
takes place remotely, but app permissions are stored on the rails side.
The app will modify data both on the Rails side and the external side,
some initial setup on the external site is needed before anything can
happen on Rails, and periodic tasks have to be performed on the external
server (manually) in order to simulate a true workflow. So, we can’t
really authenticate in a test, or do anything meaningful, without setup
both the external system and the rails system. This leads me to believe
that using the ‘test’ database, which is regenerated / rolled back
is a problem. I also can’t believe that I’m the only one who faces
like this in designing tests for a Rails application.

Additional complications include the following:
- Data must be uploaded to the rails side, processed, and then sent
over manually to the external server, and processed there with multiple
human interactions. Only after that happens can some of the tests be
performed on the rails side, and the tests change both rails data and
external data. If a test were to be performed after all that setup, and
the rails side of the database was to be “rolled back”, there would be
inconsistencies between the rails db and the external db which might
confound any future test results without cleaning everything up and
starting over again, something which would take between 10 and 50
to create (depending upon how much of a “clean slate” we want on both

  • We have dependencies upon the web server (webrick doesn’t work, and
    only older versions of passenger work). This is due to some nasty
    we do to send encoded ‘/’ characters via URL params, and we end up with
    double encodings with certain servers. If any of the test mechanisms
    have this issue with sending / retrieving / and generating links with
    ‘/’ encoded URL parameters, we’d again have confounding results. I’d
    to break this dependency, but again, it would be nice to have some tests

I’ve thought of possibly using an existing set of test data on the
side (with matched data on the Rails side), and running the tests with
data on the rails side until we’ve “used up” that data set (after
sets of operations on the rails side, the particular data item is no
modifiable in the same manner), but that doesn’t appear to be obvious
I’d do that with either unit tests / fixtures or rspec. Additionally,
uploading a file in a particular format is an integral step in many of
rails-side tests – integrating that into the testing framework would be
nice, but there’s probably a lot that could be done before we had to do

It almost seems that we need to have a GUI-based driver for the more
complicated things (such as uploading files / checking results). On the
other hand, the basic get requests do require a lot of setup (as I’ve
described above) that doesn’t seem obvious to me with the current test

Any suggestions for test infrastructure gems, tutorials, blog posts,
that might be of use would be appreciated. Right now, I’d rather get
tests working rather than try to bring this app up to 3.x in order to
in the fanciest new tools :wink:

If anyone has some ideas and needs more info, I’ll try to provide that
well, it seems like this post is long enough already!

Thanks and best wishes,

  • Rholmes