Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move around hook wrapping to ExampleGroup

Example delegates before and after hook running to ExampleGroup, so let's do
the same for around hook wrapping.
  • Loading branch information...
commit b1c2ab49f327379ca1a09628fb660ef5cd9c5306 1 parent 4e796d6
@benarmston benarmston authored
Showing with 12 additions and 9 deletions.
  1. +1 −9 lib/rspec/core/example.rb
  2. +11 −0 lib/rspec/core/example_group.rb
View
10 lib/rspec/core/example.rb
@@ -79,15 +79,7 @@ def with_pending_capture
end
def with_around_hooks(&wrapped_example)
- around_hooks_for(@example_group_class).reverse.inject(wrapped_example) do |wrapper, hook|
- def wrapper.run; call; end
- lambda { @example_group_instance.instance_exec(wrapper, &hook) }
- end
- end
-
- def around_hooks_for(example_group_class)
- (RSpec.configuration.hooks[:around][:each] +
- @example_group_class.ancestors.reverse.map{|a| a.hooks[:around][:each]}).flatten
+ @example_group_class.eval_around_eachs(@example_group_instance, wrapped_example)
end
def start(reporter)
View
11 lib/rspec/core/example_group.rb
@@ -159,6 +159,17 @@ def self.eval_after_eachs(example)
world.run_hook_filtered(:after, :each, self, example)
end
+ def self.eval_around_eachs(example_group_instance, wrapped_example)
+ around_hooks.reverse.inject(wrapped_example) do |wrapper, hook|
+ def wrapper.run; call; end
+ lambda { example_group_instance.instance_exec(wrapper, &hook) }
+ end
+ end
+
+ def self.around_hooks
+ (RSpec.configuration.hooks[:around][:each] + ancestors.reverse.map{|a| a.hooks[:around][:each]}).flatten
+ end
+
def self.eval_after_alls(example)
return if descendant_filtered_examples.empty?
before_all_ivars.each { |ivar, val| example.instance_variable_set(ivar, val) }
Please sign in to comment.
Something went wrong with that request. Please try again.