[rspec-devel] BaseFormatter.example_started(example) suspicious behavior

Roman Chernyatchik roman.chernyatchik at jetbrains.com
Wed Mar 12 13:12:57 EDT 2008


Hi guys!

I'm developing a custom formatter for RSpec(Rake Runner Plugin for TeamCity
buildserver, see draft description at
http://www.jetbrains.net/confluence/display/RUBYDEV/TeamCity+Rake+Runner).

I've noticed some problems during running tests. 

1. On RSpec project, rev.3331.
'Spec::Runner::Formatter::BaseFormatter.start'  and
'Spec::Runner::Formatter::BaseFormatter.dump_summary' methods returns
different example counts.
I.e.
'Spec::Runner::Formatter::BaseFormatter.start'  - 1255
'Spec::Runner::Formatter::BaseFormatter.dump' - 1314

2. In some cases RSpec starts example in one group and ends in other example
group.

How to reproduce:
Let's consider RSpec spec tests. You can see such behavior in html output or
by simple debug print:

E.g. in rspec/spec/spec/example/configuration_spec.rb example group

###########################
      describe "#prepend_before" do
        it "prepends the before block on all instances of the passed in
type" do
          order = []

          ...

          @example_group.it "calls prepend_before" do
          end
        
          @example_group.run
          order.should == [
            ...
          ]
        end
      end
###########################

leads to HTML output:

---------------------------
Spec::Example::Configuration#prepend_before

Special Example Group
    calls prepend_before
    prepends the before block on all instances of the passed in type
---------------------------
In fact the order of events is:

1. BaseFormatter.add_example_group : example group description =
"Spec::Example::Configuration#prepend_before"
2. BaseFormatter.example_started   : example description = "prepends the
before block on all instances of the passed in type"

3. BaseFormatter.add_example_group : example group description = "Special
Example Group"
4. BaseFormatter.example_started   : example description = "prepend_before"
5. BaseFormatter.example_passed    : example description = "calls
prepend_before"
6. BaseFormatter.example_passed    : example description = "prepends the
before block on all instances of the passed in type"

7. BaseFormatter.add_example_group : example group description =
"Spec::Example::Configuration#append_before"
....
-----------------------------
This problem can be reproduced on 1.1.3 and trunk versions.



----
Chernyatchik Roman
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"



More information about the rspec-devel mailing list