Ruby 覚書 StandardError: No fixture with name 'first' found for table 'XXXX'
移転しました。
RubyのUnitテスト実行時に本エラーが発生した。
test/fixture/xxxx.yml で指定する定義に'first'が無いというエラー。
自分は、xxxx.ymlに
-
-
- -
-
one:
:
:
two:
:
:
-
-
-
- -
-
-
のような記載をしていたため、firstが無いとエラーがでてしまった。
このため
-
-
-
- -
-
-
first:
:
:
second:
:
:
-
-
-
- -
-
-
としたところエラーがなくなった
タスク確認
rakeコマンド実行時に
Don't know how to build task 'test:functional'
のようなエラーがでた場合はタスクを確認する
# rake --task
(in /home/matsukaze/tutorial/recipe)
rake db:fixtures:load # Load fixtures into the current environment's database. Load specific fixtures using FIXTURES=x,y
rake db:migrate # Migrate the database through scripts in db/migrate. Target specific version with VERSION=x
MySQL/Rubyインストール時の問題
# gem install mysql Select which gem to install for your platform (i386-linux) 1. mysql 2.7.3 (mswin32) 2. mysql 2.7.1 (mswin32) 3. mysql 2.7 (ruby) 4. mysql 2.6 (ruby) 5. Skip this gem 6. Cancel installation > 3 ruby extconf.rb install mysql checking for mysql_query() in -lmysqlclient... no checking for main() in -lm... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lz... yes checking for mysql_query() in -lmysqlclient... no checking for main() in -lsocket... no checking for mysql_query() in -lmysqlclient... no checking for main() in -lnsl... yes checking for mysql_query() in -lmysqlclient... no *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.
のようなエラー発生時は
# gem install mysql -- --with-mysql-config=/usr/bin/mysql_config
のように--with-mysql-configを指定すること!