Skip to content
This repository
Browse code

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

  • Loading branch information...
commit b7d07dfe23d7b0912a351c973817aed411325450 2 parents 538dc8a + 4b576e7
David Chelimsky authored February 04, 2010
2  Rakefile
@@ -19,7 +19,7 @@ begin
19 19
     gem.description = 'Rspec runner and example group classes'
20 20
     gem.email = "dchelimsky@gmail.com;chad.humphries@gmail.com"
21 21
     gem.homepage = "http://github.com/rspec/core"
22  
-    gem.authors = ["David Chelimsky", "Chad Humphries"]
  22
+    gem.authors = ["Chad Humphries", "David Chelimsky"]
23 23
     gem.rubyforge_project = "rspec"
24 24
     gem.add_development_dependency "rspec-expectations", ">= #{Rspec::Core::Version::STRING}"
25 25
     gem.add_development_dependency "rspec-mocks", ">= #{Rspec::Core::Version::STRING}"
21  lib/rspec/core/example.rb
@@ -2,12 +2,17 @@ module Rspec
2 2
   module Core
3 3
     class Example
4 4
 
5  
-      attr_reader :example_group, :metadata, :example_block
  5
+      attr_reader :metadata, :example_block
  6
+
  7
+      def example_group
  8
+        @example_group_class
  9
+      end
  10
+
6 11
       alias_method :behaviour, :example_group
7 12
 
8  
-      def initialize(example_group, desc, options, example_block=nil)
9  
-        @example_group, @options, @example_block = example_group, options, example_block
10  
-        @metadata = @example_group.metadata.for_example(desc, options)
  13
+      def initialize(example_group_class, desc, options, example_block=nil)
  14
+        @example_group_class, @options, @example_block = example_group_class, options, example_block
  15
+        @metadata = @example_group_class.metadata.for_example(desc, options)
11 16
       end
12 17
 
13 18
       def description
@@ -51,11 +56,11 @@ def run_finished(status, results={})
51 56
 
52 57
       def run_before_each
53 58
         @example_group_instance._setup_mocks if @example_group_instance.respond_to?(:_setup_mocks)
54  
-        @example_group.eval_before_eachs(@example_group_instance)
  59
+        @example_group_class.eval_before_eachs(@example_group_instance)
55 60
       end
56 61
 
57 62
       def run_after_each
58  
-        @example_group.eval_after_eachs(@example_group_instance)
  63
+        @example_group_class.eval_after_eachs(@example_group_instance)
59 64
         @example_group_instance._verify_mocks if @example_group_instance.respond_to?(:_verify_mocks)
60 65
       ensure
61 66
         @example_group_instance._teardown_mocks if @example_group_instance.respond_to?(:_teardown_mocks)
@@ -93,10 +98,10 @@ def run(example_group_instance)
93 98
 
94 99
         begin
95 100
           run_before_each
96  
-          if @example_group.around_eachs.empty?
  101
+          if @example_group_class.around_eachs.empty?
97 102
             @example_group_instance.instance_eval(&example_block) if runnable?
98 103
           else
99  
-            @example_group.around_eachs.first.call(AroundProxy.new(self, &example_block))
  104
+            @example_group_class.around_eachs.first.call(AroundProxy.new(self, &example_block))
100 105
           end
101 106
         rescue Exception => e
102 107
           exception_encountered = e
38  lib/rspec/core/example_group.rb
@@ -136,36 +136,36 @@ def self.before_all_ivars
136 136
         @before_all_ivars ||= {}
137 137
       end
138 138
 
139  
-      def self.eval_before_alls(running_example_group)
140  
-        superclass.before_all_ivars.each { |ivar, val| running_example_group.instance_variable_set(ivar, val) }
141  
-        Rspec::Core.configuration.find_advice(:before, :all, self).each { |blk| running_example_group.instance_eval(&blk) }
  139
+      def self.eval_before_alls(running_example)
  140
+        superclass.before_all_ivars.each { |ivar, val| running_example.instance_variable_set(ivar, val) }
  141
+        Rspec::Core.configuration.find_advice(:before, :all, self).each { |blk| running_example.instance_eval(&blk) }
142 142
 
143  
-        before_alls.each { |blk| running_example_group.instance_eval(&blk) }
144  
-        running_example_group.instance_variables.each { |ivar| before_all_ivars[ivar] = running_example_group.instance_variable_get(ivar) }
  143
+        before_alls.each { |blk| running_example.instance_eval(&blk) }
  144
+        running_example.instance_variables.each { |ivar| before_all_ivars[ivar] = running_example.instance_variable_get(ivar) }
145 145
       end
146 146
 
147  
-      def self.eval_before_eachs(running_example_group)
148  
-        Rspec::Core.configuration.find_advice(:before, :each, self).each { |blk| running_example_group.instance_eval(&blk) }
149  
-        before_ancestors.each { |ancestor| ancestor.before_eachs.each { |blk| running_example_group.instance_eval(&blk) } }
  147
+      def self.eval_before_eachs(running_example)
  148
+        Rspec::Core.configuration.find_advice(:before, :each, self).each { |blk| running_example.instance_eval(&blk) }
  149
+        before_ancestors.each { |ancestor| ancestor.before_eachs.each { |blk| running_example.instance_eval(&blk) } }
150 150
       end
151 151
 
152  
-      def self.eval_after_alls(running_example_group)
153  
-        after_alls.each { |blk| running_example_group.instance_eval(&blk) }
154  
-        Rspec::Core.configuration.find_advice(:after, :all, self).each { |blk| running_example_group.instance_eval(&blk) }
155  
-        before_all_ivars.keys.each { |ivar| before_all_ivars[ivar] = running_example_group.instance_variable_get(ivar) }
  152
+      def self.eval_after_alls(running_example)
  153
+        after_alls.each { |blk| running_example.instance_eval(&blk) }
  154
+        Rspec::Core.configuration.find_advice(:after, :all, self).each { |blk| running_example.instance_eval(&blk) }
  155
+        before_all_ivars.keys.each { |ivar| before_all_ivars[ivar] = running_example.instance_variable_get(ivar) }
156 156
       end
157 157
 
158  
-      def self.eval_after_eachs(running_example_group)
159  
-        after_ancestors.each { |ancestor| ancestor.after_eachs.each { |blk| running_example_group.instance_eval(&blk) } }
160  
-        Rspec::Core.configuration.find_advice(:after, :each, self).each { |blk| running_example_group.instance_eval(&blk) }
  158
+      def self.eval_after_eachs(running_example)
  159
+        after_ancestors.each { |ancestor| ancestor.after_eachs.each { |blk| running_example.instance_eval(&blk) } }
  160
+        Rspec::Core.configuration.find_advice(:after, :each, self).each { |blk| running_example.instance_eval(&blk) }
161 161
       end
162 162
 
163 163
       def self.run(reporter)
164  
-        example_world = new
  164
+        example_group_instance = new
165 165
         reporter.add_example_group(self)
166  
-        eval_before_alls(example_world)
167  
-        success = run_examples(example_world, reporter)
168  
-        eval_after_alls(example_world)
  166
+        eval_before_alls(example_group_instance)
  167
+        success = run_examples(example_group_instance, reporter)
  168
+        eval_after_alls(example_group_instance)
169 169
 
170 170
         success
171 171
       end

0 notes on commit b7d07df

Please sign in to comment.
Something went wrong with that request. Please try again.