0
私はモデルがありますので、シンプルあるのでRailsではモデルの小さなメソッドをテストするのは良いか悪いのですか?
class Answer < ActiveRecord::Base
def pending_edits
self.edits.where(:is_approved => nil)
end
def update_body (new_body)
update_attributes :old_body => self.body, :body => new_body
end
def current_accepted_edit
edits.find_by(:is_current => true)
end
1)は、このメソッドをテストするために、それやり過ぎと悪い習慣ですか?
しかし、私はちょうどケース
2でそれらanyway.Soのテストを書いた)、私はそれらをテストする必要がある場合 - それは良いit block description
です:私のRSpecのテストで?
it 'answer.pending edits_method' do
some testing code
end
これは本当に小さな仕様は何かあなたのテストスイートを使用して追加すると思いますか?答えが「はい」の場合:答えが「いいえ」の場合は行います。決定できない場合は実行しません。とにかく行います。 – arieljuod