ruby on rails - factory_girl: Factories fails validation(of time) on create, but in my app, the validation passes -


i have created application strict input validation time.. have type in time format: 14:00.

this works fine, when create factories factory-girl, tests, validation fails , can see factory-girl tries create them data: 2000-01-01 14:00:00 utc

this factory:

factory :stamp   end_time "14:00" end 

so when run factorygirl.create(:stamp) fg tries set end_time to: 2000-01-01 14:00:00 utc, , validation fails.

this validation method:

validates :start_time, :end_time, :format => { :with => /[0-2][0-3]:[0-5][0-9]/,                                    :message => "you have enter time in format 14:00" 

how can make factorygirl create models without tampering time-data , fail validation?

you can try force factorygirl format end_time:

factory :stamp   end_time time.new(2013,1,1,14,0,0).strftime("%h:%m") end 

strftime("%h:%m") converts time format looking for


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -