[Rails] Re: Testing Inconsistencies - ruby works rake fails
Greg Hansen
grhansen at gmail.com
Tue Aug 8 21:33:08 GMT 2006
I've just identified another interesting piece to the puzzle. I cleared
the test folder of all files and added them back in one by one based on
the database they were using. When I added the tests for my rails app
classes, they all succeeded. But when I added in a class, that uses one
of my legacy databases, the rails app tests would still succeed as long
as the secondary database test name came after the test name of default
database test. So primary_db_test.rb would succeed as long as the
filename for the test of the secondary database name came alphabetically
after the letter p(rimary_db_test.rb). As soon as I put a secondary db
test that was alphabetically listed in front of a primary db test, rake
can't find the primary database.
It's like once rake uses the secondary database it is stuck connected to
it, and can't find the tables for the primary database tables anymore.
Does it look like I've stumbled onto a bug or is there something I have
to do to release database connections in my test? I'm having to
manually create my fixtures to my secondary databases using
Fixture.create( path, file, table-name ) { Connection }. And I'm doing
a teardown in those classes to remove all data when executing for the
tests completes.
Greg
Greg Hansen wrote:
> I'm getting some very weird results when testing my system. If I run my
> unit tests using => ruby \test\unit\<filename.rb> each of the tests
> pass. If I run => rake test_units I get several failures, and they all
> have to deal with the same issue. For instance I'm getting =>
> ActiveRecord::StatementInvalid: RuntimeError: ERROR C42P01
> Mrelation "customers" does not exist Fnamespace.c L200
> RRangeVarGetRelid: DELETE FROM customers
>
> Obviously I've checked and the customers table exists, and as I
> mentioned above, when I run => ruby test\unit\customer_test.rb all tests
> succeed. So I'm guessing there is something wrong with the way rake is
> loading up the tests and maybe not executing them correctly.
>
> I am connecting to multiple databases in my application. I've created a
> new database for my customers, licenses and products and am accessing
> some legacy databases for some historical data. I'm doing joins b/n the
> databases fine in some other tests and those are succeeding when using
> rake, it's only the tests that run against my default test database
> which I setup specifically for the rails application.
>
> For my fixtures, I am using the standard => fixtures :customers to
> manage the data loading and cleansing between runs.
>
> Any help would be appreciated.
>
> Thanks.
> Greg
--
Posted via http://www.ruby-forum.com/.
More information about the Rails
mailing list