Rails 在模型中测试小方法是好事还是坏事?

Rails is it good or bad practice to test small methods in models?

我有型号:

 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) 既然如此简单,那么测试这些方法是不是矫枉过正和不好的做法?

但我为他们写了测试anyway.So以防万一

2) 如果我需要测试它们 - 在我的 rspec 测试中 it block description : 好吗?

it 'answer.pending edits_method' do
 some testing code
end

您应该测试所有 public 方法,无论其大小如何。因此,如果可以从 class 外部调用该方法,那么您将对其进行测试。那就是说不要测试 private/protected 方法,如果它们被用作 public api 方法的组合。编辑以回应您的编辑:我愿意

it "returns pending edits" do
end