On Nov 4, 2013, at 12:23 AM, shaik s. <lists / ruby-forum.com> wrote:

> Hi,
>=20
> I'm using Cucumber+Watir for a POC. I want to use testdata from
> fixtures. How can I call the data available in fixtures(.yml file) in
> any .rb file?

This actually turns out to be more complicated than you might imagine. I =
was chatting up someone at RailsConf about this, as it was what we =
wanted to be able to do for our UAT regression tests (except we wanted =
to use factories instead of fixtures =97 same issue applies).

If you=92re driving your tests via Watir, you do need a way to get =
replicatable test data into the database to run tests consistently. You =
can=92t, however, rely on the usual suspects, and you can=92t really =
rely on a given test target=92s database being so clean. Even if you =
gave the target an initial clean target, with fixtures or factories =
seeded, it=92s difficult to maintain that without some better remote =
control of the test target.

Our thought was to come up with a Rails Engine you could slot into the =
test target=92s stack, that you could give it commands to load and clean =
a database set for that particular test target.

Sadly, when I came back from RailsConf, management wouldn=92t let us =
build such a thing.

Short of having an engine, a pair of rake tasks on the target machine to =
set up and tear down a database for your Watir testing could work. If =
you=92re running Watir on the same machine as the Rails app, this =
wouldn=92t be too difficult. If they=92re on separate machines, you=92d =
need remote access.