Permalink
Browse files

clear the world after each run

- Closes #367.
  • Loading branch information...
1 parent f994d21 commit 71cb7aff9c70e766b2a3e92f3eef014e356cdf2d @dchelimsky dchelimsky committed May 8, 2011
Showing with 15 additions and 2 deletions.
  1. +6 −0 lib/rspec/core.rb
  2. +1 −0 lib/rspec/core/runner.rb
  3. +8 −2 spec/rspec/core/runner_spec.rb
View
@@ -49,6 +49,12 @@ def self.world
@world ||= RSpec::Core::World.new
end
+ # Sets the world to nil. Used internally to ensure examples get reloaded
+ # between multiple runs in the same process.
+ def self.clear_world
+ @world = nil
+ end
+
def self.configuration
@configuration ||= RSpec::Core::Configuration.new
end
View
@@ -67,6 +67,7 @@ def self.run(args, err=$stderr, out=$stdout)
end
else
run_in_process(options, err, out)
+ RSpec.clear_world
end
end
@@ -21,9 +21,15 @@ module RSpec::Core
end
describe "#run" do
+ let(:err) { StringIO.new }
+ let(:out) { StringIO.new }
+
+ it "clears the world" do
+ RSpec.should_receive(:clear_world)
+ RSpec::Core::Runner.run([], err, out)
+ end
+
context "with --drb or -X" do
- let(:err) { StringIO.new }
- let(:out) { StringIO.new }
before(:each) do
@options = RSpec::Core::ConfigurationOptions.new(%w[--drb --drb-port 8181 --color])

0 comments on commit 71cb7af

Please sign in to comment.