开发者

RailsTutorial - Testing - What to put for Database.YML for MySQL?

First, thanks for your help.

As a noob, I've been happily chugging al开发者_如何学Pythonong this well-known tutorial:

http://ruby.railstutorial.org/chapters/static-pages#top

and I'm caught in a section where I enter

rspec spec/

where I receive 2 errors. The 2 errors are in the format of

  1. PagesController GET 'home' should be successful

    Failure/Error: Unable to find matching line from backtrace Mysql2::Error:Unknown database 'xyz.rb'

where "home" is the name of the action/page. The xyz.rb is the arbitrary database name I have listed under the test section in database.yml. I have already raked the database.

I'm pretty sure my problem has to do with how I'm not going with the sqlite3 in the tutorial but instead with mysql2. The resources I have managed to find only give guidance on what to input for the development section in database.yml, but not for the rest of the sections like "test". So, my question is, what exactly does this error mean, how to fix it, and how should I configure my database.yml file? I tried entering a file I see in my db folder like schema.rb, but this renders the same error.

Thank you very much for your help.


You have two options:

  1. Set up another sqlite database, as is default with a new rails application, or
  2. Create another MySQL database, the same way you set up your development database, with a different name (such as test) and use that for testing.

Here's my database.yml file from the Rails Tutorial that uses SQLite for all the databases; you should be able to copy the test section if you decide to go with #1 above.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