[rspec-devel] [ rspec-Feature Requests-14980 ] Nested Behaviour -- reopened

noreply at rubyforge.org noreply at rubyforge.org
Tue Oct 23 09:59:28 EDT 2007


Feature Requests item #14980, was opened at 2007-10-23 08:15
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=14980&group_id=797

Category: None
Group: None
Status: Open
Priority: 3
Submitted By: Brian Takita (btakita)
Assigned to: Nobody (None)
Summary: Nested Behaviour -- reopened

Initial Comment:
I'd like to reopen discussion for Nested Behaviour. On my current project, we are in a situation where nested describe blocks would be an elegant way to organize our examples.

It should be easy to implement given the current state of the source.
All that needs to be done is have Example.describe create a subclass of the current class.

Currently, here is our setup:

module AssociationMethods
  describe Person, "#games" do
  end
end

module CustomMethods
  describe Person, "#current_game" do
  end
end

Having nested describe blocks would allow:
describe Person, "association methods" do
  describe Person, "#games" do
  end
end

describe Person, "custom methods" do
  describe Person, "#current_game" do
  end
end

Also nested behaviour would allow sharing of before and after blocks.

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

>Comment By: David Chelimsky (dchelimsky)
Date: 2007-10-23 13:59

Message:
... in fact, I'm so open that here is my proposal:

First let's close the loop on 1.1.0 issues and get that puppy out.

Once that's released, you should feel free to create a branch for this. It would be up to you to maintain it, keep it up to date w/ changes from trunk, etc. It would also be up to you to tend to questions on the mailing list related to this feature (and you can expect some from me as I'll be experimenting).

After some time, if people are using it and it is proving more beneficial than harmful, we can consider moving it into the trunk.

So a temporary fork of sorts. WDYT?

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

Comment By: David Chelimsky (dchelimsky)
Date: 2007-10-23 13:33

Message:
Well, as you might imagine, I am very resistant to this. First, a few questions:

What would be the order of precedence of befores and afters?
What about a before(:all) or after(:all)?
How would they relate to the befores/afters set up globally?
What would the output look like?
Would the output be nested too? How deeply? Is there a limit?
Can we have examples inside the outer spec?
What is the scope of helper methods?
What happens with the --reverse flag.

I'm sure there are more of these questions that I'm not thinking of yet. I really think that this would open up a can of procedural worms that I'd be inclined to leave closed.

Additionally, even if all of my questions are answered easily, I can guarantee that it will lead to long debugging sessions focused on specs, which is exactly the opposite of where rspec should take you. I'd really hate to see the rspec lists get flooded with questions from people who are creating deeply nested hierarchies of specs and having trouble understanding why they aren't working. That's just not what this is all about.

My vote is nay.

But I'm open :)


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

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


More information about the rspec-devel mailing list