Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 0191b56

Browse files
committed
Refactor specs to stop using alternate config/world instances.
The use of alternate world and config instances was getting in the way of some changes I want to make related to group registration and isn't needed since we sandbox things so each spec runs with fresh world and config instances.
1 parent ce5bbf0 commit 0191b56

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

spec/rspec/core/configuration_spec.rb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,18 @@ module RSpec::Core
2121
end
2222

2323
describe '#on_example_group_definition' do
24-
let(:configuration) do
25-
tmp_config = RSpec::Core::Configuration.new
26-
tmp_config.on_example_group_definition do |example_group|
27-
example_group.examples.first.metadata[:new_key] = :new_value
24+
before do
25+
RSpec.configure do |c|
26+
c.on_example_group_definition do |example_group|
27+
example_group.examples.first.metadata[:new_key] = :new_value
28+
end
2829
end
29-
tmp_config
3030
end
31-
let(:world) { RSpec::Core::World.new(configuration) }
3231

3332
it 'successfully invokes the block' do
3433
example_group = RSpec.describe("group") { it "example 1" do; end}
35-
world.register(example_group)
36-
example = world.example_groups.first.examples.first
34+
RSpec.world.register(example_group)
35+
example = RSpec.world.example_groups.first.examples.first
3736
expect(example.metadata[:new_key]).to eq(:new_value)
3837
end
3938
end

spec/rspec/core/example_group_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,10 @@ def ascending_numbers
359359
end
360360

361361
it "is not registered in world" do
362-
world = RSpec::Core::World.new
363362
parent = RSpec.describe
364-
world.register(parent)
365363
parent.describe
366-
expect(world.example_groups).to eq([parent])
364+
365+
expect(RSpec.world.example_groups).to eq([parent])
367366
end
368367
end
369368

spec/rspec/core/world_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ class Foo; end
44
module RSpec::Core
55

66
RSpec.describe RSpec::Core::World do
7-
let(:configuration) { RSpec::Core::Configuration.new }
8-
let(:world) { RSpec::Core::World.new(configuration) }
7+
let(:configuration) { RSpec.configuration }
8+
let(:world) { RSpec.world }
99

1010
describe '#reset' do
1111
it 'clears #example_groups' do

0 commit comments

Comments
 (0)