views:

24

answers:

1

Hi, I have an issue while running my specs for a rails application with rake, it freezes on a certain spec. I would like to see what spec is running.

+2  A: 

I have pretty funny answer for you.

The problem as I see it is that the name of the spec is written after the success or failure. And in your case it will never happen.

So you can bring a custom formatter! Yes, it will work. The problem is that base formatter defines a lot of points like when group starts, when example starts, but available formatters ( http://github.com/rspec/rspec-core/tree/master/lib/rspec/core/formatters/ ) don't use the example_started method which is exactly the one you need.

Creating custom formatter is simple - just put this file into the spec/support/formatters/anxious_formatter.rb

class AnxiousFormatter < RSpec::Core::Formatters::DocumentationFormatter
  def example_started(example)
    message = "- #{example.description}"
    output.puts message
    output.flush
  end
end

Then you can run this with:

spec -r spec/support/formatters/anxious_formatter.rb -f AnxiousFormatter spec/models/...

The example above is for Rails 3 and RSpec 2.0 - for previous version it will slightly differ. More about custom formatters (for Rails 2 and RSpec 1.x) can be found on the project wiki: http://wiki.github.com/dchelimsky/rspec/custom-formatters

Funny, isn't it?

pawien