Permalink
Browse files

Remove dep from ExampleGroup to Configuration (now EG gets

everything it needs from World).
  • Loading branch information...
1 parent 63fb5c4 commit 5d95ab996e5f923872aeeacf61e0545e71856759 @dchelimsky dchelimsky committed May 10, 2010
Showing with 18 additions and 12 deletions.
  1. +1 −7 lib/rspec/core/example_group.rb
  2. +10 −2 lib/rspec/core/world.rb
  3. +7 −3 spec/rspec/core/configuration_spec.rb
@@ -82,15 +82,10 @@ 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.new(superclass_metadata).process(*args)
- configuration.find_modules(self).each do |include_or_extend, mod, opts|
+ world.find_modules(self).each do |include_or_extend, mod, opts|
if include_or_extend == :extend
send(:extend, mod) unless extended_modules.include?(mod)
else
@@ -109,7 +104,6 @@ def self.describe(*args, &example_group_block)
args << {} unless args.last.is_a?(Hash)
args.last.update(:example_group_block => example_group_block)
args.last.update(:caller => caller)
- args.unshift Rspec.configuration unless args.first.is_a?(Rspec::Core::Configuration)
# TODO 2010-05-05: Because we don't know if const_set is thread-safe
child = const_set(
View
@@ -8,12 +8,20 @@ def initialize
@example_groups = []
end
+ def configuration
+ Rspec.configuration
+ end
+
def inclusion_filter
- Rspec.configuration.filter
+ configuration.filter
end
def exclusion_filter
- Rspec.configuration.exclusion_filter
+ configuration.exclusion_filter
+ end
+
+ def find_modules(group)
+ configuration.find_modules(group)
end
def shared_example_groups
@@ -6,6 +6,10 @@ module Rspec::Core
let(:config) { subject }
+ before(:each) do
+ Rspec::Core.world.stub(:configuration).and_return(config)
+ end
+
describe "#mock_framework_class" do
before(:each) do
config.stub(:require)
@@ -136,7 +140,7 @@ def you_call_this_a_blt?
it "includes the given module into each example group" do
config.include(InstanceLevelMethods)
- group = ExampleGroup.describe(config, 'does like, stuff and junk', :magic_key => :include) { }
+ group = ExampleGroup.describe('does like, stuff and junk', :magic_key => :include) { }
group.should_not respond_to(:you_call_this_a_blt?)
group.new.you_call_this_a_blt?.should == "egad man, where's the mayo?!?!?"
end
@@ -147,7 +151,7 @@ def you_call_this_a_blt?
it "includes the given module into each matching example group" do
config.include(InstanceLevelMethods, :magic_key => :include)
- group = ExampleGroup.describe(config, 'does like, stuff and junk', :magic_key => :include) { }
+ group = ExampleGroup.describe('does like, stuff and junk', :magic_key => :include) { }
group.should_not respond_to(:you_call_this_a_blt?)
group.new.you_call_this_a_blt?.should == "egad man, where's the mayo?!?!?"
end
@@ -164,7 +168,7 @@ def that_thing
it "should extend the given module into each matching example group" do
config.extend(ThatThingISentYou, :magic_key => :extend)
- group = ExampleGroup.describe(config, ThatThingISentYou, :magic_key => :extend) { }
+ group = ExampleGroup.describe(ThatThingISentYou, :magic_key => :extend) { }
group.should respond_to(:that_thing)
end

0 comments on commit 5d95ab9

Please sign in to comment.