Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Conversation

fj
Copy link
Contributor

@fj fj commented Jan 28, 2011

As per a discussion on the mailing list, David suggested it might be useful to alias ":all" to ":any" for before/after hooks. Here is a patch that does that.

@dchelimsky
Copy link
Contributor

Here's the thread: http://groups.google.com/group/rspec/browse_thread/thread/26ea96043f46b3b6

Rick DeNatale pointed out that :any would just be confusing in an after hook: after(:any), which leads me to think we should probably not do this as it would just add confusion. I'm going to leave this open for a bit to see if anyone else wants to voice an opinion.

@fj
Copy link
Contributor Author

fj commented Jan 28, 2011

Not to shoot my own patch in the foot, but my personal opinion is to have only one way to do it. I think whatever ambiguity there may be in before(:all) isn't adequately compensated by the additional confusion of having before(:any), which sounds like it would do something subtly different.

@markiz
Copy link

markiz commented Jan 28, 2011

Why is :any aliased to :all instead of :each? FWIW, I think the difference is clear now and won't be so clear with introduction of this alias.

@fj
Copy link
Contributor Author

fj commented Jan 28, 2011

@markiz: Because that's what the discussion was about. It was triggered by this reasoning: "before(:each) runs before each spec runs, while before(:all) runs before any spec runs". My vote is to leave it the way it is, but I wrote the patch to show what it might look like if we did have a better reason for aliases in the future.

@dchelimsky
Copy link
Contributor

On the rspec-users mailing list, Evgeniy Dolzhenko suggested:

before(:suite)
before(:group)
before(:example)

If we're going to change the existing names at all, I'm a big fan of this. The names work very well together, with both before and after. The default would be :example. And these don't really conflict/confuse with the existing language - it's just an alternative that we would support and promote as the default over time.

Thoughts?

@fj
Copy link
Contributor Author

fj commented Feb 2, 2011

What's the difference between :suite and :group?

@dchelimsky
Copy link
Contributor

before(:suite) and after(:suite) already exist, and are the first and last hooks to run, outside of any example groups.

@fj
Copy link
Contributor Author

fj commented Feb 2, 2011

I have made a new pull request which supersedes this one to use Evgeniy Dolzhenko's suggestions. You can see it here.

In the meantime, I will close this pull request.

This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants