Skip to content

Instantly share code, notes, and snippets.

@DNNX DNNX/README.md
Created Jul 11, 2011

Embed
What would you like to do?

This simple framework allows you to assert things that should happen tomorrow*. For example:

assert_tomorrow { Time.now.wday == 2 } # => :passed
                                       # assuming today is Monday (i.e. wday == 1)

Another example shows that the time will never be the same again:

today = Time.now
assert_tomorrow { Time.now == today } # => :failed

And sometimes we can't event assert something for sure, because my expectation is too complex!

assert_tomorrow { _why is back }      # => :error

Of course, there is a lot room for improvement. You can introduce you own DSL and run tests against your life, for example:

me = Dnnx.instance.clone
assert_tomorrow do 
  future_me = Dnnx.instance 
  future_me.is_better_than me
end

*I didn't invent a time machine, so you have to wait 1 day for test result.

def assert_tomorrow() sleep(24*60*60); (yield ? :passed : :failed) rescue :error end
@jeffkreeftmeijer

This comment has been minimized.

Copy link

jeffkreeftmeijer commented Jul 14, 2011

This is certainly the best way to test if something will happen tomorrow without cheating and using a time machine. Awesome work! ;)

@bltavares

This comment has been minimized.

Copy link

bltavares commented Jul 17, 2011

Funny

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.