를 사용하여 mongoid 필드를 업데이트 : 여기단위 테스트는 내가 단위 테스트에 다음 코드 노력하고 RR
require 'mongoid'
class Seller
include Mongoid::Document
field :updated_at, type: Time
def update_updated_at
updated_at = Time.now
save
end
end
것은 나는 다음과 같은 오류
updated_at=(2013-10-14 00:00:00 -0600)
Called 0 times.
Expected 1 times.
을 얻고있다
describe Seller do
describe 'update_updated_at' do
it 'sets updated_at to Time.now' do
now = Time.new(2013,10,14)
seller = Seller.new
mock(Time).now { now }
mock(seller).updated_at= now
mock(seller).save
seller.update_updated_at
end
end
end
내 시도
timecop을 소개합니다. +1 터치. – zhon