简体   繁体   中英

Name of test db/tables in rails?

I am trying to learn rails following SAAS course in coursera.

I ran

rake db:migrate
db:test:prepare  

to create a test db and run some cucumber steps against it.

I need a way to insert some movies in the corresponding movie table in test .

I can see a scehma.rb in db folder, and also in models, there is just Movie table created by class Movie < ActiveRecord::Base , but nothing such created for test dbs ?

Where can I find the testDB creation files , how do I find all the table names in my DB . I dont even know the db name to run :

 SELECT * FROM dbname.sqlite_master WHERE type='table';

Also if there are some better/easier ways of doing this please share your experience. I expect the suggestions to be something that I can try in 5 mins and not spend debugging time to install a new gem etc, although you can mention them as an additional comment.

Thanks

Db data (name and configure) for all environment (test, dev, prod) defines in config -> database.yml file. Like this:

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM