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

Brian Takita brian.takita at gmail.com
Tue Apr 1 03:43:21 EDT 2008


Hello Roman,

Nice to see you in the rspec forum.
It looks like you are creating and running an ExampleGroup within an
Example. The "Special Example Group" is run and outputs before its
container Example is output.
I don't think I follow what that issue is about.

Thanks,
Brian

On Wed, Mar 12, 2008 at 10:12 AM, Roman Chernyatchik
<roman.chernyatchik at jetbrains.com> wrote:
> 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!"
>
>  _______________________________________________
>  rspec-devel mailing list
>  rspec-devel at rubyforge.org
>  http://rubyforge.org/mailman/listinfo/rspec-devel
>


More information about the rspec-devel mailing list