[rspec-users] Upgrade problems/questions regarding RSpec 1.3.0 to 2.0.1
dchelimsky at gmail.com
Fri Nov 5 07:52:26 EDT 2010
On Nov 4, 2010, at 2:21 PM, Jarmo Pertman wrote:
> 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?
It's more common across other libraries to put "dot files" in your home and/or project root directories.
> 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
Sounds like a new bug. Please report to http://github.com/rspec/rspec-core/issues.
> 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?
Yes. Please report to http://github.com/rspec/rspec-core/issues.
> 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?
You can write a custom subclass of the HtmlFormatter and add whatever you like.
> 5) I don't understand how to use multiple formatters together.
You can't yet. rspec-core-2 was built from Micronaut, so a lot of the functionality had to be rebuilt. This is one feature I didn't forward port from rspec-1 because I didn't see the value in it for the complexity. RSpec-2 has been in the works for over a year now and you're the first person to ask about this, so it's obviously not a widely used feature, and I'm trying to keep unused features out.
Feel free to report this to http://github.com/rspec/rspec-core/issues and we can discuss it further in the issue.
> 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
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users