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

Commit 7cba761

Browse files
committed
As each file is required, push it onto requires
1 parent 787670c commit 7cba761

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

lib/rspec/core/configuration.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,8 +1604,10 @@ def configure_example(example, example_hooks)
16041604
def requires=(paths)
16051605
directories = ['lib', default_path].select { |p| File.directory? p }
16061606
RSpec::Core::RubyProject.add_to_load_path(*directories)
1607-
paths.each { |path| load_file_handling_errors(:require, path) }
1608-
@requires += paths
1607+
paths.each { |path|
1608+
load_file_handling_errors(:require, path)
1609+
@requires << path
1610+
}
16091611
end
16101612

16111613
# @private

spec/rspec/core/configuration_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,16 @@ def absolute_path_to(dir)
237237
expect(config.requires).to eq ['a/path']
238238
end
239239

240+
it 'stores required paths "per file"' do
241+
allow(config).to receive(:require).with('a/path')
242+
expect(config).to receive(:require).with('another/path') do
243+
expect(config.requires).to eq ['a/path']
244+
end
245+
246+
config.requires = ['a/path', 'another/path']
247+
expect(config.requires).to eq ['a/path', 'another/path']
248+
end
249+
240250
context "when `default_path` refers to a file rather than a directory" do
241251
it 'does not add it to the load path' do
242252
config.default_path = 'Rakefile'

0 commit comments

Comments
 (0)