31 Temmuz 2009, Cuma
Nasıl sahte Zaman.şimdi?
Bir birim test zaman duyarlı yöntemler test amaçlı Time.now
ayarlamak için en iyi yolu nedir?
CEVAP
3 AĞUSTOS 2009, PAZARTESİ
Gerçekten Timecop kütüphane gibi. Blok form (zaman tüneli) zaman çözgü yapabilirsiniz:
Timecop.travel(6.days.ago) do
@model = TimeSensitiveMode.new
end
assert @model.times_up!
(Evet, yuva blok şeklinde zaman seyahat edebilirsiniz.)
Ayrıca açıklayıcı zamanda yolculuk: yapabilirsiniz
class MyTest < Test::Unit::TestCase
def setup
Timecop.travel(...)
end
def teardown
Timecop.return
end
end
here Timecop cucumber bazı yardımcıları var. Şey gibi onlar
Given it is currently January 24, 2008
And I go to the new post page
And I fill in "title" with "An old post"
And I fill in "body" with "..."
And I press "Submit"
And we jump in our Delorean and return to the present
When I go to the home page
I should not see "An old post"
Bunu Paylaş:
Nasıl JavaScript bir zaman damgası alm...
Nasıl dosyaları zaman uyumsuz olarak y...
Göreli zaman nasıl hesaplanır?...
Nasıl Python ile şimdiki zaman almak i...
Nasıl Python ile bir zaman gecikmesi y...