On Dec 24, 2005, at 11:30, Dick Davies wrote:
> On 23/12/05, Xavier Noria
<fxn-xlncskNFVEJBDgjK7y7TUQ@public.gmane.org> wrote:
>> I left ":memory:" in database.yml for testing and the most
simple
>> tests in the Agile book do not work (see trace below for test_truth).
>> Since that''s what comes with the distributed database.yml I
suppose
>> it''s me doing something wrong.
>
> Lazy guess, but have you tried toggling the
>
> self.use_transactional_fixtures
>
> setting in
>
> test/test_helper.rb
>
> ?
If we set that to false (so actual insertions and deletions are
done), the test tries to delete the products table and fails there,
which seems to suggest that the schema was not created. See output
below.
The piece I think I am missing is how to create the schema in that
database. In files one does it explicitly, but since that database is
created by the testing framework in memory I don''t now how it figures
the schema out (I would expect it to run the equivalent of "rake
clone_structure_to_test" behind the scenes), or whether some hook is
provided I don''t know about.
If I was right, do you know by any chance what should I do? This in-
memory database for testing looks really handy.
-- fxn
% ruby test/unit/product_test.rb
Loaded suite test/unit/product_test
Started
EE
Finished in 0.079896 seconds.
1) Error:
test_read_with_fixture_variable_as_instance(ProductTest):
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table:
products: DELETE FROM products WHERE 1=1
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/connection_adapters/abstract_adapter.rb:88:in `log''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/connection_adapters/sqlite_adapter.rb:133:in `execute''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/connection_adapters/sqlite_adapter.rb:143:in `delete''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/fixtures.rb:279:in `delete_existing_fixtures''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/fixtures.rb:252:in `create_fixtures''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/fixtures.rb:252:in `create_fixtures''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/connection_adapters/abstract/database_statements.rb:
51:in `transaction''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/fixtures.rb:251:in `create_fixtures''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/base.rb:831:in `silence''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/fixtures.rb:244:in `create_fixtures''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/fixtures.rb:540:in `load_fixtures''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/fixtures.rb:496:in `setup_with_fixtures''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/fixtures.rb:522:in `setup''
2) Error:
test_read_with_hash(ProductTest):
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table:
products: DELETE FROM products WHERE 1=1
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/connection_adapters/abstract_adapter.rb:88:in `log''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/connection_adapters/sqlite_adapter.rb:133:in `execute''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/connection_adapters/sqlite_adapter.rb:143:in `delete''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/fixtures.rb:279:in `delete_existing_fixtures''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/fixtures.rb:252:in `create_fixtures''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/fixtures.rb:252:in `create_fixtures''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/connection_adapters/abstract/database_statements.rb:
51:in `transaction''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/fixtures.rb:251:in `create_fixtures''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/base.rb:831:in `silence''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/fixtures.rb:244:in `create_fixtures''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/fixtures.rb:540:in `load_fixtures''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/fixtures.rb:496:in `setup_with_fixtures''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/
active_record/fixtures.rb:522:in `setup''
2 tests, 0 assertions, 0 failures, 2 errors