Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Be more explicit about passing a block #291

Closed
wants to merge 1 commit into from

2 participants

@jfirebaugh

JRuby 1.6.0 is not likely to support the previous bit of Proc.new magic; see http://jira.codehaus.org/browse/JRUBY-5420

John Firebaugh Be more explicit about passing a block
JRuby 1.6.0 is not likely to support the previous bit of Proc.new
magic; see http://jira.codehaus.org/browse/JRUBY-5420
b0567e1
@dchelimsky
Owner

I had it structured that way so the then clause (which happens more often than the else) wouldn't have to take the hit of Ruby creating a Proc object. That said, I did some benchmarks with this patch applied and not applied and there is no real difference on up to 100k examples on MRI or jruby.

@jfirebaugh

Be more explicit about passing a block

JRuby 1.6.0 is not likely to support the previous bit of Proc.new
magic; see http://jira.codehaus.org/browse/JRUBY-5420

@dchelimsky
Owner

Ugh - I ran the benchmarks without around hooks. Turns out that this change borks around hooks in jruby!

Leaving this open until I resolve that.

@jfirebaugh

Ugh, I see what you mean -- it breaks on JRuby 1.5.6:

NoMethodError: undefined method `metadata' for #Proc:0x18d1cbd

Looks like another JRuby bug.

@dchelimsky
Owner

I've got a fix ready - just running it through its paces against diff versions of ruby. Push coming soon.

@dchelimsky
Owner

I take it back. The fix I had was that Procsy no longer inherits from Proc, but it looks like it needs to in order to be able to use yield. This cuke is therefore failing: https://github.com/rspec/rspec-core/blob/master/features/hooks/around_hooks.feature#L12.

@jfirebaugh

Hmm... How's the performance of adding #metadata as a singleton method on a non-subclassed Proc instance?

@dchelimsky
Owner

Haven't tried and need to shut down for a few hours - wanna give that a roll and report back?

@dchelimsky
Owner

Make Procsy a module and extend the generated Procs instead of
inheriting from Proc.

@andreastt andreastt referenced this pull request from a commit
John Firebaugh Be more explicit about passing a block
JRuby 1.6.0 is not likely to support the previous bit of Proc.new
magic; see http://jira.codehaus.org/browse/JRUBY-5420

- Closes #291.
c3207da
@andreastt andreastt referenced this pull request from a commit
@dchelimsky dchelimsky Make Procsy a module and extend the generated Procs instead of
inheriting from Proc.

- This allows Procsy to behave correctly in all supported versions of
  MRI, as well as JRuby-1.5 and JRuby-1.6.
- See http://jira.codehaus.org/browse/JRUBY-5261
- See http://jira.codehaus.org/browse/JRUBY-5026
- Thanks to John Firebaugh for the suggestion!
- Closes #291 (hopefully forealz)
33f4903
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 25, 2011
  1. Be more explicit about passing a block

    John Firebaugh authored
    JRuby 1.6.0 is not likely to support the previous bit of Proc.new
    magic; see http://jira.codehaus.org/browse/JRUBY-5420
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/rspec/core/example.rb
View
4 lib/rspec/core/example.rb
@@ -93,11 +93,11 @@ def with_pending_capture
end
end
- def with_around_hooks
+ def with_around_hooks(&block)
if around_hooks.empty?
yield
else
- @example_group_class.eval_around_eachs(self, Procsy.new(metadata)).call
+ @example_group_class.eval_around_eachs(self, Procsy.new(metadata, &block)).call
end
end
Something went wrong with that request. Please try again.