Jeff C. wrote:
On Oct 12, 1:28 pm, Elliot T. [email protected]id
when you try to use a fixture. Not fun to track down. i got sentry’s
tests to run by adding:
Fixtures are for loading test data into your test database. The code
here is doing a basic sanity check: first, that ActiveRecord is
defined in your project (should be) and that the database
configurations have been loaded (from database.yml).
I understand having a sanity check, but I don’t understand failing
quietly, so you get an error later and elsewhere b/c a variable wasn’t
initialized b/c the setup just returned.
You’ve put something in there to make the sanity check “think” you’ve
configured the database, but you really haven’t.
Sounds like your plugin is being loaded before the Rails has had a
chance to initialize - that’s the real problem here.
The thing is: it works when I trick it. It is loading active record and
connecting to the database, and the fixtures are loading data into the
database and the tests pass – all with the configurations blank. Here’s
some relevant code. Maybe the establish_connection call is improper?
cause it’s using the db config but without activerecord getting fully
config_location = File.dirname(FILE) + ‘/database.yml’
config = YAML::load(IO.read(config_location))
ActiveRecord::Base.establish_connection(config[ENV[‘DB’] || ‘mysql’])