Issue 126 #579

Closed
wants to merge 4 commits into
from

Projects

None yet

2 participants

@preethiramdev

Reinstating prepend_before

The issue required the restoring prepend_before and append_after. However, on taking a look at the code it seems to me like "append_after" and the current "after" method would function the same way. Hence I've only added prepend_before. Please let me know if there something I'm missing on the append_after and I will get it working

@dchelimsky
RSpec member

After hooks are run in reverse: https://github.com/rspec/rspec-core/blob/master/lib/rspec/core/hooks.rb#L80.

What we should probably do is change it so after hooks are stored in reverse and run in the stored order, and then append_after will make sense. Also - the way it worked in rspec-1 was that we had

def prepend_before; ...; end
def append_before;  ...; end
def prepend_after;  ...; end
def append_after;   ...; end

alias_method :before, :append_before # so they are stored in order
alias_method :after,  :prepend_after # so they are stored in reverse order

That way the ordering is more self-evident.

@preethiramdev

Will do

@preethiramdev

You should be able to see the changes on the latest commit of this pull request. Let me know if this is what you were think of

@dchelimsky dchelimsky added a commit that referenced this pull request Mar 18, 2012
@dchelimsky dchelimsky rdoc tweaks for #579 d46c857
@dchelimsky dchelimsky added a commit that referenced this pull request Mar 18, 2012
@dchelimsky dchelimsky Changelog for #579 f85d405
@dchelimsky
RSpec member

Merged 19e2e2c

@dchelimsky dchelimsky closed this Mar 18, 2012
@dchelimsky
RSpec member

Actually, this doesn't solve the problem from rspec/rspec-rails#391 yet because we need to be able to prepend_before in a group and have it run before the hooks declared in global config :) I'm looking into a solution for this.

@preethiramdev

Agreed..Will look into it too

@dchelimsky
RSpec member

@preethiramdev I've been working on it on and off for the last week or two - basically refactoring the entire hooks functionality. You're welcome to try something, but I'm likely to go with the changes I'm already midstream on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment