[LRUG] Time Based Requirements for Feature testing

Tom Ward tom at popdog.net
Thu Oct 1 10:13:34 PDT 2009


Timecop provides some useful methods to deal with Time when testing:
http://github.com/jtrupiano/timecop

2009/10/1 David Henry <dw_henry at yahoo.com.au>

> Hello,
>
> Was wondering if anyone else had encountered this problem and if there was
> a nice rubish solution:
>
> NOTE: this is not the fully problem but a cut down version to help get the
> answer I want..
>
> I am trying to find a way to get the below to work in a Celerity Test (Have
> also looked at using Selenium but it didn't seem to have a solution to this
> problem either)
>
> I have an create action which can be performed before 12pm, however after
> 12pm it should not be possible to perform the action (both the link to
> perform the create should not be displayed and attempting to create should
> fail.  I want this to run as a feature to ensure all the parts work together
> as expected.  The below scenarios cover the flow that I want..
>
> *Scenario 1 (Booked before 12pm => should create without issue):*
> Given I have an Existing Advice
> And the time is 11am
> Then I can see 'Book Trade'
> When I follow 'Book Trade'
> And I book a 'Trade'
> Then I can see Successfully booked trade
>
>  *Scenario 2 (try to book after 12pm => should not be link to create):*
> Given I have an Existing Advice
> And the time is 13am
> Then I can NOT see 'Book Trade'
>
>  *Scenario 3 (Start to book before 12pm but wait until after 12pm to try
> and save => should follow link but fail on save):*
> Given I have an Existing Advice
> And the time is 11am
> Then I can see 'Book Trade'
>  When I follow 'Book Trade'
> And the time is 13am
> And I book a 'Trade'
> Then I can see 'Trade Booking Failed'
>
> The only approach I can think of is to somehow stub out Time.now to return
> the required values (this is what I have done in the RSpec) and yes I am
> aware this should not really be done in Feature..
>
> This does not work as celerity is actually running in a different process.
>
> Doe anyone know how to write a feature for this senario so that I can
> control what time it is on the test server.
>
> Thanks for your help
>
> David
>
>
> [image: Lyagushka]    [image: Proton]
>
> David Henry
> Chief Technology Officer
> Lyagushka Limited
> Phone: +44 78 7928 2112
>
> ------------------------------
> Get more done like never before with Yahoo!7 Mail. Learn more<http://au.rd.yahoo.com/mail/launch09/tagline/*http://us.lrd.yahoo.com/_ylc=X3oDMTFnY201cHJnBHRtX2RtZWNoA1RleHQgTGluawR0bV9sbmsDVTExMDQ3NjAEdG1fbmV0A1lhaG9vIQ--/SIG=11aljvgo4/*http%3A//au.overview.mail.yahoo.com/>
> .
>
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20091001/e6a4da6d/attachment-0003.html>


More information about the Chat mailing list