How to use ruby-on-rails fixtures for setting up (external) data that does not belong to the rails app DB? -
per requirements, have created models querying external database (different 1 rails app uses) of data.
i trying write tests around these models , want separate "sample test data" actual tests.
i thought put data in yml file , load hash, did work out :(
- added sample test data fixture file name 'external_database.yml'
- put below code in setup, in test file
ext_data = yaml.load_file(rails.root.to_s + "/test/fixtures/ext_data.yml")
- but stuck below error
1) error: test_should_errorout_for_invalid_market_zip(extdbtest): activerecord::statementinvalid: mysql::error: table 'rails_app_db.ext_data' doesn't exist: delete
ext_data
- what best way want done?
i guess problem schema of external database not contained in schema.rb-file and/or migrations. these used setup test-database before run tests.
so attempt made write fixtures non-existing tables - result see above.
multiple database-connections in unit tests pain. consider creating sqlite-file data of external dependencies , configure test-environment use file - or copy of it, in case need mutate data.
Comments
Post a Comment