require 'test_helper'
class PersonTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
テスト用のデータベースを準備しないと動かせない(?)ので素直にテスト用のデータベースを準備する。
rake db:test:prepare
Railsのアプリケーションフォルダで実行する。
ruby -I test test/unit/person_test.rb
| rake test | 全テストを実行する。 |
| rake test:units | ユニットテストを全て実行する。 |
def fixtures(*table_names)
if table_names.first == :all
table_names = Dir["#{fixture_path}/*.yml"] + Dir["#{fixture_path}/*.csv"]
p table_names
table_names.map! { |f| File.basename(f).split('.')[0..-2].join('.') }
else
table_names = table_names.flatten.map { |n| n.to_s }
end