[rspec-users] Upgrade problems/questions regarding RSpec 1.3.0 to 2.0.1

Jarmo Pertman jarmo.p at gmail.com
Thu Nov 4 15:21:58 EDT 2010


I'm trying to migrate my scripts from RSpec 1.3.0 to 2.0.1 having some
issues so far.

1) I don't like is that ".rspec" has to be in the working directory
and cannot be anymore in "spec". Okay, i can issue "mv spec/
spec.opts .rspec" in my projects, but why isn't it supported?

2) If there is somewhere "require 'spec'" in existing specs or
spec_helper or anywhere then test will not be run and this will be
shown instead:
    Finished in 0 seconds
    0 examples, 0 failures

It is also possible to reproduce it like this from command line:
rspec -rspec blah_spec.rb

3) Why does html formatter snippet show always failing line as:

in 1.x it would show the failing line in the spec file instead... is
this a bug?

4) In 1.x i modified ExampleGroup's description in my html formatter
to have some additional information in it like timestamp. I did it in
example_group_started where the passed variable example_group was an
instance of the ExampleGroup. In 2.x this is just a class name. How
can i accomplish the similar functionality?

5) I don't understand how to use multiple formatters together. In
RSpec 1.x it is possible to use multiple formatters like this:
spec --format nested --format html:output/blah.html

In RSpec 2.x it seems to me that only the last --format is used. The
command below:
rspec -f html -f d blah_spec.rb

Uses only nested formatter. In RSpec 1.x you had to specify the file
path like this:
rspec -f html:path_to_output

But it seems that in 2.x you have to use --out for that which
overrides all the output of course. And on top of if there is
everywhere used a term "formatter" in RSpec::Core::Configuration, but
"formatters" (in plural) in RSpec::Core::Reporter. It's constructor
also allows to pass multiple formatters into it.

I'd like to use two formatters together - documentation and html.
Documentation would be helpful for faster feedback and for an
indication of end of the testrun on the command line, but (custom)
html formatter would include more information for better

I managed to do that currently by little monkey-patching and manual
module RSpec
  module Core
    class Configuration
      def reporter=(reporter)
        @reporter = reporter

      public :built_in_formatter

and in spec_helper or somewhere:
config = RSpec.configuration
config.color_enabled = true
documentation_formatter =
@@html_formatter = MyHtmlFormatter.new("blah/index.html") # it takes
file path as a string due to archival and file in use needs
config.reporter = RSpec::Core::Reporter.new(documentation_formatter,

Is there some easier/more normal way to do this?

Does this mean that RSpec 2 is meant to be used with only 1 formatter

More information about the rspec-users mailing list