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

Commit 33f4903

Browse files
committed
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)
1 parent 6a860d9 commit 33f4903

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

lib/rspec/core/example.rb

+13-5
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,20 @@ def fail_fast(reporter, exception)
7575
finish(reporter)
7676
end
7777

78-
class Procsy < Proc
78+
def self.procsy(metadata, &block)
79+
Proc.new(&block).extend(Procsy).with(metadata)
80+
end
81+
82+
module Procsy
7983
attr_reader :metadata
80-
alias_method :run, :call
81-
def initialize(metadata, &block)
84+
85+
def self.extended(object)
86+
def object.run; call; end
87+
end
88+
89+
def with(metadata)
8290
@metadata = metadata
83-
super(&block)
91+
self
8492
end
8593
end
8694

@@ -97,7 +105,7 @@ def with_around_hooks(&block)
97105
if around_hooks.empty?
98106
yield
99107
else
100-
@example_group_class.eval_around_eachs(self, Procsy.new(metadata, &block)).call
108+
@example_group_class.eval_around_eachs(self, Example.procsy(metadata, &block)).call
101109
end
102110
end
103111

lib/rspec/core/example_group.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def self.eval_before_alls(example_group_instance)
180180

181181
def self.eval_around_eachs(example, initial_procsy)
182182
example.around_hooks.reverse.inject(initial_procsy) do |procsy, around_hook|
183-
Example::Procsy.new(procsy.metadata) do
183+
Example.procsy(procsy.metadata) do
184184
example.example_group_instance.instance_eval_with_args(procsy, &around_hook)
185185
end
186186
end

0 commit comments

Comments
 (0)