Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

RSpec.reset reinits configuration and world

- Fixes #621 (for realz)
  • Loading branch information...
commit e8eae4ddea6a8f903261a8859c864eb50907778d 1 parent 2d61d16
@dchelimsky dchelimsky authored
View
4 lib/rspec/core.rb
@@ -66,8 +66,8 @@ def self.world
# Used internally to ensure examples get reloaded between multiple runs in
# the same process.
def self.reset
- world.reset
- configuration.reset
+ @world = nil
+ @configuration = nil
end
# Returns the global [Configuration](RSpec/Core/Configuration) object. While you
View
7 spec/rspec/core/runner_spec.rb
@@ -25,10 +25,9 @@ module RSpec::Core
let(:err) { StringIO.new }
let(:out) { StringIO.new }
- it "resets world and configuration" do
- RSpec.configuration.stub(:files_to_run) { [] }
- RSpec.configuration.should_receive(:reset)
- RSpec.world.should_receive(:reset)
+ it "tells RSpec to reset" do
+ RSpec.configuration.stub(:files_to_run => [])
+ RSpec.should_receive(:reset)
RSpec::Core::Runner.run([], err, out)
end
View
38 spec/rspec/core_spec.rb
@@ -1,21 +1,35 @@
require 'spec_helper'
-describe "RSpec.configuration" do
- it "returns the same object every time" do
- RSpec.configuration.should equal(RSpec.configuration)
+describe RSpec do
+ describe "::configuration" do
+ it "returns the same object every time" do
+ RSpec.configuration.should equal(RSpec.configuration)
+ end
end
-end
-describe "RSpec.configure" do
- it "yields the current configuration" do
- RSpec.configure do |config|
- config.should eq(RSpec::configuration)
+ describe "::configure" do
+ it "yields the current configuration" do
+ RSpec.configure do |config|
+ config.should equal(RSpec::configuration)
+ end
end
end
-end
-describe "RSpec.world" do
- it "returns the RSpec::Core::World instance the current run is using" do
- RSpec.world.should be_instance_of(RSpec::Core::World)
+ describe "::world" do
+ it "returns the same object every time" do
+ RSpec.world.should equal(RSpec.world)
+ end
+ end
+
+ describe "::reset" do
+ it "resets the configuration and world objects" do
+ config_before_reset = RSpec.configuration
+ world_before_reset = RSpec.world
+
+ RSpec.reset
+
+ RSpec.configuration.should_not equal(config_before_reset)
+ RSpec.world.should_not equal(world_before_reset)
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.