Using a constant in both unit tests and in fixtures

I create a number of users in a database through a fixture. I then run
a
unit test to verify that the number of users in the database is correct.
I
want to make this number a constant that is only defined in one place.
I
currently have it defined in ./test/test_helper.rb which works fine for
the
unit test, but the fixture cannot see it. I’ve tried to "require
‘…/test_helper.rb’ " from inside the fixture to no avail.

Any ideas?

On 9/26/07, Ryan A. [email protected] wrote:

I create a number of users in a database through a fixture. I then run a
unit test to verify that the number of users in the database is correct. I
want to make this number a constant that is only defined in one place. I
currently have it defined in ./test/test_helper.rb which works fine for the
unit test, but the fixture cannot see it. I’ve tried to "require
‘…/test_helper.rb’ " from inside the fixture to no avail.

You can put it in a file in lib/ and then require that file from both
your test and your fixture file.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs