I would suggest using the chronic gem for your dates
1.9.3p194 :002 > Chronic.parse("the first day of last week")
=> 2012-07-29 12:00:00 -0400
1.9.3p194 :013 > Chronic.parse("the first day of last week").strftime("%D")
=> "07/29/12"
On Fri, Aug 10, 2012 at 12:45 PM, Ry <[email protected]> wrote:
>
> Given /^that I enter a false date or incorrect format$/ do
> ie.form(:id,
> 'options-for-RTK::VOD::Reports::XtnsByProvider').text_field(:id,
> 'date_range_1').set('02292011')
> ie.form(:id,
> 'options-for-RTK::VOD::Reports::XtnsByProvider').text_field(:id,
> 'date_range_2').set('06122012')
> end
>
> When /^I click go$/ do
> ie.button(:name, 'go').click
> end
>
> Then /^I will see the date auto correct to a new format$/ do
> assert (ie.form(:id,
> 'options-for-RTK::VOD::Reports::XtnsByProvider').text_field(:id,
> 'date_range_1').exists('**/**/2012')
> end
>
> in the first step 02 29 2011 is not a valid date, so in the second step,
> we have a button 'GO' that regenerates the page. What is expected to happen
> is that the 02 29 2011 will revert to the first day of the most recent
> week, so this date will change always, so I need to validate the format
> mainly and confirm that it is 2012 if possible.
>
>
> On Friday, August 10, 2012 9:38:42 AM UTC-7, Oscar.Rieken wrote:
>
>> To me this sounds like more of whatever framework you are using to
>> actually write your tests
>>
>> you can probably do a regex to verify the format but without some more
>> details of what exactly you want to compare it may be difficult to help out
>>
>> I would ask why are you trying to test this and what your test looks like
>> now
>>
>> On Fri, Aug 10, 2012 at 12:23 PM, Ry <[email protected]> wrote:
>>
>>> anyone familiar with how to write an assertion for a date format. For
>>> instance, I am testing a date field to ensure it doesn't accept bad
>>> formatting or unreal dates. Our page will auto revert the date to something
>>> recent when the page refreshes so I want to write an assert to say I expect
>>> mm/dd/2012
>>>
>>> --
>>> Before posting, please read http://watir.com/support. In short: search
>>> before you ask, be nice.
>>>
>>> [email protected]
>>> http://groups.google.com/**group/watir-general<http://groups.google.com/group/watir-general>
>>> watir-genera...@**googlegroups.com
>>>
>>
>> --
> Before posting, please read http://watir.com/support. In short: search
> before you ask, be nice.
>
> [email protected]
> http://groups.google.com/group/watir-general
> [email protected]
>
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]