An open API service indexing awesome lists of open source software.

https://github.com/ged/rspec-formatter-webkit

A webkit-aware pretty formatter for RSpec (github mirror).
https://github.com/ged/rspec-formatter-webkit

Last synced: over 1 year ago
JSON representation

A webkit-aware pretty formatter for RSpec (github mirror).

Awesome Lists containing this project

README

          

= A WebKit RSpec Formatter

http://deveiate.org/webkit-rspec-formatter.html

== Description

This is a formatter for RSpec 2 that takes advantage of features in
WebKit[http://webkit.org/] to make the output from RSpec in Textmate more
fun.

Test output looks like this:

http://deveiate.org/images/tmrspec-example.png

== Installation

To get started, install the `rspec-formatter-webkit` gem:

$ gem install rspec-formatter-webkit

== Usage

If you're running specs in Textmate 2 via
{the RSpec bundle}[http://github.com/rspec/rspec-tmbundle], include
these in your .tm_properties file:

TM_RSPEC_OPTS = '-rrspec/core/formatters/webkit'
TM_RSPEC_FORMATTER = 'RSpec::Core::Formatters::WebKit'

To do the same in TextMate 1, open the 'Advanced' Preferences and
adding the same variables there:

http://deveiate.org/images/tmrspecopts-shellvar.png

That's it!

=== Logging Output

If you have some kind of log output that you'd like to show up underneath
the example, you can append lines of HTML to the logger-output
thread-local variable and they'll be inserted into a +div+ under
the example line that can be toggled open and closed by clicking the
example line:

Thread.current['logger-output'] << %{

Some stuff happened.

}

Each line that has such logging appended will appear with an asterisk after it
in the output.

==== Loggability

If you're using Loggability for logging, the WebKit formatter has CSS rules for
the output of its HTML formatter, and includes a helper for injecting the logs
generated for an example into the output. Just include the Loggability spec
helper in your RSpec config:

require 'rspec'
require 'loggability/spechelpers'

RSpec.configure do |config|
config.include( Loggability::SpecHelpers )
end

== Miscellaneous

This formatter is also usable anywhere else the standard HTML formatter is, of
course. Also, while it's specifically intended to be used under the Textmate
HTML viewer that the RSpec bundle uses, the output should work fine under
recent Gecko/Firefox-based viewers, as well.

Patches/suggestions welcomed.

== Contributing

You can check out the current development source with Mercurial via its
{project page}[ssh://repo.deveiate.org/rspec-formatter-webkit]. Or if you prefer Git, via
{its Github mirror}[https://github.com/ged/rspec-formatter-webkit].

After checking out the source, run:

$ rake newb

This task will install any missing dependencies and generate the API documentation.

== License

Copyright (c) 2009-2015, Michael Granger
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the author/s, nor the names of the project's
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.