Saturday 15 March 2014

ruby on rails - Why is my test failing because of inclusion error for a date range? -


I have my user model with my verification and I
 
validates_inclusion_of: birthday, in: = & gt; Date.New (1850) .. Time.Now Yuan_k (13) .to_date ,: message = & gt; 'Sorry, you must be at least 13 years old to join.'

I am using factorial and Rs. I have this test for my user model:

  "valid User Age "should be described (make sure to) (): () Birthday .in_range (13..150)} Finish the factorygear. Define Factory: User dot sequence (: first_name) {| N | "Bob # {n}"} sequence (: last_name) {| N | "User # {n}"} email {"# {first_name }@example.com"} birthday {date.today - 13.years} password "foobarbob" and end   

from now on All this gives me an error:

  User valid user age failure / error: should make sure (ensure that_decision_ (birthdays) .in_range (13..150)} errors in the "list" "When the birthday is set to 12, the error is found:   

Why does it happen when testing in the browser? Do this work as it should?

Let's check the error messages besides the range of matchers values If you see the implementation on the link that you have posted, you will see both low and high messages included in the default: (the symbol used to view the international version of the standard bar error message). / P>

Required message in the error message check Symbol, is a regexp, or allow you to specify a string.

You are using a different category in your verification, (a limit on the date created from a limit of minutes). I believe your test will be passed if you change it:

  It should be ensured (make sure that): (birthday) .in_range (date.New (1850) .. Time.More info.to_date) should be .with_message (/ at least 13 /)}    

No comments:

Post a Comment