<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body>
I think because I'm passing it a block, it's returning itself when the
block has finished.  I seem to be getting normal spec durations at the
moment, but I remember in a previous project we had some silly
durations - probably exactly this problem.<br>
<br>
Will<br>
<br>
<br>
<table style="width: 98%; margin-top: 10px; font-family: arial,sans;"
 border="0" cellpadding="0" cellspacing="0">
  <tbody>
    <tr>
      <td
 style="border-bottom: 1px solid black; font-size: 20px; line-height: 28px; font-family: Trebuchet MS,arial,sans;"
 valign="bottom"> Will Tomlins</td>
      <td style="border-bottom: 1px solid black;" align="right">
      <table style="width: 145px;" align="right" border="0"
 cellpadding="0" cellspacing="0" width="145px">
        <tbody>
          <tr>
            <td
 style="font-family: Trebuchet MS,arial,sans; font-weight: bold; font-size: 35px; color: rgb(0, 0, 0); letter-spacing: -1px; height: 27px; line-height: 27px;"
 align="right" height="27px" valign="top"> Unboxed </td>
          </tr>
          <tr>
            <td
 style="font-family: Trebuchet MS,arial,sans; font-weight: bold; font-size: 30px; color: rgb(146, 39, 143); letter-spacing: -1px; height: 42px; line-height: 27px;"
 align="right" height="42px;" valign="top"> Consulting </td>
          </tr>
        </tbody>
      </table>
      </td>
    </tr>
    <tr>
      <td style="border-top: 4px solid white;" align="left" valign="top">
      <table style="font-size: 12px; font-family: arial;" align="left"
 border="0" cellpadding="0" cellspacing="0">
        <tbody>
          <tr>
            <td style="width: 16px; color: rgb(146, 39, 143);">E:</td>
            <td> <a href="mailto:will.tomlins@unboxedconsulting.com"
 style="color: black; text-decoration: none;">will.tomlins@unboxedconsulting.com</a></td>
          </tr>
          <tr>
            <td style="width: 16px; color: rgb(146, 39, 143);">M:</td>
            <td>+44 75 9535 5220</td>
          </tr>
          <tr>
            <td style="width: 16px; color: rgb(146, 39, 143);">T:</td>
            <td>+44 20 3137 2942</td>
          </tr>
          <tr>
            <td style="width: 16px; color: rgb(146, 39, 143);">F:</td>
            <td>+44 20 7183 4251</td>
          </tr>
        </tbody>
      </table>
      </td>
      <td
 style="border-top: 4px solid white; font-size: 12px; font-family: arial;"
 align="right" valign="top">
      <table style="font-size: 12px; font-family: arial;" align="right"
 border="0" cellpadding="0" cellspacing="0">
        <tbody>
          <tr>
            <td align="right">8 Elder Street</td>
          </tr>
          <tr>
            <td align="right">London, E1 6BT</td>
          </tr>
          <tr>
            <td align="right">United Kingdom</td>
          </tr>
          <tr>
            <td align="right"><a
 style="color: rgb(146, 39, 143); text-decoration: none;"
 href="http://www.unboxedconsulting.com">www.unboxedconsulting.com</a></td>
          </tr>
        </tbody>
      </table>
      </td>
    </tr>
  </tbody>
</table>
On 02/08/2010 15:49, James Adam wrote:
<blockquote
 id="mid_AANLkTi=3uvWqtuuQvSMLCccZupsJpJNDZekAEOuR1cv-_mail_gmail_com"
 cite="mid:AANLkTi=3uvWqtuuQvSMLCccZupsJpJNDZekAEOuR1cv-@mail.gmail.com"
 type="cite">
  <pre wrap="">One thing to bear in mind with Timecop, particularly as your
application grows, is remembering to add a teardown with
Timecop.return in it; if you don't, the reported duration for running
your tests/specs/whatever will be something crazy like 163526.1231
seconds.

- James

On 2 August 2010 11:31, Will Tomlins <a class="moz-txt-link-rfc2396E" href="mailto:will.tomlins@unboxedconsulting.com"><will.tomlins@unboxedconsulting.com></a> wrote:
  </pre>
  <blockquote id="StationeryCiteGenerated_2" type="cite">
    <pre wrap="">Hi People,

"Timecop is great and makes all these problems go away."
Tom Stuart
C 2nd Aug 2010 AD

Thanks Paul and others, timecop did indeed make the problems go away.

Here's what I've done:

When /^At "([^\"]*)" I go to (.*)$/ do |time_string, page_name|
  Timecop.travel(time_string) do
    When "I go to #{page_name}"
  end
end

So then I can call the step:

When At "10-10-2010 13:00:00" I go to the home page

