ImageManager.check_enable_time
def check_enable_time
# get current time
now_time = Time.now
# UTC to JST convestion JST = UTC + 9 hours
hour = now_time.in_time_zone("Asia/Tokyo").hour
(hour != 23) ? true : false
end
This function return true if current time in JST != 23 else returns false.
I want to test this function.
What I tried:
describe ImageManager do
describe "Test check_enable_time() function" do
context "When current time in JST != 23" do
it 'should return true' do
image_manager = ImageManager.new
result = image_manager.check_enable_time
result.should eql(true)
end
end
end
end
How do make now_time.in_time_zone("Asia/Tokyo").hour
return 23 and other than 23?
Please help I am new to rails and rspec.
Aucun commentaire:
Enregistrer un commentaire