Hello!
I’m trying to migrate my scripts from RSpec 1.3.0 to 2.0.1 having some
issues so far.
-
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? -
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
- Why does html formatter snippet show always failing line as:
raise(RSpec::Expectations::ExpectationNotMetError.new(message))
in 1.x it would show the failing line in the spec file instead… is
this a bug?
-
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? -
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
troubleshooting.
I managed to do that currently by little monkey-patching and manual
coding:
module RSpec
module Core
class Configuration
def reporter=(reporter)
@reporter = reporter
end
public :built_in_formatter
end
end
end
and in spec_helper or somewhere:
config = RSpec.configuration
config.color_enabled = true
documentation_formatter =
config.built_in_formatter(:documentation).new(config.output)
@@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,
@@html_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
simultaneously?