Lookout

Lookout is a unit testing framework for Ruby

• Setting up only one expectation per test • Not setting expectations on non-public APIs • Test isolation

This is done by

• Only allowing one expectation to be set per test • Providing no (additional) way of accessing private state • Providing no setup and tear-down methods, nor a method of providing test

  helpers

Other important points are

• Putting the expected outcome of a test in focus with the steps of the

calculation of the actual result only as a secondary concern

• A focus on code readability by providing no mechanism for describing an

expectation other than the code in the expectation itself

• A unified syntax for setting up both state-based and behavior-based

  expectations

The way Lookout works has been heavily influenced by expectations

¹ Ruby: ruby-lang.org/ ² Expectations: expectations.rubyforge.org/ ³ Jay Fields’s blog: blog.jayfields.com/ ⁴ Lookout revision 76:

https://github.com/now/lookout/commit/537bedf3e5b3eb4b31c066b3266f42964ac35ebe

⁵ Nikolai Weibull’s home page: disu.se/

§ Installation

Install Lookout with

  % gem install lookout

§ Usage

  Lookout allows you to set expectations on an object

§ Integration

Lookout can be used from Rake

¹ Read more about Rake at rake.rubyforge.org/ ² Get information on Lookout-Rake at disu.se/software/lookout-rake/

§ API

Lookout comes with an API

¹ See disu.se/software/lookout/api/

§ Interface Design

The default output of Lookout can Spartanly be described as Spartan.  If no
errors or failures occur, no output is generated.  This is unconventional,
as unit testing frameworks tend to dump a lot of information on the user,
concerning things such as progress, test count summaries, and flamboyantly
colored text telling you that your tests passed.  None of this output is
needed.  Your tests should run fast enough to not require progress reports.
The lack of output provides you with the same amount of information as
reporting success.  Test count summaries are only useful if you

¹ Read up on Compilation mode for Emacs at www.emacswiki.org/emacs/CompilationMode ² Visit The GNU Foundation’s Emacs’ software page at www.gnu.org/software/emacs/

§ External Design

Let

¹ Read the Wikipedia entry for Resource Acquisition Is Initialization at

http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization

² Read how 37signals had problems with slow Test::Unit tests at

http://37signals.com/svn/posts/2742-the-road-to-faster-tests/

³ Visit the Lookout-rack home page at

http://disu.se/software/lookout-rack/

⁴ Visit the Rack Rubyforge project page at

http://rack.rubyforge.org/

§ Internal Design

  The internal design of Lookout has had a couple of goals.

§ External Dependencies

Lookout used to depend on Mocha for mocks and stubs.  While benchmarking I
noticed that a method in Mocha was taking up more than 300 percent of the
runtime.  It turned out that Mocha

¹ See the Wolfram Alpha calculation at www.wolframalpha.com/input/?i=days+between+march+17%2C+2010+and+november+26%2C+2010 ² Check out the Wolfram Alpha computational knowledge engine at www.wolframalpha.com/

§ Internal Dependencies

Lookout has been designed so as to keep each subsystem independent of any
other.  The diff subsystem is, for example, completely decoupled from any
other part of the system as a whole and could be moved into its own library
at a time where that would be of interest to anyone.  What

§ Optimizing For Speed

The following paragraph is perhaps a bit personal, but might be interesting
nonetheless.

I

§ Naming

I hate low lines (underscores).  I try to avoid them in method names and I
always avoid them in file names.  Since the current 

§ News

§ Financing

Currently, most of my time is spent at my day job and in my rather busy
private life.  Please motivate me to spend time on this piece of software
by donating some of your money to this project.  Yeah, I realize that
requesting money to develop software is a bit, well, capitalistic of me.
But please realize that I live in a capitalistic society and I need money
to have other people give me the things that I need to continue living
under the rules of said society.  So, if you feel that this piece of
software has helped you out enough to warrant a reward, please PayPal a
donation to now@disu.se

¹ Send a donation:

https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=now%40disu%2ese&item_name=Lookout

§ Reporting Bugs

  Please report any bugs that you encounter to the {issue tracker}

§ Contributors

  Contributors to the original expectations codebase are mentioned there.  We
  hope no one on that list feels left out of this list.  Please
  {let us know}

¹ Add an issue to the Lookout issue tracker at github.com/now/lookout/issues

§ Licensing

Lookout is free software: you may redistribute it and/or modify it under
the terms of the {GNU Lesser General Public License, version 3}¹ or later²,
as published by the {Free Software Foundation}³.

¹ See disu.se/licenses/lgpl-3.0/ ² See gnu.org/licenses/ ³ See fsf.org/