Only in app2/Ins/test/fixtures: users.yml
Only in app2/Ins/test/functional: users_controller_test.rb
Only in app2/Ins/test/unit: helpers
Only in app2/Ins/test/unit: user_test.rb
Only in app2/Ins/test/functional: users_controller_test.rb
Only in app2/Ins/test/unit: helpers
Only in app2/Ins/test/unit: user_test.rb
今日はこのテストを勉強します。
users_controller_test.rbは「機能テスト」と言われるコードだそうです。
対して、user_test.rbは「単体テスト」と言われるコードだそうです。
まずはテストを実行します。
jruby test/functional/users_controller_test.rb
LoadError: no such file to load -- test_helper
require at org/jruby/RubyKernel.java:1019
require at /Applications/jruby-1.7.0/lib/ruby/shared/rubygems/custom_require.rb:36
(root) at test/functional/users_controller_test.rb:1
怒られる。。。調べてみると、-Itestパラメータをつけるらしい。
jruby -Itest test/functional/users_controller_test.rb
Run options:
# Running tests:
EEEEEEE
Finished tests in 0.243000s, 28.8066 tests/s, 0.0000 assertions/s.
1) Error:
test_should_create_user(UsersControllerTest):
ActiveRecord::StatementInvalid: ActiveRecord::JDBCError: query does not return ResultSet: PRAGMA table_info("users")
・・・・
一歩前進!しかしながら、テストがダメだって言われる。dbがないらしい。マイグレートしていないからか。
rake RAILS_ENV=test db:migrate
jruby -Itest test/functional/users_controller_test.rb
Run options:
# Running tests:
.......
Finished tests in 0.915000s, 7.6503 tests/s, 10.9290 assertions/s.
7 tests, 10 assertions, 0 failures, 0 errors, 0 skips
成功!
今日はここまで、次回はテストコードを読んでいきます。
0 件のコメント:
コメントを投稿