Permalink
Browse files

Merge branch 'master' of github.com:rspec/rspec-core

  • Loading branch information...
2 parents 538dc8a + 4b576e7 commit b7d07dfe23d7b0912a351c973817aed411325450 @dchelimsky dchelimsky committed Feb 5, 2010
Showing with 33 additions and 28 deletions.
  1. +1 −1 Rakefile
  2. +13 −8 lib/rspec/core/example.rb
  3. +19 −19 lib/rspec/core/example_group.rb
View
@@ -19,7 +19,7 @@ begin
gem.description = 'Rspec runner and example group classes'
gem.email = "dchelimsky@gmail.com;chad.humphries@gmail.com"
gem.homepage = "http://github.com/rspec/core"
- gem.authors = ["David Chelimsky", "Chad Humphries"]
+ gem.authors = ["Chad Humphries", "David Chelimsky"]
gem.rubyforge_project = "rspec"
gem.add_development_dependency "rspec-expectations", ">= #{Rspec::Core::Version::STRING}"
gem.add_development_dependency "rspec-mocks", ">= #{Rspec::Core::Version::STRING}"
View
@@ -2,12 +2,17 @@ module Rspec
module Core
class Example
- attr_reader :example_group, :metadata, :example_block
+ attr_reader :metadata, :example_block
+
+ def example_group
+ @example_group_class
+ end
+
alias_method :behaviour, :example_group
- def initialize(example_group, desc, options, example_block=nil)
- @example_group, @options, @example_block = example_group, options, example_block
- @metadata = @example_group.metadata.for_example(desc, options)
+ def initialize(example_group_class, desc, options, example_block=nil)
+ @example_group_class, @options, @example_block = example_group_class, options, example_block
+ @metadata = @example_group_class.metadata.for_example(desc, options)
end
def description
@@ -51,11 +56,11 @@ def run_finished(status, results={})
def run_before_each
@example_group_instance._setup_mocks if @example_group_instance.respond_to?(:_setup_mocks)
- @example_group.eval_before_eachs(@example_group_instance)
+ @example_group_class.eval_before_eachs(@example_group_instance)
end
def run_after_each
- @example_group.eval_after_eachs(@example_group_instance)
+ @example_group_class.eval_after_eachs(@example_group_instance)
@example_group_instance._verify_mocks if @example_group_instance.respond_to?(:_verify_mocks)
ensure
@example_group_instance._teardown_mocks if @example_group_instance.respond_to?(:_teardown_mocks)
@@ -93,10 +98,10 @@ def run(example_group_instance)
begin
run_before_each
- if @example_group.around_eachs.empty?
+ if @example_group_class.around_eachs.empty?
@example_group_instance.instance_eval(&example_block) if runnable?
else
- @example_group.around_eachs.first.call(AroundProxy.new(self, &example_block))
+ @example_group_class.around_eachs.first.call(AroundProxy.new(self, &example_block))
end
rescue Exception => e
exception_encountered = e
@@ -136,36 +136,36 @@ def self.before_all_ivars
@before_all_ivars ||= {}
end
- def self.eval_before_alls(running_example_group)
- superclass.before_all_ivars.each { |ivar, val| running_example_group.instance_variable_set(ivar, val) }
- Rspec::Core.configuration.find_advice(:before, :all, self).each { |blk| running_example_group.instance_eval(&blk) }
+ def self.eval_before_alls(running_example)
+ superclass.before_all_ivars.each { |ivar, val| running_example.instance_variable_set(ivar, val) }
+ Rspec::Core.configuration.find_advice(:before, :all, self).each { |blk| running_example.instance_eval(&blk) }
- before_alls.each { |blk| running_example_group.instance_eval(&blk) }
- running_example_group.instance_variables.each { |ivar| before_all_ivars[ivar] = running_example_group.instance_variable_get(ivar) }
+ 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_group)
- Rspec::Core.configuration.find_advice(:before, :each, self).each { |blk| running_example_group.instance_eval(&blk) }
- before_ancestors.each { |ancestor| ancestor.before_eachs.each { |blk| running_example_group.instance_eval(&blk) } }
+ def self.eval_before_eachs(running_example)
+ Rspec::Core.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_group)
- after_alls.each { |blk| running_example_group.instance_eval(&blk) }
- Rspec::Core.configuration.find_advice(:after, :all, self).each { |blk| running_example_group.instance_eval(&blk) }
- before_all_ivars.keys.each { |ivar| before_all_ivars[ivar] = running_example_group.instance_variable_get(ivar) }
+ 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) }
+ before_all_ivars.keys.each { |ivar| before_all_ivars[ivar] = running_example.instance_variable_get(ivar) }
end
- def self.eval_after_eachs(running_example_group)
- after_ancestors.each { |ancestor| ancestor.after_eachs.each { |blk| running_example_group.instance_eval(&blk) } }
- Rspec::Core.configuration.find_advice(:after, :each, self).each { |blk| running_example_group.instance_eval(&blk) }
+ 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) }
end
def self.run(reporter)
- example_world = new
+ example_group_instance = new
reporter.add_example_group(self)
- eval_before_alls(example_world)
- success = run_examples(example_world, reporter)
- eval_after_alls(example_world)
+ eval_before_alls(example_group_instance)
+ success = run_examples(example_group_instance, reporter)
+ eval_after_alls(example_group_instance)
success
end

0 comments on commit b7d07df

Please sign in to comment.