読者です 読者をやめる 読者になる 読者になる

Thanks Driven Life

日々是感謝

RSpec Turnip Formatter

turnip rspec

Post in Japanese here

RSpec::Core::Formatters::TurnipFormatter

TurnipFormatter is a RSpec custom formatter for Turnip.

Installation and Usage

$ gem install turnip_formatter

Or

$ echo 'gem "turnip_formatter'" >> Gemfile
$ bundle install

And run this line.

$ bundle exec rspec -r turnip_formatter --format RSpecTurnipFormatter --out report.html

Then, create report.html

Motivation

Built-in formatter is hard to see.

e.g. turnip examples.

$ git clone git://github.com/jnicklas/turnip.git
$ cd turnip
$ bundle install --path vendor/bundle
$ buddle exec rspec examples -f html -o test.html -f documentation -o test.txt

First, Documentation Format

$ less test.txt
(skip..)

Steps for a feature
  Evil
    the monster has an alignment -> that alignment should be "Evil"
  Neutral
    the monster has an alignment -> that alignment should be "Neutral"

Red Dragons are deadly

    there is a dragon -> there is a knight -> the dragon attacks the knight -> the knight is alive

    there is a dragon -> the dragon breathes fire -> there is a knight -> the dragon attacks the knight -> the knight is dead

Horizon eye movement is tiring because each step connected by -> are display

In addition,

  3) raises errors Incorrect expectation there is a monster -> it should die
     Failure/Error: Then it should die

       expected: 0
            got: 1

       (compared using ==)
     # examples/steps/steps.rb:14:in `block in <top (required)>'
     # ./lib/turnip/execute.rb:20:in `step'
     # ./lib/turnip/rspec.rb:44:in `run_step'
     # ./lib/turnip/rspec.rb:70:in `block (6 levels) in run'
     # ./lib/turnip/rspec.rb:69:in `each'
     # ./lib/turnip/rspec.rb:69:in `block (5 levels) in run'
     # ./examples/errors.feature:8:in `it should die'

I can't understand easily about where scenario failed. (I can only see backtrace...)

Next, HTML Format.

$ open test.html

f:id:gongoZ:20130418195441p:plain

Code display of failed step is good. But previous problem is not resolved

Solution

$ echo 'gem "turnip_formatter"' >> Gemfile
$ bundle install
$ bundle exec rspec examples -r turnip_formatter -f RSpecTurnipFormatter -o report.html

f:id:gongoZ:20130418195458p:plain

So good!!!

f:id:gongoZ:20130418195501p:plain

Very so good!!

You can be found here demo.

Epilogue

I setting save and display this report on Jenkins.

Enter permalink of failed step on report to IRC, make good progress of code review. :+1: