Lookout

Lookout is a lightweight unit testing framework. Tests (expectations) can be
written as follows

expect 2 do
  1 + 1
end

expect NoMethodError do
  Object.invalid_method_call
end

Lookout is designed to encourage 

• 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 (additonal) way of accessing private state • Providing no setup and teardown methods, nor a method of providing test helpers

Other important points are

• A unified syntax for setting up both state-based and behavior-based expectations • A focus on code readability by providing no mechanism for describing an expectation other than the code in the expectation itself

The way Lookout works has been heavily influenced by expectations

¹ Get more information on the expectations library at http://expectations.rubyforge.org/ ² Read Jay Fields’s blog at http://blog.jayfields.com/ ³ Review Lookout revision 76 at https://github.com/now/lookout/commit/537bedf3e5b3eb4b31c066b3266f42964ac35ebe ⁴ Visit Nikolai Weibull’s home page at http://bitwi.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 http://rake.rubyforge.org/ ² Get information on RubyGems at http://rubygems.org/ ³ Find out more about Vim at http://www.vim.org/

§ 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 http://www.emacswiki.org/emacs/CompilationMode ² Visit The GNU Foundation’s Emacs’ software page at http://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 GitHub project page at http://github.com/now/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 http://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 http://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 

§ 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 https://github.com/now/lookout/issues

§ License

You may use, copy, and redistribute this library under the same terms

¹ Read the Ruby licensing terms at http://www.ruby-lang.org/en/LICENSE.txt