[rspec-devel] [ rspec-Bugs-14923 ] Nested shared behaviours get executed twice

noreply at rubyforge.org noreply at rubyforge.org
Sun Oct 21 14:23:24 EDT 2007


Bugs item #14923, was opened at 2007-10-21 17:40
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=14923&group_id=797

Category: runner module
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Wincent Colaiuta (wincent)
Assigned to: Nobody (None)
Summary: Nested shared behaviours get executed twice

Initial Comment:
My original mailing list post follows:

http://rubyforge.org/pipermail/rspec-users/2007-October/003989.html

Given the following ApplicationController specs:

  describe ApplicationController, "one facet", :shared => true do
    it 'foo' ...
    it 'bar' ...
  end

  describe ApplicationController, "some other facet", :shared => true do
    it 'abc' ...
    it 'xyz' ...
  end

  describe ApplicationController, :shared => true do
    it_should_behave_like 'ApplicationController one facet'
    it_should_behave_like 'ApplicationController some other facet'
  end

And corresponding ApplicationController subclass specs:

  describe OtherController do
    it_should_behave_like 'ApplicationController'
  end

Both of the shared behaviour blocks get executed twice when running the subclass specs; the specdoc output looks like:

  OtherController
  - foo
  - bar
  - abc
  - xyz
  - abc
  - xyz
  - foo
  - bar

And note that it's running the shared behaviours in this order:

  - 'one facet'
  - 'some other facet'
  - 'some other facet'
  - 'one facet'

Not actually a big deal; seeing as the specs don't have any side-effects and running them twice is harmless, and in any case getting rid of the nesting (putting all the specs in a single shared behaviour block) gets rid of the duplicate.

Will shortly come up with a test case that exhibits the bug. That way when this is fixed we'll have a regression test to make sure it doesn't ever creep back in.

----------------------------------------------------------------------

>Comment By: Wincent Colaiuta (wincent)
Date: 2007-10-21 18:23

Message:
Uploading a silly test case that demonstrates the bug.

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=14923&group_id=797


More information about the rspec-devel mailing list