And everything works perfectly.


Thanks people, I'll leave you with the obligatory (terrible) Timecop quote:

McComb: That's C-4. Not only will it turn this house into dust, but it will
also separate every part of you from every other part of you.

Will





On 02/08/2010 10:52, Paul Bowsher wrote:

Have you tried Timecop instead? <a class="moz-txt-link-freetext" href="http://github.com/jtrupiano/timecop">http://github.com/jtrupiano/timecop</a>
I'm using it (not within Cucumber, mind) and it works great.
Paul Bowsher


On Mon, Aug 2, 2010 at 10:50 AM, Will Tomlins
<a class="moz-txt-link-rfc2396E" href="mailto:will.tomlins@unboxedconsulting.com"><will.tomlins@unboxedconsulting.com></a> wrote:
    </pre>
    <blockquote id="StationeryCiteGenerated_3" type="cite">
      <pre wrap="">
Hi People,

I'm having a strange issue with stubbing time and I was wondering if
anyone here could shed a little light on the issue.

Firstly I am trying to stub Time.zone.now in Cucumber  # Waits while the
calls of "don't stub time in cucumber" die down #.  So the feature I'm
writing explicitly required different behaviour based on the current time,
and I would like the language of the feature to reflect this.

What I have at the moment:

When /^I time-travel to "([^\"]*)"$/ do |time_string|
  time = Time.zone.parse(time_string)
  Time.zone.stub!(:now).and_return(time)
end

Then "I return to the present day" do
  Time.zone.unstub!(:now)
end

And my features go along these lines:

    When I time-travel to "2010/01/01 10:00:00"
    And I go to the home page
    Then I should see XXXXXXXXXXXXXXXXXXX
    Then I return to the present day


And I've got 2 scenarios running which use these quantum leaps.  Each
scenario runs and passes when run on their own, but the second will fail if
the two are run together.  After a bit more digging I found that
Time.zone.now cannot be stubbed if it has previously been unstubbed.

Thus:

(rdb:1) Time.zone.stub!(:now).and_return(:something)

#<a class="moz-txt-link-rfc2396E" href="mailto:Proc:0x051b55a8@/Users/will/Sites/five-tv/vendor/gems/rspec-1.3.0/lib/spec/mocks/message_expectation.rb:61"><Proc:0x051b55a8@/Users/will/Sites/five-tv/vendor/gems/rspec-1.3.0/lib/spec/mocks/message_expectation.rb:61></a>
(rdb:1) Time.zone.now
:something

(rdb:1) Time.zone.stub!(:now).and_return(:something_else)

#<a class="moz-txt-link-rfc2396E" href="mailto:Proc:0x051b55a8@/Users/will/Sites/five-tv/vendor/gems/rspec-1.3.0/lib/spec/mocks/message_expectation.rb:61"><Proc:0x051b55a8@/Users/will/Sites/five-tv/vendor/gems/rspec-1.3.0/lib/spec/mocks/message_expectation.rb:61></a>
(rdb:1) Time.zone.now
:something_else

(rdb:1) Time.zone.unstub!(:now)
#<Spec::Mocks::MessageExpectation:0x512c5dc @at_most=nil,
@exception_to_raise=nil, @args_to_yield_were_cloned=false.......
(rdb:1) Time.zone.now
Mon, 02 Aug 2010 10:28:56 BST +01:00

(rdb:1) Time.zone.stub!(:now).and_return(:another_thing)

#<a class="moz-txt-link-rfc2396E" href="mailto:Proc:0x051b55a8@/Users/will/Sites/five-tv/vendor/gems/rspec-1.3.0/lib/spec/mocks/message_expectation.rb:61"><Proc:0x051b55a8@/Users/will/Sites/five-tv/vendor/gems/rspec-1.3.0/lib/spec/mocks/message_expectation.rb:61></a>
(rdb:1) Time.zone.now
Mon, 02 Aug 2010 10:29:12 BST +01:00

I have to unstub because the time stub seems to carry across scenarios.

Has anyone else had this issue, or know of any other way to decently
handle present time in cucumber?

Thanks,
Will



_______________________________________________
Chat mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a>
<a class="moz-txt-link-freetext" href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a>

      </pre>
    </blockquote>
    <pre wrap="">

_______________________________________________
Chat mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a>
<a class="moz-txt-link-freetext" href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a>


_______________________________________________
Chat mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a>
<a class="moz-txt-link-freetext" href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a>


    </pre>
  </blockquote>
  <pre wrap="">_______________________________________________
Chat mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Chat@lists.lrug.org">Chat@lists.lrug.org</a>
<a class="moz-txt-link-freetext" href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a>
  </pre>
</blockquote>
<br>
</body>
</html>