我对 Rails 和测试完全陌生,我编写了这个模型:
class KeyPerformanceInd < ActiveRecord::Base
#attr_accessible :name, :organization_id, :target
include ActiveModel::ForbiddenAttributesProtection
belongs_to :organization
has_many :key_performance_intervals, :foreign_key => 'kpi_id'
validates :name, presence: true
validates :target, presence: true
validates :organization_id, presence: true
end
我的问题是对于这样的模型,我应该编写哪些 RSpec 测试?像这样的东西?还是有什么事情要做?我听说过FactoryGirl,这是我测试这个模型需要的东西还是用于测试控制器中的东西?
Describe KeyPerformanceInd do
it {should belong_to(:key_performance_interval)}
end