Permalink
Browse files

optionally pass configuration to ExampleGroup.create

  • Loading branch information...
1 parent 038f623 commit 992394a49f89b84a100886ef8c768a725a7a3735 @dchelimsky dchelimsky committed Feb 19, 2010
Showing with 189 additions and 183 deletions.
  1. +11 −5 lib/rspec/core/example_group.rb
  2. +1 −1 rspec-core.gemspec
  3. +177 −177 spec/rspec/core/configuration_spec.rb
@@ -62,10 +62,15 @@ def self.superclass_metadata
self.superclass.respond_to?(:metadata) ? self.superclass.metadata : nil
end
+ def self.configuration
+ @configuration
+ end
+
def self.set_it_up(*args)
+ @configuration = args.shift
@metadata = Rspec::Core::Metadata.process(superclass_metadata, *args)
- Rspec::Core.configuration.find_modules(self).each do |include_or_extend, mod, opts|
+ configuration.find_modules(self).each do |include_or_extend, mod, opts|
if include_or_extend == :extend
send(:extend, mod) unless extended_modules.include?(mod)
else
@@ -116,6 +121,7 @@ def self.create(*args, &example_group_block)
def self._build(klass, given_caller, args, &example_group_block)
args << {} unless args.last.is_a?(Hash)
args.last.update(:example_group_block => example_group_block, :caller => given_caller)
+ args.unshift Rspec::Core.configuration unless args.first.is_a?(Rspec::Core::Configuration)
klass.set_it_up(*args)
klass.module_eval(&example_group_block) if example_group_block
klass
@@ -153,26 +159,26 @@ def self.eval_before_alls(running_example)
if superclass.respond_to?(:before_all_ivars)
superclass.before_all_ivars.each { |ivar, val| running_example.instance_variable_set(ivar, val) }
end
- Rspec::Core.configuration.find_advice(:before, :all, self).each { |blk| running_example.instance_eval(&blk) }
+ configuration.find_advice(:before, :all, self).each { |blk| running_example.instance_eval(&blk) }
before_alls.each { |blk| running_example.instance_eval(&blk) }
running_example.instance_variables.each { |ivar| before_all_ivars[ivar] = running_example.instance_variable_get(ivar) }
end
def self.eval_before_eachs(running_example)
- Rspec::Core.configuration.find_advice(:before, :each, self).each { |blk| running_example.instance_eval(&blk) }
+ configuration.find_advice(:before, :each, self).each { |blk| running_example.instance_eval(&blk) }
before_ancestors.each { |ancestor| ancestor.before_eachs.each { |blk| running_example.instance_eval(&blk) } }
end
def self.eval_after_alls(running_example)
after_alls.each { |blk| running_example.instance_eval(&blk) }
- Rspec::Core.configuration.find_advice(:after, :all, self).each { |blk| running_example.instance_eval(&blk) }
+ configuration.find_advice(:after, :all, self).each { |blk| running_example.instance_eval(&blk) }
before_all_ivars.keys.each { |ivar| before_all_ivars[ivar] = running_example.instance_variable_get(ivar) }
end
def self.eval_after_eachs(running_example)
after_ancestors.each { |ancestor| ancestor.after_eachs.each { |blk| running_example.instance_eval(&blk) } }
- Rspec::Core.configuration.find_advice(:after, :each, self).each { |blk| running_example.instance_eval(&blk) }
+ configuration.find_advice(:after, :each, self).each { |blk| running_example.instance_eval(&blk) }
end
def self.run(reporter)
View
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["Chad Humphries", "David Chelimsky"]
- s.date = %q{2010-02-16}
+ s.date = %q{2010-02-19}
s.default_executable = %q{rspec}
s.description = %q{Rspec runner and example group classes}
s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
Oops, something went wrong.

0 comments on commit 992394a

Please sign in to comment.