Browse files

Merge pull request #845 from michihuber/issue-632

example group: register global hooks before individual config
  • Loading branch information...
2 parents e192cf2 + 7a88e87 commit 263809170bebc9810a9eaf1af03adf0fbbd9c335 @myronmarston myronmarston committed Mar 25, 2013
Showing with 21 additions and 1 deletion.
  1. +1 −1 lib/rspec/core/example_group.rb
  2. +20 −0 spec/rspec/core/shared_context_spec.rb
View
2 lib/rspec/core/example_group.rb
@@ -287,8 +287,8 @@ def self.set_it_up(*args)
args << build_metadata_hash_from(args)
args.unshift(symbol_description) if symbol_description
@metadata = RSpec::Core::Metadata.new(superclass_metadata).process(*args)
- world.configure_group(self)
hooks.register_globals(self, RSpec.configuration.hooks)
+ world.configure_group(self)
end
# @private
View
20 spec/rspec/core/shared_context_spec.rb
@@ -34,6 +34,26 @@
expect(after_all_hook).to be_true
end
+ it "runs the before each hooks in configuration before those of the shared context" do
+ ordered_hooks = []
+ RSpec.configure do |c|
+ c.before(:each) { ordered_hooks << "config" }
+ end
+
+ shared_context("before each stuff", :example => :before_each_hook_order) do
+ before(:each) { ordered_hooks << "shared_context"}
+ end
+
+ group = RSpec::Core::ExampleGroup.describe :example => :before_each_hook_order do
+ before(:each) { ordered_hooks << "example_group" }
+ example {}
+ end
+
+ group.run
+
+ expect(ordered_hooks).to be == ["config", "shared_context", "example_group"]
+ end
+
it "supports let" do
shared = Module.new do
extend RSpec::SharedContext

0 comments on commit 2638091

Please sign in to comment.