GitXplorerGitXplorer
N

freeze_time

public
3 stars
1 forks
0 issues

Commits

List of commits on branch master.
Unverified
a978e422f4ee0ccc103760c22e8725fbbfc9583f

Readme is a lot more clear now

NNarnach committed 15 years ago
Unverified
b01885b0fa5465f1d6eaad12febae7422c0b1138

Version 0.1

NNarnach committed 15 years ago
Unverified
8778daf3a97f2cc620a85d8b71553c4bc6ba5245

New project

NNarnach committed 15 years ago

README

The README file for this repository.

= FreezeTime

Every once in a while you have a need to freeze time in your tests or specs. Usually the code that does it is ugly code, like in this example that uses rspec:

frozen_time = Time.now Time.stub!(:now).and_return(frozen_time) Foo.bar.should == frozen_time

You need to read three dense lines to understand that time is frozen and that Foo.bar should return the current time. What if this could be a lot more intention revealing?

freeze_time do |time| Foo.bar.should == time end

FreezeTime helps you test code that requires time to be frozen. It does this by implementing Object#freeze_time, which allows you to freeze time for the duration of the block. This makes your code more intention revealing and a lot more pleasant to look at.

== Installation

If you are using http://gemcutter.org, installation is easy:

gem install freeze_time

The alternative is to build and install the gem by hand:

git clone git://github.com/Narnach/freeze_time.git cd freeze_time rake install

There are no external dependencies and it should be compatible with all testing frameworks.

== Contributors

Wes Oldenbeuving [http://github.com/Narnach]